LemonStand Documentation

shop:on_addToCompare

This AJAX handler allows you to add a product to the product comparison list. Usage example: 

<a href="#" onclick="return $(this).getForm().sendRequest(
  'shop:on_addToCompare', {
     onSuccess: function(){alert('The product has been added to the compare list')},
     extraFields: {product_id: '<?= $product->id ?>'},
     update: {compare_list: 'shop:compare_list'}
});">Add to compare</a>

The product_id parameter is required. Use it to pass an identifier of a product you are adding to the list, to the AJAX handler. Please note that the request in the example updates a page element with compare_list identifier, using the shop:compare_list partial. You may need to replace the element and partial identifiers in your implementation.

See also:

Next: shop:on_removeFromCompare
Previous: Shop_PaymentMethod
Return to Reference