Charles Anssens
Charles Anssens

Reputation: 143

How to automatically create a cart for a customer in prestashop?

I would like to create automatically a cart for a customer with a product. Then the customer can login on the site and validate the cart.

I saw how to create a cart in my module but i don't understand how to affect the cart to a customer?

Upvotes: 0

Views: 1393

Answers (1)

klimpond
klimpond

Reputation: 766

Binding created cart to customer is very simple:

$cart = new Cart();
//Add products or what so ever
$cart->id_customer = $my_customer_id;
$cart->update();

or simply update your ps_cart database table and set proper id_customer value. You can create a module with this code in a function with hook transplanted to actionAuthentication, which is executed after customer successful login to your e-shop.

Upvotes: 1

Related Questions