{"id":2488,"date":"2012-10-12T11:57:05","date_gmt":"2012-10-12T10:57:05","guid":{"rendered":"http:\/\/www.simonbattersby.com\/blog\/?page_id=2488"},"modified":"2018-02-06T15:27:19","modified_gmt":"2018-02-06T15:27:19","slug":"opencart-set-up-multiple-stores","status":"publish","type":"page","link":"https:\/\/www.simonbattersby.com\/blog\/opencart-set-up-multiple-stores\/","title":{"rendered":"Opencart &#8211; Setting up multiple stores"},"content":{"rendered":"<p>Here&#8217;s how to set up multiple stores on Opencart using subdomains. You could use this to set up a separate store to run a different theme &#8211; although this is not essential &#8211; you can run several stores with the same theme if you want.<\/p>\r\n\r\n<div class=\"expander\">\r\n<p>The steps will vary depending upon your version of Opencart.<\/p>\r\n<h3>Opencart 1.5.x<\/h3>\r\n<div class=\"detail\">\r\n\r\n<h4>Create your subdomain<\/h4>\r\n<p>Let&#8217;s assume you&#8217;re running your main store on <code>www.yourshop.com<\/code>, and that your web hosting locates the files for your store in its root directory <code>public_html<\/code>. For a mobile store, let&#8217;s also assume you&#8217;re going to sit this on <code>m.yourshop.com<\/code>.<\/p> \r\n\r\n<p>You need to create your new domain and point it at <strong>the same<\/strong> folder that your main store uses. If your hosting uses cPanel then it should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc_multiple_stores.png\" width=\"742\" height=\"300\" alt=\"Screenshot of additional domain in cPanel\" title=\"Additional domain in cPanel\" \/>\r\n\r\n<h4>Create your new store<\/h4>\r\n<p>The next step is to create the new store in Opencart. Go to System > Settings and click the &#8216;Insert&#8217; button. This should bring up screens to create your new store. For the Store URL and SSL URL, enter your new domain, adding https to the SSL URL if you have a certificate installed. <strong>Make sure you close your entries with a &#8216;\/&#8217; or it won&#8217;t work<\/strong>. Fill out the rest of the details on the General tab, and your screen should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc_multiple_stores_2.png\" width=\"546\" height=\"729\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>Now the Store tab. Here you need to enter the store name, and select the theme you want to use (e.g. a mobile theme). Set the default layout to &#8216;Default&#8217;. Your screen should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc_multiple_stores_3.png\" width=\"546\" height=\"599\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>You can then save your new store.\r\n\r\n<h4>Configure your new store<\/h4>\r\n<p>Opencart will create your new store with all the default settings, so you will need to amend all the store settings as required.<\/p>\r\n<p>Opencart will not load any categories, products, manufacturers or information pages to your new store (unfortunately?). You&#8217;ll need to do all these manually, or by running some SQL queries from the backend. To do this manually:<\/p>\r\n<ul class=\"bulletlist\">\r\n<li><strong>Categories<\/strong> &#8211; From the Category edit screen, go to Data > Stores to mark the checkbox against your new store.<\/li>\r\n<li><strong>Products<\/strong> &#8211; From the Product edit screen, go to Links > Stores to mark the checkbox against your new store.<\/li>\r\n<li><strong>Manufacturers<\/strong> &#8211; From the Manufacturer edit screen, mark the checkbox against your new store.<\/li>\r\n<li><strong>Information<\/strong> &#8211; From the Information edit screen, go to Data > Stores to mark the checkbox against your new store.<\/li>\r\n<\/ul>\r\n\r\n<h4>Modules in your new store &#8211; using Layouts<\/h4>\r\n<p>If you&#8217;re using Opencart 1.5.x, then any Modules that you have configured will not be carried over to your new store. Opencart manages the display of extensions by using the concept of Layouts &#8211; which is a little tricky to grasp, I think.<\/p>\r\n<p>A Layout is the entity which links Modules to pages and stores. When a page is to be displayed on a store, Opencart looks up the layout appropriate to that page on that store, and then finds any modules configured for that layout.<\/p>\r\n<p>So, if you make no changes to any Layouts after creating your new store, then when a page on your new store is displayed, Opencart will search for the appropriate Layout, and not find one. It will therefore use the Default layout which we assigned when the store was set up. This (probably) has no Modules assigned to it, and so no Modules will be displayed. So, to display a Module on your new store, we need to configure a Layout.<\/p>\r\n<p>I&#8217;ll illustrate this with an example. Let&#8217;s assume you have some Modules on your default store homepage, and you want to display <strong>the same<\/strong> Modules on your new store. First thing is to navigate to System > Design > Layouts and click &#8216;Edit&#8217; against the &#8216;Home&#8217; Layout. You should then see something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc_multiple_stores_4.png\" width=\"742\" height=\"227\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>You&#8217;ll see that the existing (default) entry tells Opencart that for the default store the Layout &#8216;Home&#8217; should be used with the route, or page &#8216;common\/home&#8217; &#8211; which is the home page. We need to tell Opencart to use the same Layout for the new store. So, click &#8216;Add Route&#8217;, select the new store and enter &#8216;common\/home&#8217; against the route &#8211; like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc_multiple_stores_5.png\" width=\"742\" height=\"139\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>Click &#8216;Save&#8217; and you&#8217;re done.<\/p>\r\n<p>You can probably see from this that it&#8217;s possible to display different modules on your new store homepage by creating a new Layout and assigning it to your new store only. Here&#8217;s <a href=\"\/blog\/opencart-use-different-modules-on-multiple-stores\/\" title=\"Using different modules on different stores\">some more details on how to do this<\/a>.<\/p>\r\n\r\n<h4>You&#8217;re done<\/h4>\r\n<p>Once this is complete, your new store should display via the subdomain, with the products etc and modules that you have enabled in the steps above. Payment, Shipping and Order Totals will all be the same as your existing store.<\/p>\r\n<\/div>\r\n\r\n<h3>Opencart 2.x and 3.x<\/h3>\r\n<div class=\"detail\">\r\n\r\n<h4>Create your subdomain<\/h4>\r\n<p>For my example, I&#8217;m assuming a store running on <code>www.yourstore.com<\/code>, with its root directory <code>public_html<\/code>. For a substore, let&#8217;s also assume you&#8217;re going to sit this on <code>trade.yourshop.com<\/code>.<\/p> \r\n\r\n<p>You need to create your new domain and point it at <strong>the same<\/strong> folder that your main store uses. If your hosting uses cPanel then it should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc2_multiple_stores_3.png\" width=\"684\" height=\"433\" alt=\"Screenshot of additional domain in cPanel\" title=\"Additional domain in cPanel\" \/>\r\n\r\n<h4>Create your new store<\/h4>\r\n<p>The next step is to create the new store in Opencart. Go to System > Settings &#8211; which shows Stores &#8211; and click the blue &#8216;+&#8217; button. This should bring up screens to create your new store. For the Store URL and SSL URL, enter your new domain, adding https to the SSL URL if you have a certificate installed. <strong>Make sure you close your entries with a &#8216;\/&#8217; or it won&#8217;t work<\/strong>. Fill out the rest of the details on the General tab, and your screen should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc2_multiple_stores_1.png\" width=\"634\" height=\"763\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>Now the Store tab. Here you need to enter the store name, and select the theme you want to use (YooBlue in my example). Set the default layout to &#8216;Default&#8217;. Your screen should look something like this:<\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc2_multiple_stores_2.png\" width=\"634\" height=\"704\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>You can then save your new store.\r\n\r\n<h4>Configure your new store<\/h4>\r\n<p>Opencart will create your new store with all the default settings, so you will need to amend all the store settings as required.<\/p>\r\n<p>Opencart will not load any categories, products, manufacturers or information pages to your new store (unfortunately?). You&#8217;ll need to do all these manually, or by running some SQL queries from the backend. To do this manually:<\/p>\r\n<ul class=\"bulletlist\">\r\n<li><strong>Categories<\/strong> &#8211; From the Category edit screen, go to Data > Stores to mark the checkbox against your new store.<\/li>\r\n<li><strong>Products<\/strong> &#8211; From the Product edit screen, go to Links > Stores to mark the checkbox against your new store.<\/li>\r\n<li><strong>Manufacturers<\/strong> &#8211; From the Manufacturer edit screen, mark the checkbox against your new store.<\/li>\r\n<li><strong>Information<\/strong> &#8211; From the Information edit screen, go to Data > Stores to mark the checkbox against your new store.<\/li>\r\n<\/ul>\r\n\r\n<h4>Modules in your new store &#8211; using Layouts<\/h4>\r\n<p>If you&#8217;re using Opencart 2.x or later, when you create a your new store, all the Modules that you have configured will automatically be carried over to your new store (note this is different to 1.5.x).<\/p>\r\n<p>Opencart manages the display of extensions by using the concept of Layouts. A Layout is the entity which links Modules to pages and stores. When a page is to be displayed on a store, Opencart looks up the Layout appropriate to that page on that store, and then finds any Modules configured for that Layout. You can find Layouts under Design > Layouts. If you edit the Home Layout you should see something like this: <\/p>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/blog\/oc2_multiple_stores_4.png\" width=\"965\" height=\"596\" alt=\"Screenshot of Opencart store configuration screen\" title=\"Opencart store config screen\" \/>\r\n<p>You&#8217;ll see that the first entry tells Opencart that the &#8216;Home&#8217; Layout applies to the default store when the route, or page &#8216;common\/home&#8217; is displayed &#8211; the home page. When we created our second store Opencart duplicates this for use, so the &#8216;Home&#8217; layout also applies to our new store when the route &#8216;common\/home&#8217; is used. Result &#8211; the Modules assigned to the Layout &#8216;Home&#8217; are displayed on both the default and trade store.<\/p>\r\n<p>You can probably see from this that it&#8217;s possible to display different modules on your new store homepage by creating a new Layout and assigning it to your new store only. Here&#8217;s <a href=\"\/blog\/opencart-use-different-modules-on-multiple-stores\/\" title=\"Using different modules on different stores\">some more details on how to do this<\/a>.<\/p>\r\n\r\n<h4>You&#8217;re done<\/h4>\r\n<p>Once this is complete, your new store should display via the subdomain, with the products etc and modules that you have enabled in the steps above. Payment, Shipping and Order Totals will all be the same as your existing store.<\/p>\r\n<\/div>\r\n\r\n<script type=\"text\/javascript\">\r\n$(document).ready(function(){\r\n   $('.detail').hide();\r\n   $('h3').removeClass('active').append(' <\\span>[<\\span>show details<\\\/span>]<\\\/span>');\r\n   $('h3 span span').click(function(event){\r\n          if(!event.detail || event.detail==1){\r\n          $(this).parents('h3').next().slideToggle();\r\n          $(this).parents('h3').toggleClass('active');\r\n          $(this).text($(this).text() == 'show details' ? 'hide details' : 'show details');\r\n          return false;\r\n          }\r\n   });\r\n})\r\n<\/script>\r\n<\/div>\r\n\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s how to set up multiple stores on Opencart using subdomains. You could use this to set up a separate store to run a different theme &#8211; although this is not essential &#8211; you can run several stores with the same theme if you want. The steps will vary depending upon your version of Opencart. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2488","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/2488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/comments?post=2488"}],"version-history":[{"count":33,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/2488\/revisions"}],"predecessor-version":[{"id":3132,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/2488\/revisions\/3132"}],"wp:attachment":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/media?parent=2488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}