Jump to content

Adding product to newly created cart programatically


Recommended Posts

I am creating a new cart and simply add a product in that newly created cart, but the product get added to the cart that was created before not to the newly created, why?

 

I dont want to use the context cart, it is more like a backend process that has nothing to do with a front-end user interaction. 

 

Adding $cart->update does not solve it. 

include('../../config/config.inc.php');
include('../../init.php');

$cart = new Cart(); 
$cart->id_customer = 1;
$cart->id_address_delivery = (int)  (Address::getFirstCustomerAddressId($cart->id_customer)); 
$cart->id_address_invoice = $cart->id_address_delivery; 
$cart->id_lang = 1; 
$cart->id_currency = 2; 
$cart->id_carrier = 1; 
$cart->recyclable = 0; 
$cart->gift = 0; 
$cart->add(); 
$cookie->id_cart = (int)($cart->id);
$cart->updateQty(1, 4); //add one unit of product id 4 
Edited by AlainGau (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...