在结帐之前将客户重定向到另一家商店的正确方法是什么?如果客户试图结帐且商店不正确,则需要在打开结帐页面之前更改客户商店。
我能够通过事件实现这一目标:
<event name="controller_action_predispatch_checkout_index_index">
...
</event>
重定向代码为:
....
$store = $this->storeManager->getStore($customer->getStore());
$path = $store->getBaseUrl().'checkout';
$this->responseFactory->create()->setRedirect($path)->sendResponse();
exit();
问题: 客户已成功移至另一家商店并访问了结帐,但问题是,只有在页面刷新购物车价格更改为该新商店的价格之后,才重新加载购物车总额的结账摘要,并且价格仍然是先前商店的价格。 / p>
如果不需要刷新页面如何立即获得正确的结帐摘要总计?
答案 0 :(得分:0)
进一步调查后回答我的问题:
我刚刚更改了购物车中的报价存储ID:
...
$store = $this->storeManager->getStore($customer->getStore());
$quote = $this->quoteRepository->getActive($this->cart->getQuote()->getId());
$quote->setStoreId($store->getId());
$quote->setDataChanges(true);
$this->quoteRepository->save($quote);
$quote = $this->quoteRepository->getActive($this->cart->getQuote()->getId());
$this->cart->setQuote($quote)->save();
...