How To Share Magento Cart Between Several Magento Multiple-Stores?

Magento-multi-stores

Tutorial on Sharing Magento Cart Between Several Magento Stores

Today, the word “Multiple” becomes more and more popular in ecommerce community. Multiple shopping carts offer a wide range of options to meet multiple business needs and wants. Platforms supporting several languages and currencies, payment and shipping options, open multiple opportunities for online traders. Magento was one of the first platforms that offered multiple storefronts management

Magento multi-store functionality provides web store owners with an opportunity to admin several stores within a single Magento installation. A lot of online retailers, who have multi-stores configured in Magento, want to have a single cart for all of them. It makes the act of purchase and sale considerably easier for both ecommerce business owner and customers. 

If for website owners it is a need, for some Magento developers it is a challenge. However, everything is easier than may seem. Our Sam Ecommerce Magento developers have already been experienced with sharing Magneto cart between Multi-stores, and now we want to show you how to do it correctly. 

We will advise you how to share cart content between multi-stores and provide customers with a single account for all of them.

Customer Accounts Sharing

Firstly, you need to share customer's account between multi-stores. To do this, you should configure this feature here: System -> Configuration -> Customer Configuration -> Share Customer Accounts.

Sharing Sessions Between Magento Websites

Now, you have to share customers session between Magento websites.

There are 3 possible store configurations:

  • The first one is for those, who keep their websites in one domain, but in different directories: "www.example.com/stores/store1" and "www.example.com/stores/store2" you can setup your "Cookie Path" to "/stores/" in System -> Configuration -> Web -> Session Cookie Management.
  • The second one is for those, who keep websites in different sub-domains: "store1.example.com" and "store2.example.com" you can setup "Cookie Domain" to ".example.com" in System -> Configuration -> Web -> Session Cookie Management.
  • And the third one is for those, who have different domains: You should 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.

These changes will enable your customers to switch between multi-stores Magento websites without re-login. So, when your customer will login in one website, he will have the opportunity to see another multi-store Magento website using his first store account. However, these Magento websites will not have a single card.

Sharing The Cart Content Between Magento Multi-Stores

It is well-known that Magento uses separate cart sessions for every store, because different multi-store websites present different set of products and different product settings for every store. 

In order to get over this limitation, you should create a separate store that will contain products from all your websites ( System -> Manage stores). 

To be able to use one website on the checkout session, you have to modify the "Mage_Checkout_Model_Session" class.

Then, copy this file: app/code/core/Mage/Checkout/Model/Session.php 

to: app/code/local/Mage/Checkout/Model/Session.php.

After, 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;
   }
 
...

Now, you have to change CHECKOUT_STORE_ID value "1" to your Magento store ID with all products. After,  find all these elements in the file:

Mage::app()->getStore()

and change them to:

Mage::app()->getStore($this->getCheckoutStoreId())

Clear Magento cache and check your store. All done!

Please, remember about the limitations of this solution:

  • All prices in the cart will be taken from the store that you will select. Consequently, in case if you place different prices for different stores, it won't work in the cart.
  • The currency will be from the store you will select.
  • And at last but not least,  the link for editing items in the cart will redirect customer to original cart website. However, you can change it by overriding getUrl method for cart items block or by overriding controller.

We hope that this guidance will help you! Please, when you try it, let us know about the results. If you still have some questions, ask our Sam Ecommerce Magento experts, and they will be happy to answer them! Read more about Magento here:

Comments (2):
Posted on Wednesday, September 14, 2016 by :
Howdy just wanted to give you a brief heads up and let you know a few of the picutres aren't loading properly. I'm not sure why but I think its a linking issue. I've tried it in two different web browsers and both show the same outcome.
Posted on Wednesday, April 19, 2017 by :
Hi. I am not overly knowledgeable on how some of this more advanced stuff in Magento works. I've been trying to make this type of customer/cart sharing between domains work on my end, but I just can't seem to get anything to work. I can't even fully tell if I've set it up correctly in Magenot to begin with, as everything I've been finding online (including this post, which, I've actually found in 3 different places online) seems to use terms differently. So, I've got some questions about this solution, which I've asked on other forums as well, but can't seem to get anyone to actually answer me. If you are willing to answer some of my questions, I would greatly appreciate it.
Leave a comment:
*Your comment will be published after approval by site administrator.