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