Opencart 1.5产品最小数量基于多个产品上的产品选项

时间:2018-07-21 22:36:41

标签: php opencart

我正在OpenCart 1.5商店工作,他们希望为他们拥有的各种T恤设计提供最低订购量。

首先,整个订单必须至少包含12种商品。大部分服装都有尺寸细分(从XS到4XL)。每种服装样式都可以采用7种设计之一进行丝网印刷。他们希望每个设计在订购时最少要有6个-可以分布在任何屏幕可打印项目上。

例如,一个客户可以购买6件设计A的衬衫和6件设计B的连帽衫,以最少订购12件。他们还可以购买3件男式T恤,2件女T恤和一个背心设计A和相似数量的设计B的顶部,使最小值最少12。

如果客户订购的任何设计的数量少于六个,则应该出现错误,要求他们添加更多设计的产品。

总共12项商品的最小购物车效果很好,问题是,如果客户未按每种设计订购最小数量的商品,系统将无法捕获。

我在第196行的catalog / controller / checkout / cart.php中提出了这种验证方式

如果有人可以推荐我如何进行这项工作,我将不胜感激。

$products = $this->cart->getProducts();

foreach ($products as $product) {
$product_total = 0;
$product_design_a = 0;
$product_design_b = 0;
$product_design_c = 0;
$product_design_d = 0;
$product_design_e = 0;
$product_design_f = 0;
$product_design_g = 0;

foreach ($products as $product_2) {
    if ($product_2['product_id'] == $product['product_id']) {
        $product_total += $product_2['quantity'];
    }
    if (($product_2['category_id'] = 77) or ($product_2['category_id'] = 84)) {
        if ($product_2['option_value_id'] = 1238) {
            $product_design_a += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1239) {
            $product_design_b += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1240) {
            $product_design_c += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1241) {
            $product_design_d += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1242) {
            $product_design_e += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1245) {
            $product_design_f += $product_2['quantity'];
        }
        if ($product_2['option_value_id'] = 1246) {
            $product_design_g += $product_2['quantity'];
        }
    }
}

if ($product_design_a + $product_design_b + $product_design_b + $product_design_b + $product_design_b + $product_design_b + $product_design_b != 0) {
    if ($product_design_a != 0 and $product_design_a < 6) {
        $this->data['error_warning'] = 'Please add more products with Will Flex For Food w CE Logo Back design';
    }
    elseif ($product_design_b != 0 and $product_design_b < 6) {
        $this->data['error_warning'] = 'Please add more products with Like a Snack w CE Logo Back design';
    }
    elseif ($product_design_c != 0 and $product_design_c < 6) {
        $this->data['error_warning'] = 'Please add more products with Hangry w CE Logo Back design';
    }
    elseif ($product_design_d != 0 and $product_design_d < 6) {
        $this->data['error_warning'] = 'Please add more products with Eat Clean Train Dirty w CE Logo Back design';
    }
    elseif ($product_design_e != 0 and $product_design_e < 6) {
        $this->data['error_warning'] = 'Please add more products with Feed Me w CE Logo Back design';
    }
    elseif ($product_design_f != 0 and $product_design_f < 6) {
        $this->data['error_warning'] = 'Please add more products with Clean Eatz Logo Front Only design';
    }
    elseif ($product_design_g != 0 and $product_design_g < 6) {
        $this->data['error_warning'] = 'Please add more products with Cafe Front Only design';
    }

    if ($product['minimum'] > $product_total) {
        $this->data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
    }
}

0 个答案:

没有答案