• How To, Magento

    Magento Multiple Stores Sharing One Cart

    Magento Multiple Stores Sharing One Cart

    Posted on January 2nd, 2010

    Written by CJ

    Tags

    Multiple Stores and One Checkout (One Cart).

    The reason I wrote this instructional tutorial, is that some other online forums, tutorials, and blogs, are not showing how to share the same cart with multiple Magento stores. Multiple stores with one checkout is an extremely important feature. This tutorial is also for people who search for titles like, "How to setup up Multiple Stores in Magento", but their article doesn’t show how to share the cart. For example, one tutorial says to create a new website scope in Magento; which unless you edit some expensive core magento files, is not the correct way for a multiple store shopping cart sharing solution. Another article, by someone who seems to be a convincing webmaster, says you can not share a cart with different domains; he’s crazy. You can share a cart with multiple stores, with any shopping cart web application, i.e. Zen Cart, osCommerce, CRE Loaded, X-Cart, Miva, and any web application. Magento, just facilitates this dream without having to buy any plugins, extensions, addons, or hire a programmer.

    Anyways, I hope my in-depth tutorial here gives you instructions and answers to those comments and helps you get the job done. The following tutorial is based on a tested and live environment with a shared shopping cart solution on two stores, on one IP address, two domains, and with one SSL certificate (optionally two or more certificates).

    The Environment

    Main store alias is magento-main.com, and the second store alias is magento-2nd.com.

    1 - Dedicated Server (you physically own it and can access it remotely or locally)
    1 - LAMP or WAMP (Linux or Windows)
    1 - IP address
    1 - magento-main.com - virtual host www root directory for main store
    1 - magento-2nd.com - virtual host www root directory for 2nd store
    1 - Magento Admin Control Panel which is your main store.
    1 - SSL certificate
    Option 1. Two SSL certificates on one IP Address, by adding another secure port of 444 to 2nd Store.
    Option 2. One SSL certificate, for your main store. Any secure request in your 2nd store will redirect to your secure main store.
    Option 3. No SSL certificates.

    A word of advice, "if possible" stop using hosting solutions which limit your admin powers in C-Panel, Plesk, etc.., and set up your own server, unless of course you are geographically limited. If you have gotten this far with ecommerce, I am pretty sure you can set up your own server.

    Preface

    You will not be installing another Magento installation for your 2nd Store. Your current installation of Magento is your Main Store. And you will be sharing everything needed for one checkout with multiple stores, including sessions with your current installation of Magento. All this with two or multiple domains, and with 1 and optionally with 2 or more secure domains. In this tutorial there is no instructions for multiple IP addresses. Although this is the case, I gather you can use my tutorial to write your own comment or tutorial on multiple IP addresses.

    Let’s get started.


    Help Links to AWStats and WAMP



    Until you are ready, always work on a development environment, when testing.

    Login into your main site magento-main.com Magento Admin.

    Step 1. Catalog Section

    • Set up a Root Catalog
      Magento Admin>Catalog>Add Root Category
      Name it, Root Second Store
    • Set up Subcategory
      Magento Admin>Catalog>Add Subcategory
      Name it, Second Store SubCategory
    • Apply a Product to the new Subcategory, Second Store SubCategory
      Magento Admin>Catalog>Select, Second Store SubCategory
      Select, Category Products Tab
      Click on drop down, and change from Yes to Any (if it’s not already set to any)- hit enter if it doesn’t fetch
      Check the radio button on the product you want to add to this category
      Click on, Save Category
      Do the same for, Root Second Store

    Step 2. Manage Stores Section

    • Add 2nd Store
      Magento Admin>System>Manage Stores
      Create Store
      For Name enter, Second Store
      For Root Category, select Root Second Store
      Save Store
    • Configure Language/Store View
      Magento Admin>System>Manage Stores
      Create Store View
      For Store, select Second Store
      For Name, enter English
      For Code, enter second_store_en
      For Status, enter enabled
      Leave sort order alone (optional)

    Step 3. System Configuration Section

    • Change Base URLS
      System>Configuration>Web
      Change Current Configuration Scope (top left) to Second Store > English
      Select Unsecure. For Unsecure Base URL and Base Link URL, uncheck radio button and change to http://magento-2nd.com/
      Select Secure. For Secure Base URL and Base Link URL, uncheck radio button and change to https://magento-2nd.com/
      • Option 1. Two or More Certificates and One IP address:
        You’ll be able to run two SSL certificates on one Ip Address, by changing the port. So, go to System>Configuration>Web choose Second Store scope and for Secure, instead of entering https://magento-2nd.com/ you would enter https://magento-2nd.com:444/ This way your main site magento-main.com will use the normal 443 secure port and your 2nd store will be redirected to a new secure port of 444. The downside is 444 will be showing in the URL. So to hide (mask) the 444, I suggest you google "hide port number in url" through the use of apache module mod_proxy. You will also need to configure your secure vhost file to listen and respond through port 444 requests only on your 2nd site. If you want to run more secure sites on the same IP, than increment the corresponding ports.
      • Option 2. One SSL Certificate and One IP address:
        There is two ways to accomplish this.

        The first way to accomplish this is, you can simply do a redirect (as I did) from your 2nd Store for all secure request, to redirect to your main store, magento-main.com. In other words, when ever the customer selects a secure link on the 2nd store, it will send them over to your main store. To do this, go to System>Configuration>Web choose Second Store scope and for Secure, https://magento-2nd.com/ you would deselect the radio button for, Use Secure URL’s in the Frontend, and change the drop down from yes to no. Open your magento-2nd.com/.htaccess file with any text editor and insert the following in between the existing <IfModule mod_rewrite.c> and </IfModule> section.

        RewriteCond %{HTTPS} !=on
        RewriteRule ^customer(.*) https://magento-main.com/customer$1 [R,L]
        RewriteRule ^checkout/onepage(.*) https://magento-main.com/checkout/onepage$1 [R,L]

        So any of your clickable secure links on the frontend of magento-2nd.com will redirect to corresponding URL in secure magento-main.com.

        The second way to accomplish this, go to System>Configuration>Web choose Second Store scope and for Secure, make sure https://magento-main.com/ is in the base_link_url and the base_url. Make sure to select the radio button for, Use Secure URL’s in Frontend, to yes.
        So any of your clickable secure links on the frontend of magento-2nd.com will redirect to secure magento-main.com. This is Magento’s preferred way of redirecting.

        Either way will work, just depends on your setup and your needs.

      • Option 3. No SSL Certificates:
        To do this, go to System>Configuration>Web choose Second Store scope, and for https://magento-2nd.com/ you would deselect the radio button for, Use Secure URL’s in Frontend, and change the drop down from yes to no. I am not going to say anything, do what you want.

      Please Note: To save you time please understand how Apache works. Currently, in order to run multiple ssl (secure) sites on the same server securely and correctly, you only have two choices; using multiple IP’s or somehow changing the port as in option 1.

    Step 4. WAMP or LAMP, change index.php and create symbolic links.

    No need to install another Magento installation. Even though I am showing WAMP here, I strongly recommend you build it on a Linux Server. Magento and most all Open Source Web Apps are built and tested for Linux. The reason we chose WAMP, is strictly because the customer has IBM BladeCenters, which at this time does not support Linux Ubuntu Server, if it did we’d only have BladeCenters ;)

    • For WAMP (Windows Apache MySQL PHP, Server)
      http://www.wampserver.com/en/

      Using a wampserver installation with the following directory structures.

      wamp\www\magento-main.com\
      wamp\www\magento-2nd.com\

      We are going to do symbolic links, which Windows does not support, so we have to install additional software tools.
      Download and install HardlinkShellExt http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

      Pay Attention Here:
      Right Click on your wamp\www\magento-main.com\404 directory and select, Pick Link Source
      Right Click on your wamp\www\magento-2nd.com directory and select, Drop As > Junction

      Do this for wamp\www\magento-main.com\app, downloader, js, media, report, skin, and var directories. You will now have 8 aka symbolic links in your wamp\www\magento-2nd.com directory

      Now go to your wamp\www\magento-main.com\ and copy both the .htaccess and the index.php into wamp\www\magento-2nd.com\
      Using any text editor, open wamp\www\magento-2nd.com\index.php, and change:

      $mageFilename = 'app/Mage.php';

      to this

      $mageFilename = '../magento-main.com/app/Mage.php';

      Change this:

      Mage::run();

      to this:

      Mage::run('second_store_en','store');

    • For LAMP (Linux Apache MySQL PHP, Server)

      It’s very simple for a LAMP server with the following directory structures.

      /var/www/magento-main.com/
      /var/www/magento-2nd.com/

      Do symbolic links (for each) with command line:

    prompt>ln -s /var/www/magento-main.com/404 /var/www/magento-2nd.com/404
    prompt>ln -s /var/www/magento-main.com/app /var/www/magento-2nd.com/app
    prompt>ln -s /var/www/magento-main.com/includes /var/www/magento-2nd.com/includes
    prompt>ln -s /var/www/magento-main.com/downloader /var/www/magento-2nd.com/downloader
    prompt>ln -s /var/www/magento-main.com/js /var/www/magento-2nd.com/js
    prompt>ln -s /var/www/magento-main.com/media /var/www/magento-2nd.com/media
    prompt>ln -s /var/www/magento-main.com/report /var/www/magento-2nd.com/report
    prompt>ln -s /var/www/magento-main.com/report /var/www/magento-2nd.com/report
    prompt>ln -s /var/www/magento-main.com/skin /var/www/magento-2nd.com/skin
    prompt>ln -s /var/www/magento-main.com/var /var/www/magento-2nd.com/var

    • You will now have 8 symbolic links in your /var/www/magento-2nd.com/ directory. Now go to your /var/www/magento-main.com/ and copy both the .htaccess and the index.php into var/www/magento-2nd.com/. Using any text editor, open /var/www/magento-2nd.com/index.php, and change:

      $mageFilename = 'app/Mage.php';

      to this

      $mageFilename = '../magento-main.com/app/Mage.php';

      Change this:

      Mage::run();

      to this:

      Mage::run('second_store_en','store');

    Step 5. Take your new Ferrari out for a Test Run:

    Go to http://magento-2nd.com/ - you will see the new site with the following message, "There was no Home CMS page configured or found".

    Go to http://magento-2nd.com/second-store-subcategory - you will see the one product you chose. (please note: second-store-subcategory would be the default url, but it might be different for your install check Admin>Catalog>URL Rewrite Management> for the correct URL.)

    Go to http://magento-2nd.com/second-store-subcategory - add the product to your cart. Go to magento-main.com and add any one product to the cart. You will now see two products in your cart, in either magento-2nd.com/checkout/cart/ or magento-main.com/checkout/cart/

    If these url’s work than, than pat your friend on the back, and skip Step 6. TroubleShoot and Solutions and go to Step 7 Tidy Up.

    Step 6. TroubleShoot, and Solution

    • http://magento-2nd.com, is not resolving.
      Rename index.php to index_.php and create a new blank file and name it index.html. If it still doesn’t resolve, than it has nothing do with this tutorial. 1. Check your Web Server (WAMP or LAMP) log files, for troubleshooting. 2. If it’s local copy of magento-2nd.com, make sure you change your system host file to reflect your server IP Address.
    • http://magento-2nd.com is displaying 404, http://magento-2nd.com/\404.
      1. Check above tutorial, and make sure you didn’t leave out or misspell something. This also probably means everything works on your WAMP or LAMP, but http://magento-2nd.com/magento is somehow not connecting to http://magento-main.com/magento. 2. Make sure you didn’t alter any core magento files in the past, which may be affecting the connection. 3. If your running, linux it could be it’s not allowing relative URLS, so change the above ‘../magento-main.com/app/Mage.php’; to an absolute url ‘/var/www/magento-main.com/app/Mage.php’; 4. Make sure you have the correct PHP/Apache modules, settings, and/or extensions enabled. 5. Also, 404 can mean infinite problems, so report them here to see if I can help.
    • Cart sharing doesn’t work.
      This can mean many solutions. If you chose file based session (which is the default) when you first installed magento, delete all the sessions content of your http://magento-main.com/var/session directory. Refresh your browser on your https://magento-main.com site and your https://magento-2nd.com site. If you see two session files in the session directory, than this probably means your http://magento-2nd.com/index.php or your magento admin panel > system > manage stores configuration is incorrect, so report here to see if I can help.

    Step 7. Tidy Up

    Here are some things you might want to do next:

    Quick solution to change your 2nd store theme.
    Depending on your theme setup this may or may not work for you, or you might have to do some tweaking. But I’ll show you how to quickly change the theme with the following directory structure:

    magento-main.com\skin\frontend\magento-main_theme
    magento-main.com\app\design\frontend\magento-main_theme

    Make duplicate copies of both magento-main_theme into corresponding directory and rename them to magento-2nd_theme. Your directory should now look like this:

    magento-main.com\skin\frontend\magento-main_theme
    magento-main.com\skin\frontend\magento-2nd_theme
    magento-main.com\app\design\frontend\magento-main_theme
    magento-main.com\app\design\frontend\magento-2nd_theme

    Go Magento Admin>System>Configuration>Design
    Change Current Configuration Scope (top left) to Second Store > English
    In Package, for Current package name uncheck both radio buttons and change, to magento-2nd_theme

    Please note, this may or may not work for you, depending on your theme setup.

    Thanks for reading my blog.

    I really hope my instructions helped. Also, there are many more tidy up tasks to do after creating your second store. So, if you know of any, please feel free to comment on these ‘tidy up tasks’ or any other related issues.

    This entry was posted on Saturday, January 2nd, 2010 at 6:47 pm and is filed under How To, Magento. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
  • 55 Comments

    Take a look at some of the responses we've had to this article.

    1 2

    1. " Magento Multiple Stores Sharing One Cart "

      John Smith
      Posted on January 27th

      This really isn’t clear on the whole “two stores 1 cart” situation. Its just like any other multiple-store setup.. I’ve done this and my store isn’t sharing the cart..

    2. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on February 9th

      John,
      I think you need to check your sessions. If you have file based:
      Go ahead and delete all the sessions content of your /var/www/magento-main.com/var/session directory. Refresh your browser on your http://magento-main.com site and your http://magento-2nd.com site. You should only see one session (one file) being created. If you see two sessions (2 files), then follow the tutorial above and make sure you didn’t leave anything out.
      CJ

    3. " Magento Multiple Stores Sharing One Cart "

      Posted on February 12th

      I was create multiple store.
      but common user account and shopping cart can not we working.

      pls replay me how to work in easy php

    4. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on February 12th

      Nakul,

      I hope I can better understand your question. As per ‘common user account’, are you referring to store guest or users signed in? Either, user account can share the cart. They don’t have to be signed in, to share cart. As far as, easy php, can you elaborate?

      CJ

    5. [...] actually works! I feel like I have to apologize to Magento. After following these instructions, Magento Share One Cart, it gave me the solution. And now both sites are sharing the [...]

    6. " Magento Multiple Stores Sharing One Cart "

      Tirmont
      Posted on February 15th

      Dear all,

      I would greatly appreciate your advice. I think I face an SEO issue with the configuration of my multi web sites. Here you are what I have :

      http://www.site.fr
      http://www.site.com
      http://www.site.de
      http://www.site.ru
      http://www.site.cn

      When I look the code source they all get their “stylesheet” from an other domain : http://www.site.info

      For example the http://www.site.com code source is :

      When I look the magento mall example it is more like i should have somthing like that :

      I do think that this is an SEO issue specilay for google. Would it be possible that google does not like the fact the some files of the code come from an other domain?

      I wonder that because I am very well rank (1st or 2nd place) for more than 150 keywords on Yahoo, Baidou and Yandex, but I stay at 2nd or 3rd page one google.

      What do you think of that?

      Thank you for your answer

    7. " Magento Multiple Stores Sharing One Cart "

      Tirmont
      Posted on February 15th

      For example the http://www.site.com code source is :

      link rel=”stylesheet” type=”text/css” href=”http://www.site.info//skin/frontend/sitecom/site/css/boxes.css” media=”all” />
      link rel=”stylesheet” type=”text/css” href=”http://www.site.info//skin/frontend/sitecom/site/css/menu.css” media=”all” />
      link rel=”stylesheet” type=”text/css” href=”http://www.site.info//skin/frontend/sitecom/site/css/clears.css” media=”all” />

      When I look the magento mall example it is more like i should have somthing like that :

      link rel=”stylesheet” type=”text/css” href=”http://www.site.com/skin/frontend/sitecom/site/css/reset.css” media=”all” />
      link rel=”stylesheet” type=”text/css” href=”http://www.site.com/skin/frontend/sitecom/site/css/boxes.css” media=”all” />
      link rel=”stylesheet” type=”text/css” href=”http://www.site.com/skin/frontend/sitecom/site/css/menu.css” media=”all” />
      link rel=”stylesheet” type=”text/css” href=”http://www.site.com/skin/frontend/sitecom/site/css/clears.css” media=”all” />

    8. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on February 15th

      Tirmont,

      I definitely agree, having stylesheets from another domain, even if it’s your domain can’t be good, for SEO and other reasons; especially with Multiple Stores. I am pretty sure you have already checked your Admin > System > Configuration > Web > URLS, but I would double check them, and make sure you have the correct urls, respective to the Current Configuration Scope, on top left. Also, you might uncheck the, ‘Use website’ check boxes on all the Base URLs for the Multiple Stores, and “manually” insert them.

      For example, the URL set for your China Configuration Scope: would read, Base URL http://www.site.cn/, Base Link URL http://www.site.cn/, Base Skin URL http://www.site.cn/skin/, Base Media URL http://www.site.cn/media/, and Base JavaScript URL http://www.site.cn/js/ .

      Do this for all URL sets in all your Configuration Scopes, accept your Default and Main Store, which would read Base URL http://www.site.com/, Base Link URL http://www.site.com/, Base Skin URL {{unsecure_base_url}}skin/, Base Media URL {{unsecure_base_url}}media/, and Base JavaScript URL {{unsecure_base_url}}js/

      You would also do the above for all the secure URLS as well.

      How about your directory structure for you skin. In my experience, the following directory works without issues and is a workaround for a design flaw (possibly a bug) in Magento, of which I’ll address next.

      skin/frontend/sitecn/default/
      skin/frontend/sitecom/default/
      skin/frontend/sitefr/default/

      app/design/frontend/sitecn/default
      app/design/frontend/sitecom/default
      app/design/frontend/sitefr/default

      This directory structure helps solve the 404 issue you get when you place two different items in the cart from two different stores. In this scenario, if the customer were to click on the item from their shopping cart it will 404. With the above directory structure, they will not see a 404, but will see the view page of the current store. You can see others are also having the same issue: http://www.magentocommerce.com/boards/viewthread/73227/

      If you try the above directory structure, not only will your one shared cart in multiple stores work better, but I think the directory structure may have something to do with your stylesheet URLS. Anyways, if you would try the above mentioned, hopefully it will resolve your css issue.

    9. " Magento Multiple Stores Sharing One Cart "

      Tirmont
      Posted on February 16th

      Dear CJ,

      Many thanksfor your post, I will try all that right away

    10. " Magento Multiple Stores Sharing One Cart "

      Tirmont
      Posted on February 16th

      Dear CJ,

      I just tried your advice for site.cn in the code source the stylesheets come from the right website ! However, I have lost all my disign.. It there an other thing I should do…?

      Once again thank you for your great advice I really appreciate

    11. " Magento Multiple Stores Sharing One Cart "

      Monty
      Posted on February 16th

      I want to thank you for this instructions n great job on the detail.

      It worked flawlessly but now, i’m having problems with the two sessions showing instead of one, now. I have followed your tutoiral on development stores, to the tee. I disabled the cache in Magento and removed all the sessions, manually. When I first start it, it worked fine (one session/one cart for multiple stores). But after I enable the cache it never wants to share the cart, and two sessions keep showing up. Can you please help me.

    12. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on February 16th

      @Monty

      Thanks so much for the compliment. As you pointed out, it has something to do with the cache and session, or vise versa.

      One cache most people forget is the APC, or XCache (other wise known as Opcode Caches). This may or may not help, but at any rate, if you are running any of these PHP helper accelerators, then you also need to clear “all of them”. If all your multiple stores are running on different IP addresses (or different server), you have to delete each of the multiple store’s Opcode Caches, as well.

      Even though Magento has little affect on the browser you use, another cache, people forget about is your browser cache. For example, Firefox, Chrome, IE, etc… will store the sessions (cookies) and it’s configurations, in it’s local cache. So delete your sessions and cache in your browser. To Disable the Firefox cache altogether. Type about:config in the Firefox address. Look for browser.cache.memory.capacity and browser.cache.disk.capacity and set them to 0.

      Also, check your computer system clock settings in windows or or whatever OS your using to share the cart with Magento multiple stores. The clock settings are common causes for cookie (session) issues. If you go to one store and checkout on another, Magento or most all cookie dependent web apps won’t know how to handle the session being passed, due to the time not being consistent. So, instead of using the current session for one cart in multiple stores, it will create a new session.

      Multiple stores and sharing one cart with one session is also dependent on the permissions and ownership on the Magento directories (folders). For development reasons, I would chmod 777 both var/session and var/cache. I would also CHOWN these folders with the appropriate user; it’s different for every server. You can check your phpinfo(), some users may include nobody, apache, www-data, etc.. dependent on your Linux distribution or Windows server. As an extra measure, I would delete app/etc/use_cache.ser; Magento will automatically replace it.

      First, before clearing opcode caches, take your development Magento main and multiple store sites offline, so no one but you can access it. If your Magento sessions are on the database, then delete with the following sql command, TRUNCATE TABLE `core_session; it will delete all the cache from the core_session table on the Magento store database. If the sessions are on a file, then delete them as well. Delete all the var/cache too.

      If you have APC, XCache, or a variant than you need to clear all Opcode Caches caches for all the multiple stores that are sharing the one cart. If your ‘APC’ didn’t come with the tool to clear the cache, you can download it, here http://webdevster.com/downloads/one-cart/multiple_store_clear_cache.zip You will need to extract and edit the apc_clear_cache.php file and change the username and password to be able to clear the cache. Make a copy of each of the apc_clear_cache.php and place each apc_clear_cache.php file in each of the main and multiple stores directory. Clear all cache, User Cache Entries, Pre-Directory Entries, and System Cache Entries (as an extra measure). To run, point your browser to magentomultiplestore.com/apc_clear_cache.php or wherever you placed the files.

      Optionally you can disable the apc, by removing it from your local.xml or remove it all together from php, by commenting it in php.ini.

      You say, when you first installed Magento with the multiple stores, the cart was sharing. But, after you enabled cache it stopped sharing. If my above recommendations don’t help, I would also try to remember what else happened before or during the event when the cart stop sharing.

      Well by doing the above steps, you should be back to square one, with a clear cache and session. After you get Magento to share cart, I would advice to turn the cache back on, because it will speed up Magento significantly.

      Also don’t forget to chmod the directories back to a secure setting. The settings (chmod) depends on who owns the folder.

      Hope this works for you.

    13. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on February 17th

      @ Tirmont

      Try clearing out your Magento Cache, maybe the old settings for stylesheet are still being applied. If you haven’t already, it’s a good idea to work with no cache, while you are testing your multiple stores with one shared shopping cart. It’s also a good idea to disable cache during major configurations of your multiple stores.

      Also, if you have set an expiration date on your stylesheets, and/or if you are using GZIP compression for your stylesheets and JS; the style sheet settings can probably still be sitting in your (minified) JS cache which compresses the css. You might also, want to delete those css cache as well.

      One more step, which probably won’t have any affect, but is worth trying, is disable cache from your browser. For example, like I mentioned to Monty, Firefox, Chrome, IE, etc… will store the sessions, stylesheets, configurations, etc.. in it’s local cache. Since you don’t have a problem with sessions, I would manually disable firefox’s cache altogether, when testing.

      Use the reply to Monty, to clear out all your cache in your Magento main store and multiple stores.

    14. " Magento Multiple Stores Sharing One Cart "

      Posted on March 12th

      Thank you for the post. I’ve done this, but it ‘broke’ my checkout when I changed the secure base url. The customer login doesn’t work either. But that doesn’t make sense to me. I’m using Shared SSL and that might be the problem. But I want to make sure the three stores will work together in 1 cart before I buy an SSL cert Any ideas? Thank you SO much!!

    15. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on March 12th

      Penny,
      When you type in the URL for Secure and Unsecured, I would try typing in the full absolute URL, and not the {{…}}. The shared SSL should have nothing to do with breaking your cart. Make sure you configured the SSLCertificateFile, SSLCertificateKeyFile,
      SSLCertificateChainFile directive in the htaccess.

      FYI- I would definitely get three SSL certificates. Comodo is free for 90 days so its great for development environment. The only downside from using Comodo free trial, is the sales reps are very persistent in upselling you. Comodo does have better deals than all the others (Verisign, GeoTrust, etc…), in regards to the green bar and the ease in acquiring.

      -CJ

    16. " Magento Multiple Stores Sharing One Cart "

      Jeremy
      Posted on March 18th

      You wrote “In this tutorial there is no instructions for multiple IP addresses. Although this is the case, I gather you can use my tutorial to write your own comment or tutorial on multiple IP addresses. ”

      This concept confuses me. I gather that you can have multiple domains on different ip addresses on various servers and share the 1 magento cart. However, do you still need to install magento on every separate IP for the actual storefront software functionality or can I use 1 instance of magento on it’s own IP and run a store on a differnt IP?

    17. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on March 18th

      Jeremy,

      The latter is correct; you install one instance of Magento, which will house all of your stores. The Magento which houses your stores, I refer to Mangento Main, which can also house many stores under one IP (one server). Alternately, you can have multiple stores (multiple servers). And each store can have it’s own IP with it’s own SSL, etc.. The only thing you need to install into your multiple stores (multiple servers) www root, with regards to Magento and your question, is two itty bitty files, [.htaccess and index.php]. These are placed into the root of where you want your store to be. This index.php is then configured to talk to the Main installation of your Magento. This way you can configure all your stores from one control panel.

      Hope this helps. Let me know if you have other questions.

      -CJ

    18. " Magento Multiple Stores Sharing One Cart "

      Jeremy
      Posted on March 18th

      CJ- thanks for the clarification. I am planning on hosting the stores on different ip’s for SEO purposes. When I set up the main website on Magento I give it a name. Can I simply use the IP when configuring the new ip’s to talk to magento or will google actually see the domain name I assigned? Also, if I did this with 150 sites and then interlinked them it creates triangular links but on different IP’s. If it was found is this a blacklist item or do I just loose the link juice?

    19. " Magento Multiple Stores Sharing One Cart "

      FireBall
      Posted on March 18th

      Using 1.4.0.1 on dedicated IP

      MY GOAL: To have either websites or stores to share one cart.

      I want to set up Magento to have either multiple websites or multiple stores under one 1 instance of Magento and to share 1 cart. I can’t find anything on what the main pro/cons of setting up websites vs stores.

      I figured out how to setup website and have different domains pointing to those websites by editing the .htaccess file and that works fine. Ideally I would like to do what Jeremy is saying by having my domains on different IP’s but I can’t add any more confusion at this time.

      I didn’t realize that Magento wouldn’t allow the websites with there own domains to share carts. I have read that websites can’t share carts but stores can and vs versa.

      Now I’m point of going postal over all the conflicting information.

      Can someone tell me what to do here or send me a link to a company that actually really knows what 1.4 can do.

      I even went to Megento’s site and looked at there new Multi store demo site and it will not even allow you to add items to your cart from different sites… (what in the HECK). http://www.magento-mall.com/

      Thanks in advance for any feedback…

    20. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on March 18th

      @Jeremy
      I outlined your questions in bold and the answers solutions below them.

      I am planning on hosting the stores on different ip’s for SEO purposes.

      Excellent strategy. Some pros include, mulitple search engine results (the big gun) on the same result page, more top level keywords, higher overall visibility , independant sites, increase level of success, decrease level of odds, etc… maybe you can share your info on more SEO pros?

      When I set up the main website on Magento I give it a name.

      Yep, sort of like an umbrella. An umbrella corp which houses many other dynamic corps (subsidiaries). But, with Magento, they refer to it as a mall name. And like in your case, you could have multiple mall names with multiple store names (or ip’s)

      Can I simply use the IP when configuring the new ip’s to talk to magento or will google actually see the domain name I assigned?

      So instead of using http://www.sitename.tld you will be using http://www.345.67.567.55.tld. This is will not make a difference for Magento. But, Google has “the all seeing eye”. They don’t just cache your pages. I am pretty sure, they also do DNS lookups, reverse DNS lookups, whois, etc.. when ranking your site(s). I can’t be sure, because I don’t work for Google, but if I sat on the round table at Google Corp, I would use these tools for ranking purposes.

      Also, if I did this with 150 sites and then interlinked them it creates triangular links but on different IP’s. If it was found is this a blacklist item or do I just loose the link juice?

      As long as you have outbound links to other sites not under your umbrella, it would not be considered a “web ring”. As far being blacklisted, I would lessen the chance of anything like this ever happening by; hosting with different providers throughout the world, spreading out your domains to many registrars throughout the world; moving existing domains to other registrars throughout the world; the whois contact and info will also need to be different on every domain (they have to be legitimate email contacts for whois, I would then forward all the emails to one email to keep yourself organized); there are many more ways, maybe you also have some ideas or suggestions?

      The other thing is SSL is very important, if you plan to process your own transactions through a third party provider like authorize.net and directly with a merchant provider like Bank of America. You can avoid SSL, Gateway transaction processor, and merchant account, by simply using, using Google checkout, amazon checkout, and PayPal checkout. Magento, easily facilitates this and more.

      I hope I answered your questions. Remember, I am just one guy talking, so I would definitely try to gather more people’s opinion or facts.

      -CJ

    21. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on March 18th

      @Fireball
      I feel your frustration. Magento is a fairly new shopping cart. Therefore, it doesn’t have explicit and detailed information on custom sharing cart solutions and instructions. But, let me reassure you that Magento Shopping cart does let you share the cart with multiple stores.

      In regards to your statement, “I didn’t realize that Magento wouldn’t allow the websites with there own domains to share carts. I have read that websites can’t share carts, but stores can and vs versa.” That is correct, but they don’t mean it in a literal sense; as a “website” which maybe confusing. In Magento backend they refer to website as a container, which holds other stores. Each store, ‘literally’ can be a website.

      So, yes you can ‘literally’ share a cart with multiple websites. Each store would then have it’s own ssl and it’s own ip, and literally be another website.

      Hope that clarifies it for you.

      @ Jeremy and FireBall
      Also, not to confuse people even more, you can run all your multiple stores (multiple websites) with different IP and different SSL, under ONE physical server with the use of XEN server. The XEN server host (domO) will contain multiple guest (domU) virtual servers. These virtual servers are independent of each other, and will share the same hardware resources that the xen server host provides. I would use Ubuntu Hardy as the Xen Server (domO), which will contain Multiple Ubuntu Hardy Virtual Servers (domU). This is the same cloud computing technology, Amazon uses.

      XEN is production ready. I have deployed many of these xen servers with 99.9% uptime. Xen, once forged into the server, just works! Remember, xen.org is not xenserver. xen.org is the open source app and xenserver is owned by Citrix, which is based on the XEN code.

      Although you can run a XEN server, keep in mind Magento is resource hungry. So, as you grow and become more successful, XEN will easily let you spread out your server tasks to many other physical XEN Servers or virtual servers. i.e. Dedicated MySQL Master server and Dedicated Mysql Slave server, Dedicated Image Server, Memcache Server, etc.. By migrating virtual servers to other virtual servers or physical servers, you increase Magento’s ability to service your customers.

      Also, using Xen is way to test your Magento multiple stores, before production.

      I will be doing a STEP BY STEP article soon, on how to install XEN Server and Virtual Servers from scratch.

      Hope this helps.

      -CJ

    22. " Magento Multiple Stores Sharing One Cart "

      Posted on March 25th

      CJ - I bought the SSL and it was installed. Once I did that and changed the secure base url, it seems to be working like a charm. :) Thank you *so* very much!!

    23. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on March 26th

      Penny,

      Your website stores are very impressive. Very catchy domain names, too. Any suggestions or questions please let me know.

      -CJ

    24. " Magento Multiple Stores Sharing One Cart "

      Posted on March 27th

      Superduper great guide! I have one small problem though. I have created the symbolic links on my 2nd domain, but it doesn’t seem to work the way it’s supposed. Here is an image of how it looks. http://img708.imageshack.us/img708/3430/screenshot20100327at204.png

      Do you have any suggestion on how to solve this?

    25. " Magento Multiple Stores Sharing One Cart "

      mike
      Posted on March 30th

      Running 1.4
      CJ - I found out that I can’t have more then 100 SSL on one IP address, so I have to move roughly 75 more domains to a new IP .

      I figured out how to set up the 100 domains outside the public_html folder and how to code the 2 files to make them point to the magento cart. I then created symbolic links to a few folders like this:
      ln -s ../public_html/404/ ./404
      ln -s ../public_html/app/ ./app
      and so on.

      Now my question.
      1. If I am doing SSH from a different IP address I’m thinking the symbolic links above would not work. What should i use assumming my domain where my magento is installed is http://www.mike.com?
      2. in the index.php - now i have
      $mageFilename = ‘../public_html/app/Mage.php’;
      Does this stay the same on another IP?
      3. Do I need to do anything with the .htaccess file other then copying it to the folder?

      Thanks in advance, your post are great!

    26. " Magento Multiple Stores Sharing One Cart "

      Jeff
      Posted on July 30th

      I’m planning to eventually run 6 or 7 “stores” with different domain names off a single Magento installation.
      How are most people handling the merchant account/gateway issue in this case, a separate merchant and gateway account for each domain/IP?

    27. " Magento Multiple Stores Sharing One Cart "

      Posted on August 4th

      Hi,
      In the blog it is mentioned we can share the magneto checkout with the other shopping carts like zen-cart,X-cart please elaborate how that is possible

    28. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on August 4th

      Hello Sushil,

      To put it simply, all these(zen cart, x-cart, magento, oscommerce) web apps are built on PHP and SQL. Magento simply facilitates “one page checkout” out of the box. So you can hire a programmer, to write you the scripts which enables a “new one page checkout” functionality on any ecommerce platform. For example, OScommerce you can buy a plugin (no need to hire anyone). For Virtuemart, which is Joomla’s flagship ecommerce solution you can also buy a plugin. I’m not sure about the others, but I would check out Zen Cart forum and X-Cart forum.

      If the cart you have doesn’t offer a plugin. You can simply hire a freelancer at, PHP Freaks, Nerdlance, PHP Freelancers, and Freelancers.com. From my experience, China and India programmers work for less money and went far and beyond what was expected; and the nicest personality ever. Remember, the internet was invented by the US, so it’s interpreter language is English. Notice every Chinese, or other language websites have html tags, in their source. So, if they can program in PHP,SQL, then the language barrier should be little fuss.

      I hope I was helpful. Let me know if you need anything else.

      -CJ

    29. " Magento Multiple Stores Sharing One Cart "

      CJ
      Posted on August 4th

      @JEFF

      There are three pieces to the puzzle:

      1. Shopping Cart.
      The shopping cart’s ability to communicate with the Payment Gateway through an API. Most all shopping cart’s provide this by default, but every shopping cart differs in the Payment Gateway provider they support.

      2. Payment Gateway.
      Authorize.net is by far the most popular solution, and is already supported in Magento and most all shopping carts.

      3. Merchant Service Account.
      In order to process the transaction and make the deposits into any checking or savings account of your choice, you need a Merchant Service Provider. The most reputable in my experience are BAMS (Bank of America Merchant Services), FirstData, Elavon, and SAMs. But there are so many, so just look for the best deal and most reputable. Keep away from resellers, call the number on the merchant service provider website direct, to make sure you don’t get a reseller. Best thing to do is call your bank and find out who there merchant processor provider is, because you’ll probably get the funds deposited faster and chances are there is no middle man. I searched merchant service provider on the internet, and I couldn’t believe all the shady type websites I came across, i.e. charge.com, gotmerchant.com, and so many more that look like scams. Stay away from them like the plague. Or maybe they need to revamp there website, regardless if they are a trusting provider, they should make a good first impression especially on the net. No excuses.

      Having said that (to explain to the rest of the readers), you would need to talk to your merchant service provider and payment gateway provider when you want to open up different stores. I could suggest the following, from experience.

      If you want one merchant and one gateway account for all stores, than simply change your industry, for example if one of your stores sell knives and the other sells garden supplies, then change your industry to Home and Garden. An addition, you would need to change you business name or do a DBA, to an umbrella type company, for example instead of calling it Jack’s Knives, call it Jack’s Stores, or Jack’s Enterprise. This way when the customer get’s their MC, Visa, etc statement it will say Jacks Ent. or Jack stores, and no red flags go out. For your website name, you can give them the umbrella store, i.e. magentomall.com, jackstore.com, etc.. I’ve done this with two customers, after providing all the paperwork to their payment gateway and merchant provider, they were ok with this setup. As far setting up the corporations, sole proprietorship, fictitious name, etc.. well that’s up to you.

      If your stores are all different industries and different business name then you would probably need to open different merchant and gateway accounts for each. I don’t know your business plan or structure, so the best bet is to contact your providers.

      I hope I was helpful.

      -CJ

    30. " Magento Multiple Stores Sharing One Cart "

      Posted on August 11th

      Hi Cj

      Thanks for Your help, I am elaborating what I actually want , I have client which have stores in other shopping carts like oscommerece,zen-cart and x-cart, Upto this time I was giving them a facility that they can checkout through ny site by using the button on client side and when the customer submit the button and checkout they can checkout through the My orevious made java based checkout,But now i want to shift my javabased checkout to a new checkout which will be magento,

    31. " Magento Multiple Stores Sharing One Cart "

      Posted on August 12th

      Hi Cj,

      This is a great article!

      I’m using the new 1.4 version and multiple sites has gotten quite a bit simpler using environmental variables and setting them with .htaccess rules; however, I was struggling with passing sessions between “websites” and it seems that only possible between “stores”.

      I’ve got everything working down to the second step of the checkout.

      I start on website-b.com, populate my cart, start the checkout on website-a.com and the moment I click continue, it shows me the billing step but then immediately redirects me to a screen telling me my cart’s empty.

      Did I miss a step? Any thoughts on what might be causing this?

    32. " Magento Multiple Stores Sharing One Cart "

      Saurabh
      Posted on August 26th

      Nice post, this works for me. Can you also post how compare products and recently viewed products can work between multi sites.

      Thanks,
      Saurabh

    33. " Magento Multiple Stores Sharing One Cart "

      travis
      Posted on September 10th

      Hi Cj,

      Thanks for your detailed article. I have one question about the cart sharing.

      Does the session in your example based on the cookie? If so, how could that work for different domains? As I know, browsers will only accept and submit the cookie from the domain of the current website, which means the cookie from a.com will not be used by b.com or vice versa.

      That is what happend on my side. But it could work properly after login. I guess after login, the cart will not only be stored in session, but also in database with the specified customer bind.

      And if the multiple domains are all subdomains for one domain, it could work even if you are not login. . Go to System->Configuraion->General->Web->Session Cookie Management, set the Cookie Domain as your main domain, and you’ll be done.

      Travis

    34. " Magento Multiple Stores Sharing One Cart "

      Posted on September 13th

      Hi,
      I plan on setting up two stores (different domains) with one cart, and one mechantacocunt (pay pal)
      However, I want one store to have US currency and one with Canadian Curency - do I need to do anytihng special besides input what currecies? anything I need to know ahead of time?

      Thanks!

    35. " Magento Multiple Stores Sharing One Cart "

      Posted on September 13th

      Also, my SSL cert is on one IP, which I thought a SSL cert can only have one IP and it can oot be shared) but my other domain is on a different IP, can I still follow these instructions (using option 2 one SSL one IP)?

      Thanks again!

    36. " Magento Multiple Stores Sharing One Cart "

      Posted on October 12th

      Hi CJ!

      Finally I found the solution thanks to your tutorial and this code:

      a href=”http://www.magento-main.com/checkout/cart/?SID= php
      echo Mage::getModel(”core/session”)->getEncryptedSessionId(); php”>Go to sister website

      Check my solution at: Magento Sharing baskets between multiple stores

    37. " Magento Multiple Stores Sharing One Cart "

      Posted on October 14th

      Great read! I wish you could follow up to this topic?

    38. " Magento Multiple Stores Sharing One Cart "

      Posted on October 25th

      Honestly can’t thank you enough for posting this, I was just about to pull my hair out!

    39. " Magento Multiple Stores Sharing One Cart "

      KATHY
      Posted on October 29th

      We use Magento 1.4 and have 6 sites sharing 1 cart. However, the carts do NOT share with block html caching enabled. This causes a lot of performance problems. Do you have a solution for this?

      Thanks!

    40. " Magento Multiple Stores Sharing One Cart "

      Posted on November 26th

      Merely found your internet page through google and i contemplate this might be a shame that you’re not ranked upper due to the fact that that’s a fantastic publish. To swap this i determined to stay away from losing your web website to my Rss reader and I will attempt to point out you in 1 of my posts given that you truly deserv additional readers when publishing content content of this quality.

    41. " Magento Multiple Stores Sharing One Cart "

      Posted on November 30th

      Any chance this has anything to do with the onepage checkout redirecting to the cart page?

      I have multiple domains running off of 1 magento installation. The base domain has no issues with the cart, but if I attempt to go through the onepage checkout on the other domains, when going to step 2, it 303 redirects me back to the cart page.

      I have a feeling it’s an issue with the unsecure vs secure URLs for the 2ndary domains. In previous versions of Magento (1.3.x) the solution was to update the onepage.js file to include a call to a div on that page.

      Thoughts?

      (PS - in Chrome your comment blocks are not expanding to the appropriate height of the comment. things are being truncated)

    42. " Magento Multiple Stores Sharing One Cart "

      Posted on December 11th

      So if I right now have have /home/username/www/htdocs as root for http. Should I then have my Magento installed in there and then create two empty folders for Main and Second store?

    43. " Magento Multiple Stores Sharing One Cart "

      Posted on December 16th

      Great post!
      I have success main website 4 stores one cart!

      Problem, if I have a product on the main website, and in store A, although it is not store B, it shows up in the site map and also in the serps.

      any ideas where i could have gone wrong!

    44. " Magento Multiple Stores Sharing One Cart "

      Magefan
      Posted on January 19th

      Hi CJ!

      Firstly would like to thank you on sharing such a nice post.

      I am having trouble sharing carts b/w two of my stores. My problem is, both the stores create separate session files in /var/session/ directory. I followed all the steps properly and tried to troubleshoot as per step 6 but still not able to share the carts. I have setup a dummy Magento installation in my local development environment , thus I cannot share you the URL but what I have is :
      1) a magento site with two stores on a common local IP
      2) no SSL

      Thoughts?

      Thanks in advance.

    45. " Magento Multiple Stores Sharing One Cart "

      Posted on February 12th
    46. " Magento Multiple Stores Sharing One Cart "

      Tiffany Estes
      Posted on February 28th

      I have a client who wants to have two stores with one checkout, like diapers.com/soap.com or gap.com, where you can add items from several stores to a single cart and execute a single checkout. Will all editions of Magento accomplish this, or only the paid editions?

    47. " Magento Multiple Stores Sharing One Cart "

      Posted on March 16th

      This is my problem CJ, one site will not send the cart contents to the other UNLESS I change in the config Add Store Code to Urls to Yes. However, this break my url structure something nasty, for an already established website.

      It seems that PHP wont share session cookies across IP’s only from within domains. So I might have to create my second site as a virtual domain of the first, in a folder under the first site.

      I’ve read everything you’ve said about ownership, session info in the database, and have implemented it all, but nothin.

      Any ideas?

    48. " Magento Multiple Stores Sharing One Cart "

      rajandanish
      Posted on March 18th

      Any chance this has anything to do with the onepage checkout redirecting to the cart page?

      I have multiple domains running off of 1 magento installation. The base domain has no issues with the cart, but if I attempt to go through the onepage checkout on the other domains, when going to step 2, it 303 redirects me back to the cart page.

      please help me to fix this.

    49. " Magento Multiple Stores Sharing One Cart "

      Robert
      Posted on March 26th

      404 Error on second store

      Magento 1.5.0.1 - http://www.capitogolf.com primary Magento install - works fine

      http://www.derossico.com - secondary store - 404

      Hosting is hostgator VPS, derossico.com is an addon domain under capitogolf.com - Cpanel

    50. " Magento Multiple Stores Sharing One Cart "

      Posted on May 4th
    51. " Magento Multiple Stores Sharing One Cart "

      Anonymous
      Posted on May 11th

      No idea which version of Magento this page is talking about, so I keep searching without reading details.

    52. " Magento Multiple Stores Sharing One Cart "

      Posted on May 17th

      Frankly speaking, I badly wanted this one. Many many thanks for posting this one article and helped me out.

    53. " Magento Multiple Stores Sharing One Cart "

      JJ
      Posted on May 20th

      Hey there:
      I tried a couple items in this post, and specifically, I have two stores on one website, with one IP and one SSL. I am trying to get a third theme to display that combines the logos for both stores when customers to to either secure area. I cannot for the life of me figure out how to pass the information to magento to use a specific store view. Anyone have any suggestions?

    54. " Magento Multiple Stores Sharing One Cart "

      Posted on May 31st

      I’m getting a 404 error and a broken logo image on the 2nd store.

      Primary store: http://www.security-camera-warehouse.com
      2nd Store: http://www.surveillance-depot.com

    55. " Magento Multiple Stores Sharing One Cart "

      robness
      Posted on July 24th

      Ok, now what about the stors SHARING cart data, so that you can checkout from any of the stores? This solution seems to dictate that the final checkout will always be on one domain.

      So I’d like my customers to be able to shop on storeone.com and storetwo.com, and when they checkout, the site design and domain should be the most recent domain they were shopping on.

      This prevents the confusion that would be caused if someone was on storetwo.com, and had never heard of storeone.com, checking out and being confused when they are suddenly on storeone.com…

  • Post a Comment

    Let us know what you thought.

    1 2

  • Name:

    Email:

    Website:

    Message: