Reputation: 461
I'm trying to get the current cart id from prestashop with:
$cookie->id_cart;
But it's blank until I add a product in the cart.
Is there any option to create that cart so I can get the id?
Thanks.
Upvotes: 2
Views: 7571
Reputation: 461
I have solved it, I just needed to create before the cart id.
if (is_null($context->cart->id)) {
$context->cart->add();
$context->cookie->__set('id_cart', $context->cart->id);
}
So I can now add products programmatically in my current cart.
Upvotes: 9