Putting Add to Cart on the front page
#1
Posted 12 September 2010 - 02:47 PM
#2
Posted 12 September 2010 - 04:02 PM
The shop:on_addToCart handler (http://lemonstandapp...n_shop_product/) does not require a product identifier if it is called from the product details page. That is why you didn't find product-speicfic fields in the product_parital partial. If you call this handler from other pages, you need to pass the product_id parameter to the server. You can do it using a hidden field, or with the AJAX request:
<input onclick="return $(this).getForm().sendRequest('shop:on_addToCart',
{
extraFields: {
'product_id': <?= $product->id ?>
}
})" type="button" value="Add to cart"/>Thank you
#3
Posted 12 September 2010 - 04:28 PM
<input onclick="return $(this).getForm().sendRequest(
'shop:on_addToCart', {
update: {
'mini_cart': 'shop:mini_cart', 'introContent': 'shop:product_list'
},
extraFields: {
'product_id': <?= $product->id ?>
}
})" type="image" name="add_to_cart" class="add_to_cart" src="<?= root_url('/resources/images/btn_add_to_cart.gif') ?>" alt="Add to cart"/>
#4
Posted 12 September 2010 - 04:29 PM
Please check whether the product_id parameter has value. You can inspect it using FireBug, or just look to the page source code.
Thanks
#5
Posted 12 September 2010 - 04:32 PM
Yes, the param has value (source listing):
<p class="center" style="padding: 5px 0 0 0;">
<input onclick="return $(this).getForm().sendRequest(
'shop:on_addToCart', {
update: {
'mini_cart': 'shop:mini_cart', 'introContent': 'shop:product_list'
},
extraFields: {
'product_id': 53 }
})" type="image" name="add_to_cart" class="add_to_cart" src="/resources/images/btn_add_to_cart.gif" alt="Add to cart"/>
</p>
#6
Posted 12 September 2010 - 04:35 PM
#7
Posted 12 September 2010 - 04:45 PM
BTW, the simplest way is to not update the product list at all. Instead, you can create a DIV element above the list and update it with the flash message partial. It is simpler for the server as well. So, the solution is:
1. Create a new DIV element above the list and assign it some ID, for example 'flash'
2. Create a new partial with the <?= flash_message() ?> code inside and assign it some name, for example 'flash_partial'
3. In the AJAX request alter the update parameter:
update: {
'mini_cart': 'shop:mini_cart', 'flash': 'flash_partial'
}I hope this helps!
#8
Posted 12 September 2010 - 04:52 PM
#9
Posted 12 September 2010 - 05:01 PM
#10
Posted 12 September 2010 - 05:06 PM

Help














