Need some help?

I'm usually available for small jobs or problem solving with jQuery or css, at reasonable rates. Just get in touch.

Web Hosting

We recommend Clook for web hosting. UK based, great service and great value.

Buy me a drink

If you've found this useful, particularly for commercial projects, you might consider making a small donation.

Opencart – Use different modules on multiple stores

If you have multiple stores on one Opencart installation, it’s quite likely you might want to display different versions of the same module on your different stores. I first came across this issue when developing a mobile theme, designed to be used alongside a ‘standard’ theme suitable for desktops. While most modules transfer fairly easily across from one theme to another, one that doesn’t is Banner, and Slideshow is much the same. On my standard site I want a nice wide banner to take up the whole width of the home page, but if this is transferred directly to the mobile theme, designed to have an entirely fluid width to fit a screen down to 320px wide, it won’t fit. This could perhaps be overcome with css, but the Slideshow module creates an inline style setting the width, which on the face of it appears insuperable…

The good news is that this is easily addressed using Opencart’s Layout functionality. 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. Let’s use the Slideshow example to show how we can use two different slideshows on the homepages for our default and mobile stores. The first thing to do is to create a new layout for the mobile store home page. First we create the new Layout, via System > Design > Layouts, and click the ‘Insert’ button. I’ll call the new layout Home_Mobile. Now I need to tell Opencart which pages (or routes) on which store this Layout should be used for. Click ‘Add Route’, select the mobile store from the dropdown and then, to use this on the homepage, add the route ‘common/home’. Like this:

Screenshot of Opencart Layout config page

Click ‘Save’. Now we’ve done this, assuming no other changes have been made, Opencart will use the Layout Home for the home page on the default store – this is set up already, but for the mobile store it will use the Layout Home_Mobile.

Once we’ve done this the next bit’s easy…. Let’s assume we’ve got a suitably sized Banner already created. Bring up the Slideshow module config screen (Extensions > Modules > Slideshow – Edit), then click ‘Add Module’, and fill in the details for your new Slideshow, selecting ‘Home_Mobile’ as the Layout to which this module is applied. Something like:

Screenshot of Opencart Layout config page

Click ‘Save’ and it’s done – you have two separately sized Slideshows visible on the two different homepages.

Tags:

24 responses to “Opencart – Use different modules on multiple stores”

  1. Simon says:

    Impossible to tell without seeing your setup in detail, but my first thought would be to try the default theme and see if the problem persists.

  2. ioannis says:

    Dear Simon

    I m trying to set a multistore but I have a problem with modules. I use Jurnal theme and I want both of my sites to have the same modules. I created new layout with (common/home) but only some modules (slider -popup- and banners) appears in my second store…..
    Castom sections module and carousel I can’t appear in my second layout……..
    Any advise is welcome…

    Best regards
    John

  3. Simon says:

    Don’t do a complete install, have a look here to do what you’re describing.

  4. ajay joshi says:

    Thank for your valuable post
    but my issue is diffrent
    I want to create my mobile site using seprate subdomain( fresh opencart installtion on subdomain) using all new files not using multi store but want to combined all databases for main domain and subdomain how it possible

  5. Deepak says:

    Awsome!!! I have been looking for this from so much time.. Thanks a lot!!!!

  6. Simon says:

    As I’ve replied to you before, there is no search in the mobile template. Feel free to add one yourself. Similarly, I have not styled sub categories differently than categories. Again feel free to make whatever amendments you need.

  7. Admin says:

    I’m already using your template in my site. Everything is fine except two major lackness. First one is no search box and the second one is when i display the subcategory, the main and sub categories looks like same. People get confused that which one main and which one sub. There is no any subcategory page as like the mobile site of flipkart.com . Please solve these problems.

  8. Simon says:

    This page tells you how to do this, as far as I can understand your question. Are you trying to do something different that what’s described here?

  9. Robin says:

    I have a default website & a multistore’s vendor website for vendor…

    i want to display different modules on my default website…and different modules on vendors website…

    please help me how to do this…

    i have already configured a theme on default website…

  10. Simon says:

    You’d just create a different layout to use on the store, and create a different banner to assign to the slideshow using that layout.

  11. martin says:

    Excellent article now I understand the layout section. What happens if i want to add different images to each separate slideshow for each domain. this just enables you to change the size and position.

  12. Thanks a lot for this explanation it worked perfectly!

  13. Dhanasekaran says:

    It’s working perfectly for my multi-store site.Thanks..

  14. Simon says:

    If your different stores are using different themes, just paste the GA code in the header.tpl file for each theme, and remove it from the Store > Settings. If you’re using the same theme, either create a new theme to accommodate the code, or if you fancy being a bit more technical, write some conditional code into your template file which echoes different GA code depending on the store. You can retrieve the store id using:

    $this->config->get('config_store_id')
  15. RJ says:

    I would like to know how am i going to put all the GA tracking code if im using multistore? only the default setting has the google analytic textbox.

  16. Simon says:

    You should be able to do this by defining two additional Layouts for your second and third stores, and setting up the Slideshow Module for each store using the different Layouts.

  17. Devpriy says:

    Hello Sir

    here follow you point but not display different slidshow for three store

  18. Simon says:

    Dave, I know you got this fixed. For others, the approach here is to use a different layout as described above.

  19. Dave says:

    Hi

    How can i add different routes do i dont get the same banners and mods on both sites

    can u use something different than common/home

  20. Lokesh says:

    thanks to provide this type of nice tutorial. it’s working for me

  21. Simon says:

    A single installation of Opencart will allow you to create multiple stores, with different styling and with different products if required. This article describes the setup. Is that what you mean?

  22. Adrian says:

    Hello,
    Thank you for your answer, but I would like to know how to have a one cart for multistore(one cart for all stores).
    All the best!

  23. Simon says:

    Not familiar with the Visitors module. You’re probably best taking this up with the extension developer.
    Having said that, using Google Analytics or similar would probably be easier and give you better stats.

  24. Adrian says:

    Hy, I have a problem with my visitors module.
    How to generate independent counter on every store from my multistore?
    And what have to do for multistore same cart?
    All the best!

Useful? Interesting? Leave me a comment

I've yet to find a way of allowing code snippets to be pasted into Wordpress comments - so if you're trying to do this you'd be better off using the contact form.