Thursday, June 30, 2022

[FIXED] how to get cart content of second shop in prestashop

Issue

I have a multistore enable in my Prestashop, I would like to access the cart of the second shop in the first shop. How can I achieve this?

I can get the content of the cart in the current shop using the code below:

$this->context->cart

but how to access the cart of the second shop which is not in the current context


Solution

I think this is not possible with Prestashop classes / methods as Context object is related to the current shop.

Isn't using the built-in shared carts between the same shop group a chance ? I know it's buggy, but it should work as long the two shops are in the same domain.

Otherwise I think you can perform a DB query directly on the ps_cart_product table (maybe joined with ps_cart to retrieve the id_customer) since it contains the id_shop row.



Answered By - user3256843
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.