dpxw7293 2017-06-21 13:24
浏览 40
已采纳

Opencart 1.5.4 - 不验证同一产品的不同选项的最小订单数量

For my Opencart 1.5.4 project, we have set the minimum 12 quantity for product. If the user select the quantity less than 12 it will not allow user to buy it (Opencart validate this on cart page). But if user selects the same product in the group of different option (small, medium, large) individual less than 12 then he can place the order.

For e.g.

Product A (small) 6 Qty

Product A (medium) 6 Qty

Product A (large) 10 Qty

Total quantity is 22.

But I want individual item quantity is minimum 12 like below,

Product A (small) 12 Qty (minimum 12)

Product A (medium) 12 Qty (minimum 12)

Product A (large) 12 Qty (minimum 12)

Opencart is not treated different options as different product in cart and user can easily buy individual product in less than 12 quantity.

Can any one suggest me why this happen and how to fix this issue? Any extension is available for that?

  • 写回答

1条回答 默认 最新

  • dphg63476 2017-06-22 06:16
    关注

    I have found the solution of this issue, for that I have to make changes in the cart and checkout controller. By default Opencart is calculating the product quantity on the cart page by product id. I have customized the code and now it will check the individual quantity of each product in the cart.

    Cart controller ==> Cart.php \catalog\controller\checkout\cart.php make changes in line no 192 to 197

    foreach ($products as $product) {
    
        $product_total = 0;
        $allCartProductId[] = $product['product_id'];
        foreach ($products as $product_2) {
            if ($product_2['product_id'] == $product['product_id']) {
                $product_total += $product_2['quantity'];
            }
        }
    
        if ($product['minimum'] > $product_total) {
            $this->data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']) 
        }
    }
    

    To

    foreach ($products as $product) {
    
                    $product_total = 0;
                    $allCartProductId[] = $product['product_id'];
    
                            $product_total += $product['quantity'];
    
                    if ($product['minimum'] > $product_total) {
                        $this->data['error_warning'] .= sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum'])."<br>";
                    }
    

    Checkout controller ==> checkout.php \catalog\controller\checkout\checkout.php make changes in line no 15 to 20

    foreach ($products as $product) {
            $product_total = 0;
    
            foreach ($products as $product_2) {
                if ($product_2['product_id'] == $product['product_id']) {
                    $product_total += $product_2['quantity'];
                }
            }
    

    To

    foreach ($products as $product) {
        $product_total = 0;         
        $product_total += $product['quantity'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器