简体   繁体   English

Magento - 在类别页面上添加到购物车不起作用

[英]Magento - add to cart on category page not working

After upgrading Magento 1.7.0 to 1.8.0 (or 1.8.1.0. for that matter) I've noticed that the add to cart function on the product details page and the categorie overview page were no longer working.在将 Magento 1.7.0 升级到 1.8.0(或 1.8.1.0。就此而言)后,我注意到产品详细信息页面和类别概览页面上的添加到购物车功能不再有效。 When clicking on the add to cart button the cart is loading properly but is stating: "You have no items in your shopping cart."单击添加到购物车按钮时,购物车正在正确加载,但显示:“您的购物车中没有任何商品。”

Because this function is rather important for a webshop we took this problem very seriously.因为这个功能对于网店来说相当重要,所以我们非常重视这个问题。

While searching for an answer I've noticed that the problem could be related to formkeys.在寻找答案时,我注意到问题可能与 formkeys 有关。 To solve the problem with the product details page we added a line of PHP-code to yourtemplate/template/catalog/product/view.phtml right after the form opening tag.为了解决产品详细信息页面的问题,我们在表单开始标签之后添加了一行 PHP 代码到 yourtemplate/template/catalog/product/view.phtml。

After line (42):第 (42) 行之后:

<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>:

Add:添加:

<?php echo $this->getBlockHtml('formkey'); ?>

After solving this there only remains two questions.解决这个问题后,只剩下两个问题。

  1. The add to cart buttons on the categorie pages are still not working.类别页面上的添加到购物车按钮仍然不起作用。 How can we fix this?我们怎样才能解决这个问题?
  2. How does it come that upgrading to Magento 1.8.0 or 1.8.1.0.升级到 Magento 1.8.0 或 1.8.1.0 是怎么回事。 is producing this kind of errors?正在产生这种错误? Does any one else know what this problem is?有没有其他人知道这个问题是什么? Even the base/default theme is having this problem.甚至基本/默认主题也有这个问题。

Try the following code in the place of your 'Add to cart' button.在“添加到购物车”按钮的位置尝试使用以下代码。

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>

i have used this code but it is not working in magento version 1.9.2.x ..need help to fixed this issues....我已经使用了这段代码,但它在 magento 版本 1.9.2.x 中不起作用......需要帮助来解决这个问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM