Tárraga Posted May 5, 2016 Share Posted May 5, 2016 Hello! I'm making a file which will add some products to the cart in PrestaShop, but it doesn't work. Here is my code: require(dirname(__FILE__).'/config/config.inc.php'); $context=Context::getContext(); $id_cart=$context->cookie->__get('id_cart'); $id_product = $_GET['id_product']; $attribute = $_GET['attribute']; $cart=new Cart($id_cart); $cart->id_currency=1; $cart->id_lang=1; $cart->updateQty(1, $id_product, $attribute, false); So I execute it from file.php?id_product=555&attribute=666 It doesn't work. Why? Link to comment Share on other sites More sharing options...
ernestvidal Posted July 28, 2016 Share Posted July 28, 2016 $cart->add() is missing 1 Link to comment Share on other sites More sharing options...
khaya Posted May 2, 2018 Share Posted May 2, 2018 Where do you put $cart->add() ? Link to comment Share on other sites More sharing options...
digitalDot Posted March 27, 2019 Share Posted March 27, 2019 This is the command for add programmatically $cart>updateQty(1, $id_product, 0, null, 'up', 0, null, false); Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 20, 2020 Share Posted March 20, 2020 Ok guys, this works when customer has his cart already filled with something or it is created but what to do if someone don't have a cart created already? Link to comment Share on other sites More sharing options...
Patryk Tchórzewski Posted February 21, 2021 Share Posted February 21, 2021 Just create new cart: new Cart() and set all required fields and add products like @digitalDot said 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