Jump to content

How to add product to cart programmatically


Tárraga
 Share

Recommended Posts

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?

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 1 year later...
  • 10 months later...
  • 11 months later...
  • 11 months later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More