[英]Magento Add to cart button issue after upgrade 1.5 to 1.9
I just upgrade Magento 1.5 to 1.9 and I have a small issue, in the shopping cart I add some products, in my store this are free gifts, each of this products have Add to cart button, but I don't know why in Magento 1.9 this button is not work: 我只是将Magento 1.5升级到1.9并且我有一个小问题,在购物车中我添加了一些产品,在我的商店这是免费赠品,每个产品都有添加到购物车按钮,但我不知道为什么在Magento 1.9这个按钮不起作用:
<button class="button btn-cart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$giftPro->getId(),'qty'=>1)) ?>')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
and the url in this button is: 并且此按钮中的URL是:
http://mystore.com/checkout/cart/add/product/1444/qty/1/ http://mystore.com/checkout/cart/add/product/1444/qty/1/
If i press on add to cart the page is only refreshing, but the product is not add to cart. 如果我按下添加到购物车页面只是刷新,但产品不添加到购物车。 How I need to do this button to work in the 1.9 version?
我怎么需要这个按钮才能在1.9版本中工作?
Thank you 谢谢
I found a solution I use something like this: 我发现了一个使用这样的解决方案:
<button class="button btn-cart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$giftPro->getId(),'qty'=>1, 'form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
After some research I found that for 1.9 we need to add 'form_key' => Mage::getSingleton('core/session')->getFormKey()
经过一些研究,我发现对于1.9我们需要添加
'form_key' => Mage::getSingleton('core/session')->getFormKey()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.