When opening up a product page (example.com/store/women/catalog/product/view/id/215/) in a new session and using the standard add to cart, my product gets dropped and says the shopping cart is empty. However, once a ?SID= is assigned I am able to add the product to the cart. I am using Lesti::FPC.

Form action before getting an SID:

action="http://example.com/store/women/checkout/cart/add/uenc/aHR0cDovL3ByaW9yaXR5b3V0Zml0dGVyLmNvbS9zdG9yZS93b21lbi9jYXRhbG9nL3Byb2R1Y3Qvdmlldy9pZC8yMTUvP1NJRD1jYWUwNjU4ZWNiNjkxNTdjZDczMzZkNTllY2E0MmJmMg,,/product/215/form_key/Dij9pPXAwRBzAywH/?<(!)-- fpc session_id_placeholder -->"

Form action after getting an SID:


They are the same besides the fpc session_id_placeholder

  • Are you able to fix this issue? if yes, then please post the solution. – Anshu Mishra Aug 14 '14 at 7:59

You need to add the form key to the cart add link:


$formKey = Mage::getSingleton('core/session')->getFormKey();?>

<form action="/checkout/cart/add/product/<?php echo $productid; ?>" method="post">
    <input type="hidden" name="form_key" value="<?php echo $formKey; ?>" />

    <input type="text" name="qty"> QTY

    <input type="submit" value="Add to basket" />

Resource: https://stackoverflow.com/a/19999360/582138

  • I'm not quite sure this is what I actually need. I am linking to a product page: example.com/store/catalog/product/view/id/215/. When first time customers arrive here and click add to cart, the product gets dropped – kicksforlaughs Apr 8 '14 at 20:55
 <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>" method="post" id="product_addtocart_form"enctype="multipart/form-data">

         <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
           <input name="qty" value="  1" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
     <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add+')) ?>" onclick=" this.form.submit()" id="product-addtocart-button" class="button btn-cart" ><span><span><?php echo $this->__('Add+') ?></span></span></button>


  public function getAddUrl($product, $additional = array())
      $routeParams = array(

            Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()

        return $this->_getUrl('checkout/cart/add', $routeParams);


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.