0

How can I create an 'add to cart' button for simple products within a grouped product AND still get the grouped product image to show in the cart when there is not an image specified for the simple?

I've added the button, code as below, for each simple within a grouped product but when I click to add the associated simple to the cart it doesn't display an image in the 'my cart' preview or on the cart page - it's just showing the placeholder image. I've tried getAddToCartUrl instead but it has the same issue.

<button type="button" class="button btn-cart buy-btns" id="<?php echo $_item->getId(); ?>" onclick="setLocation('<?php echo Mage::helper('checkout/cart')->getAddUrl($_item); ?>' + 'qty/' + $(this).previous().value; ?>')">Add to cart</button>

I assume it's treating it as an independant simple, however I do not have images on all my simples and want it to display the grouped product image if the simple does not have an image. Some of my simple products are in more than one grouped so I can't just pull any grouped image that it's associated with.

I've looked at the function getAddUrl in the Core code (Cart.php) and notice it has $additional parameters. Could this help me or can anyone help me resolve this issues? Many thanks.

0

Assuming you have a grouped of ID 635 and one of its simple products is 122, this is what your add to cart form needs to pass

product=635
super_group[122]=*qty*

that way you are adding product 122 to the cart, but the link in the cart remains to group 635

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.