Would it be possible to add a button in checkout cart page to add a product to cart?

That product would always have the same SKU and would be dynamically created. By dynamically I mean that the price would depend on the product it is being added to (I guess I could just pass the SKU of the product it is being addded to in a URL of a button or form).

Any ideas or suggestions on how to make this work?

1 Answer 1


The following would work by loading a product by $sku & generate the appropriate add-to-cart HTML:

    $sku = 'your_sku';
    $url = Mage::helper('checkout/cart')->getAddUrl(Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)); 
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $url; ?>')">
      <?php echo $this->__('Add to Cart') ?>

You'd need to place the code in app/design/frontend/yourtheme/default/template/checkout/cart.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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