0

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?

2

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

<?php
    $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; ?>')">
  <span>
    <span>
      <?php echo $this->__('Add to Cart') ?>
    </span>
  </span>
</button>

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

| improve this answer | |

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.