Answer the question
In order to leave comments, you need to log in
How to auto add items to cart in opencart 3?
How to auto add items to cart in opencart 3? There is a code from 2 opencart, but on version 3, it unfortunately does not work. Help him fix it for version 3. I will be very grateful. Here is the code
//// add
$needed_products=array(47,28);///Через запятую ID нужных товаров
////
////add
$cart_products = array();
foreach ($this->session->data['cart'] as $key => $quantity) {
$product = explode(':', $key);
$cart_products[] = $product[0];
}
foreach($needed_products as $needed_product){
if(!in_array($needed_product, $cart_products)){
$this->cart->add($needed_product, 1, array());// Перебираем наши товары и добавляем в корзину, если товара еще там нет. Добавляем 1 ед. товара без опций.
}
}
/////
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question