我想让客户只从我的商店购买一种产品。客户可以添加仅添加一个产品到购物车,数量也应该只有一个,但当前的opencart系统正在向购物车添加多个产品。如何在Opencart 1.5.5中创建这样的系统?
答案 0 :(得分:1)
我使用此论坛帖子创建了系统: http://forum.opencart.com/viewtopic.php?t=28181
编辑:system/library/cart.php
FIND:
$ this-> session-> data ['cart'] [$ key] + =(int)$ qty;
更换:
$ this-> session-> data ['cart'] [$ key] =(int)$ qty;
然后
system/library/cart.php
2a上。 FIND(1.4.x):
if(!$ options){
2B。 FIND(1.5.x):
if(!$ option){
$这 - >清除();
这会将客户设置为仅向购物车添加一个产品。但是当您从购物车页面更新数量时,它将更新为给定数量。要解决这个问题,我们应该更改/catalog/controller/checkout/cart.php
在 /catalog/controller/checkout/cart.php
的第13行查找if (!empty($this->request->post['quantity']))
替换现有的forloop,如下所示。我的意思是在循环内将值1设置为$ value。即使客户尝试更新购物车页面中的数量,它也会将数量重置为1.
foreach ($this->request->post['quantity'] as $key => $value) {
$value=1;
$this->cart->update($key, $value);
}