Jump to content

Problem with adding the product to the uninitialized basket


Recommended Posts

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 by 24box (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...