Is it possible to add certain product(s) to cart when some conditions are met?
For expample: My condition is - if is in cart any product from category C then add product X and you can`t delete it form cart if this condition is still active.
Customer adds Product P from category C and system automaticlly adds product X so in cart are two product now.
My goal is to have those two product in invoice as two separate items then. Manually adding that second product is not an option.
答案 0 :(得分:0)
在cart.php这里有一个名为add的方法
Catalog->controller->checkout->cart.php
您可以在其中获得用户点击的产品ID,以便将该产品添加到购物车中,您可以在此处查看此产品属于哪个类别的条件。如果您的条件为真,那么您可以使用此方法将另一个选项产品添加到购物车
$this->cart->add($optional-Product_id, $quantity, $option, $recurring_id);
-> by default $quantity will be 1.
-> By default $recurring_id will be 0.
-> And $option would be an array ($option = array()).
我希望这会对你有所帮助。