24box Posted May 14, 2018 Share Posted May 14, 2018 (edited) Hi, I've got a problem with adding the product to the uninitialized basket using my plugin. Everything works fine when there is already a product in the basket or a user is logged in. When there's none, adding a product doesn't work. Is there any method to initialize the basket for that purpose? The code is: $cart = new Cart(); $cart->id_lang = (int) $this->context->cookie->id_lang; $cart->id_currency = (int) $this->context->cookie->id_currency; $cart->id_guest = (int) $this->context->cookie->id_guest; $cart->id_shop_group = (int) $this->context->shop->id_shop_group; $cart->id_shop = $this->context->shop->id; if ($this->context->cookie->id_customer) { $cart->id_customer = (int) $this->context->cookie->id_customer; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); $cart->id_address_invoice = (int) $cart->id_address_delivery; } else { $cart->id_address_delivery = 0; $cart->id_address_invoice = 0; } $cart->updateQty((int)$quantity, (int)$idProduct); Best Regards Edited May 14, 2018 by 24box (see edit history) Link to comment Share on other sites More sharing options...
phinq1910 Posted May 15, 2018 Share Posted May 15, 2018 For add to cart via module, try refer hook actionCartSave Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now