share magento cart between multi-stores

If you have multi-stores configured in your Magento and you want to have single cart for all multi-stores this article is what you need.

All your multi-stores will be not separate websites, they all will have single cart (share cart content between multi-stores).
Also your customers will have single account for all multi-stores.

1. Share customer accounts.

First step is to share customers account between multi-stores.
You can configure this feature here: System -> Configuration -> Customer Configuration -> Share Customer Accounts.

2. Share sessions between Magento websites.

Next step is to share customers session between Magento websites.

There are 3 possible store configurations:

1. If your websites are located in one domain, but in different directories, e.g. "" and "" you can setup your "Cookie Path" to "/stores/" in System -> Configuration -> Web -> Session Cookie Management.

2. If your websites are located in different sub-domains e.g. "" and "" you can setup "Cookie Domain" to "" in System -> Configuration -> Web -> Session Cookie Management.

3. If you have different domains, in this case you can add session ID to the URL for another store. Use this construction "Mage::getModel('core/url')->addSessionParam()->getUrl('...')" to get the URL with session parameter.

After that your customers will be able to switch between multi-stores Magento websites without re-login. In other words, if customer will login in one Magento website, he will be able to see another multi-store Magento website using his first store account.
But the cart will be different for each Magento website.

3. Share the cart content between Magento multi-store websites.

Magento uses separate cart sessions for each store, the reason is that different multi-store websites have different set of products and different product settings for each store (like price, quantity, etc).

To overcome this limitation, you need to have a website/store which will have all available products from all other websites. If you do not have such Magento website, just create it in the System -> Manage stores. The idea is use single store and website in the checkout session, that is why we need Magento store with all products in it.

To use one website on the checkout session you need to modify the "Mage_Checkout_Model_Session" class.

Copy this file: app/code/core/Mage/Checkout/Model/Session.php
to: app/code/local/Mage/Checkout/Model/Session.php.

After that add the following source code to the class:

class Mage_Checkout_Model_Session extends Mage_Core_Model_Session_Abstract
   const CHECKOUT_STORE_ID = 1;

   public function getCheckoutStoreId()
       return self::CHECKOUT_STORE_ID;


Change CHECKOUT_STORE_ID value "1" to your Magento store ID with all products.

Next, find all such elements in the file:


and change them to:


Clear Magento cache and check your store. Now your Magento will use one cart for different multi-stores websites.

Note that there are several limitations of this solution:

1. All prices in the cart will be from the store you selected (using CHECKOUT_STORE_ID). So if you have different prices for different stores it will not work in the cart.

2. The currency in the cart will be the same as in the store you selected.

3. The link for editing items in the cart will redirect customer to original cart website. It is possible to change it, you can override getUrl method for cart items block or override controller.