如何设置在Opencart中只向购物车添加/购买一件商品的权限?

时间:2013-09-17 09:13:22

标签: php e-commerce opencart

我想让客户只从我的商店购买一种产品。客户可以添加仅添加一个产品到购物车,数量也应该只有一个,但当前的opencart系统正在向购物车添加多个产品。如何在Opencart 1.5.5中创建这样的系统?

1 个答案:

答案 0 :(得分:1)

我使用此论坛帖子创建了系统: http://forum.opencart.com/viewtopic.php?t=28181

  1. 编辑:system/library/cart.php

  2. FIND:

    $ this-> session-> data ['cart'] [$ key] + =(int)$ qty;

  3. 更换:

    $ this-> session-> data ['cart'] [$ key] =(int)$ qty;

  4. 然后

    1. 编辑:system/library/cart.php
    2. 2a上。 FIND(1.4.x):

      if(!$ options){

      2B。 FIND(1.5.x):

      if(!$ option){

      1. BEFORE,ADD:
      2. $这 - >清除();

        这会将客户设置为仅向购物车添加一个产品。但是当您从购物车页面更新数量时,它将更新为给定数量。要解决这个问题,我们应该更改/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);
        }
        
相关问题