I'm not sure if this works, it's just an idea: The quote has the functionality to specify the stores which are sharing the quote. By default this are all stores of a website. Anyway if it is possible to set a list of spefic stores before loading the quote, I think it is possible to restrict the quote to a subset of all stores of a website, in your case just to the actual store.
One idea could be to set the store restriction in a plugin before the get
method in Magento\Quote\Model\QuoteRepository
, which should always be called when a quote is loaded.
Again, it's just an idea which might not work and the code is not tested and just to demonstrate my thoughts.
class MyPlugin{
protected $storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
){
$this->storeManager = $storeManager;
}
public function beforeGet(
\Magento\Quote\Model\QuoteRepository $quoteRepository,
$cartId,
array $sharedStoreIds
){
return [$cartId, [$this->storeManager->getStore()->getId()]];
}
}
Looking forward to hearing what you think about this approach.