quoteRepository = $quoteRepository; $this->checkoutSession = $checkoutSession; } /** * Update store id in active quote after store view switching. * * @param StoreSwitcherInterface $subject * @param string $result * @param StoreInterface $fromStore store where we came from * @param StoreInterface $targetStore store where to go to * @param string $redirectUrl original url requested for redirect after switching * @return string url to be redirected after switching * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterSwitch( StoreSwitcherInterface $subject, $result, StoreInterface $fromStore, StoreInterface $targetStore, string $redirectUrl ): string { $quote = $this->checkoutSession->getQuote(); if ($quote->getIsActive()) { $quote->setStoreId( $targetStore->getId() ); $quote->getItemsCollection(false); $this->quoteRepository->save($quote); } return $result; } }