简体   繁体   English

如何在prestashop中获取第二家商店的购物车内容

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

I have a multistore enable in my Prestashop, I would like to access the cart of the second shop in the first shop.我的 Prestashop 中启用了多商店功能,我想访问第一家商店中第二家商店的购物车。 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但是如何访问不在当前上下文中的第二家商店的购物车

I think this is not possible with Prestashop classes / methods as Context object is related to the current shop.我认为这对于 Prestashop 类/方法是不可能的,因为Context对象与当前商店相关。

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.否则,我认为您可以直接在ps_cart_product表(可能与ps_cart 连接以检索id_customer )上执行数据库查询,因为它包含id_shop行。

This is not the best approach .. There may be completely different products in the other shop, so the cart cannot be valid either.这不是最好的方法.. 其他商店可能有完全不同的产品,因此购物车也无效。

But if you know the cart_id and the shop_id, you can perform a DB query但是如果你知道cart_id和shop_id,你可以执行一个数据库查询

$query = new DbQuery();
    $query->select('*');
    $query->from('cart');
    $query->where("id_cart= {$cartID}");
    $query->where("id_shop= {$shopID}");
    $result = Db::getInstance()->executeS($query);
   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM