Jump to content

Edit History

skrittar

skrittar

Try to assign new cart object to `context` after create.

$this->context->cart = $cart;

This solved my problem

$cart = $this->context->cart;
if (!$this->context->cart->id){
  $cart = new Cart();
  $cart->id_customer = (int)($this->context->cookie->id_customer);
  $cart->id_address_delivery = (int)  (Address::getFirstCustomerAddressId($cart->id_customer));
  $cart->id_address_invoice = $cart->id_address_delivery;
  $cart->id_lang = (int)($this->context->cookie->id_lang);
  $cart->id_currency = (int)($this->context->cookie->id_currency);
  $cart->id_carrier = 1;
  $cart->recyclable = 0;
  $cart->gift = 0;
  $cart->add();
  $this->context->cookie->id_cart = (int)($cart->id);
  $this->context->cart = $cart;
}

 

skrittar

skrittar

Try to assign new cart object to `context` after create.

$this->context->cart = $cart;

 

×
×
  • Create New...