Jump to content

Show added Products To cart Programmatically


Recommended Posts

Hello Community ,

i created a module that import products by customer from an excel file for adding them to ps_cart table and ps_cart_product table .

the insertion works fine , but when i log in to a customer account the cart is empty in the front office .

This is code for inserting cart :

 

                            $cart = new Cart();

                            $cart->id_customer = (int)($idCustomer);

                            $cart->id_address_delivery = (int) (Address::getFirstCustomerAddressId($cart->id_customer));

                            $cart->id_address_invoice = $cart->id_address_delivery;

                            $cart->id_lang = (int)($this->context->cookie->id_lang);

                            $cart->id_currency = (int)($this->context->cookie->id_currency);

                           $cart->id_carrier = 1;

                            $cart->recyclable = 0;

                            $cart->gift = 0;

                            $cart->add(); 

                           $cart->updateQty((int)($quantity), (int)($idProduct), null , false, 'up', 0, null, false);

                            $cart->update();

 

image.png.1a978714c9a32d3bf364a3e74a10e429.png  as you can see in the image the cart is empty but the cart exist in the ps_cart and ps_cart_product tables

how can i activate the inserted cart to show it in front office ?

Best Regards 

Link to comment
Share on other sites

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
×
×
  • Create New...