Opencart – Setting up multiple stores
Here’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 – for example a mobile-optimised theme.
Create your subdomain
Let’s assume you’re running your main store on
www.yourstore.com, and that your web hosting locates the files for your store in its root directory
public_html. For a mobile store, let’s also assume you’re going to sit this on
You need to create your new domain and point it at the same folder that your main store uses. If your hosting uses cPanel then it should look something like this:
Create your new store
The next step is to create the new store in Opencart. Go to System > Settings and click the ‘Insert’ 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. Make sure you close your entries with a ‘/’ or it won’t work. Fill out the rest of the details on the General tab, and your screen should look something like this:
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 ‘Default’. Your screen should look something like this:
You can then save your new store.
Configure your new store
Opencart will create your new store with all the default settings, so you will need to amend all the store settings as required.
Opencart will not load any categories, products, manufacturers or information pages to your new store (unfortunately?). You’ll need to do all these manually, or by running some SQL queries from the backend. To do this manually:
- Categories – From the Category edit screen, go to Data > Stores to mark the checkbox against your new store.
- Products – From the Product edit screen, go to Links > Stores to mark the checkbox against your new store.
- Manufacturers – From the Manufacturer edit screen, mark the checkbox against your new store.
- Information – From the Information edit screen, go to Data > Stores to mark the checkbox against your new store.
Modules in your new store – using Layouts
If you’re using Opencart 1.5 or later, then any Modules that you have configured will not be carried over to your new store. This is a good thing, I think, since it effectively gives you control over which modules are used by your different stores. Opencart manages the display of extensions by using the concept of Layouts – which is a little tricky to grasp, I think.
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.
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, so no Modules will be displayed. So, to display a Module on your new store, we need to configure a Layout.
I’ll illustrate this with an example. Let’s assume you have some Modules on your default store homepage, and you want to display the same Modules on your new store. First thing is to navigate to System > Design > Layouts and click ‘Edit’ against the ‘Home’ Layout. You should then see something like this:
You’ll see that the existing (default) entry tells Opencart that for the default store the Layout ‘Home’ should be used with the route, or page ‘common/home’ – which is the home page. We need to tell Opencart to use the same Layout for the new store. So, click ‘Add Route’, select the new store and enter ‘common/home’ against the route – like this:
Click ‘Save’ and you’re done.
You can probably see from this that it’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’s some more details on how to do this.
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.