7/20/2010

Get Add to cart button url in Magento

<input type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$row['product_id'],'qty'=>1)) ?>')" />

9 comments:

  1. Anonymous12/13/2010

    cool, thanks.

    ReplyDelete
  2. MAGENTO-FOLDER/app/design/frontend/YOUR-THEME/default/template/catalog/product/list.phtml

    ReplyDelete
  3. Its working thanks for sharing this. its really help full.

    ReplyDelete
  4. Thanks Its working...........after putting correct variable instead of $row['product_id']

    ReplyDelete
  5. I want to redirect to shopping cart page instead of product detail page , how can we do this ?

    ReplyDelete
    Replies
    1. Mage::getUrl('checkout/cart/add').. After adding the product to the cart it will automatically redirect the page to Shopping cart page

      Delete
    2. thanks for this post

      Delete
    3. Thanks for this post

      Delete
  6. Anonymous6/02/2017

    Hello,

    i have tried it, but not worked for me. its redirected to home page without updating cart. Any help Please...

    ReplyDelete