我正在尝试从类别页面添加项目。但它将我带到下一个产品页面,而不是将此类产品添加到购物车中。但是相同的功能在产品页面中正常工作。
要找到我添加的解决方案
to check what array i am getting. After adding it such functionality of add to cart in category page was working. I am a bit confuse what to do with that. Kindly help or advice. Following is the code for Add-to-Cart button in category.tpl file.
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span> <i class="fa fa-shopping-cart"></i></button>
答案 0 :(得分:1)
好的,即使我对opencart一无所知,我也很快检查了这个演示。 似乎有一些类别项可以按预期添加:
POST http://demo.opencart.com/index.php?route=checkout/cart/add
200 OK
{"success":"Success: You have added <a href=\"http:\/\/demo.opencart.com\/index.php?route=product\/product
&product_id=41\">iMac<\/a> to your <a href=\"http:\/\/demo.opencart.com\/index.php?route=checkout
\/cart\">shopping cart<\/a>!","total":"2 item(s) - $244.00"}
其他的返回某种形式错误:
POST http://demo.opencart.com/index.php?route=checkout/cart/add
{"error":{"option":{"218":"Radio required!","223":"Checkbox required!","208":"Text required!","217":"Select
required!","209":"Textarea required!","222":"File required!","219":"Date required!","221":"Time required
!","220":"Date & Time required!"}},"redirect":"http:\/\/demo.opencart.com\/index.php?route=product
\/product&product_id=42"}
而不是显示正确的错误消息,而是发送重定向网址。似乎那是你被重定向到的那个。看起来像代码的预期行为,以隐藏错误发生。
也许这可以帮助您缩小错误范围。祝你好运。