nimeshmakwana Posted September 30, 2015 Share Posted September 30, 2015 how to add product dynamically plz hepl my code <?phprequire(dirname(__FILE__).'/config/config.inc.php');$context=Context::getContext();//new Cart();$id_cart=$context->cookie->__get('id_cart');$products_ids=$_GET['products_ids']; // comma seprated products id example : test.php?products_ids=1,2,3$products_ids_array=explode(",",$products_ids);if(count($products_ids_array)>0){ $cart=new Cart($id_cart); $cart->id_currency=2; $cart->id_lang=1; foreach($products_ids_array as $key=>$id_product){ $cart->updateQty(1, $id_product); [spam-filter]?> Link to comment Share on other sites More sharing options...
jgamio Posted September 30, 2015 Share Posted September 30, 2015 Hi maybe these help you first read get the cart if ($this->context->cookie->id_cart) { $cart = new Cart($this->context->cookie->id_cart); } after check if is a cart if not create I think you miss the customer part if (!isset($cart) OR !$cart->id) { $cart = new Cart(); $cart->id_customer = (int)($this->context->cookie->id_customer); $cart->add(); $this->context->cookie->id_cart = (int)($cart->id); $cart->update(); } after that you can add products Link to comment Share on other sites More sharing options...
nimeshmakwana Posted October 1, 2015 Author Share Posted October 1, 2015 Thanks for the explanation. 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