2017-09-07 58 views
10

我有一個PrestaShop的大問題,我正在使用我自己創建的API來爲移動應用程序提供服務。添加產品到Prestashop 1.6中的特定商店購物車(編程)

現在,我可以添加,刪除,更新數量到第一個購物車。 我也可以導航到像我的網上商店類別和子類別。

但是我有兩家商店,我想在第二家商店中添加一個特定的多主題模式產品,並且該腳本始終添加到第一個購物車。

這是我的線添加到購物車。

第一店鋪ID = 1個
第二店= 4

$_shop = new Shop(_PS_SHOP_SELECTED_ID); //_PS_SHOP_SELECTED_ID = 4 
$isAdded = $cart->updateQty((int)$product->quantity, (int)$producToAdd->id, $id_product_attribute, FALSE, 'up', 0,$_shop); 
+0

你如何創建或獲得$購物車? – sadlyblue

+0

$ context = Context :: getContext();如果(!$ context-> cart-> id){ \t \t $ context-> cart-> add(TRUE,FALSE,TRUE,_PS_SHOP_SELECTED_ID); \t \t $ context-> cookie-> id_cart = $ context-> cart-> id; $ cart = new Cart($ context-> cart-> id); $ cart-> id_customer =(int)UserApi :: getIdAuthUser(); $ cart-> id_lang = _PS_APP_MOBILE_LANG_ID; $ cart-> id_currency =(int)Context :: getContext() - > currency-> id; $ cart-> id_carrier = 1; $ cart-> recyclable = 0; $ cart-> gift = 0; \t} \t $ cart = new Cart($ context-> cart-> id); –

+0

你能編輯你的文章並添加更多代碼嗎? – idnovate

回答

3

我終於找到改變鋪在上下文中的最好的和適當的方式。 我從代碼中進行了很多搜索,發現第一個店鋪分配在config.inc.php中,但鋼材從Shop類獲得價值。

因此改變店上下文覆蓋:

Shop::initialize();中的Prestashop店

類設置你的願望店!

相關問題