Skip to content

Zen4All-nl/Multisite-Module-for-Zen-Cart

Repository files navigation

Multi Site Module v1.0.1 Beta for ZC 1.5.1 Documentation

Introduction

This contribution Multi Site support to Zen Cart.

Credit is due to Gerome Romey for creating Multi Site 0.4 and the Zen Cart Team for creating the best open source ecommerce package available!

What's New

Version 1.0.1 - Release Date: 2013-02-09

  • Updated site links sodebox to use the on/off switch properly
  • Added a header site link side box. This box can be placed any where you like and displays a horizontal bar with the site links.

Installation

This version of Multi Site has been updated and tested for use with Zen Cart 1.5.1

Please remember to backup your website files and database before you continue.

To install Multi Site follow the steps below.

  1. Download the latest version of Multi Site from:
    http://www.zen-cart.com/downloads.php?do=file&id=378

  2. Extract the contents (of master.zip) to a temporary location, keeping the file structure intact. (Note: If you can't open this file try using 7-Zip, it's free!)

  3. Open the 4_SQL_Files folder and then open the install.sql file in a text editor (not Microsoft word) and copy all of the text to the clipboard. Next go to (Admin > Tools > Install SQL Patches) in your Zen Cart admin and paste the contents of install.sql into the text area and then press the send button. Or copy the code from below
    ALTER TABLE orders ADD order_site varchar(30) NOT NULL DEFAULT 'no';
    This adds the column 'order_site' to the 'Orders' Table to know which site orders originate from.
  4. Alternative to step 3. Open phpMyAdmin for your site and navigate to your database. Choose 'Import' and then 'choose file' and navigate to and select install.sql then choose 'Go'.

  5. Open the 1_New_Files folder

  6. Rename the following folders to match your admin folder name.
    • YOUR_ADMIN

  7. Upload the entire contents of the 1_New_Files folder, includes folder and the admin folder to your server, again keeping the file structure intact.
    • YOUR_ADMIN/multisite.php
    • YOUR_ADMIN/includes/autoloaders/config.multisite.php
    • YOUR_ADMIN/includes/extra_datafiles/multisite.php
    • YOUR_ADMIN/includes/init_includes/init_multisite_config.php
    • YOUR_ADMIN/includes/languages/dutch/multisite.php
    • YOUR_ADMIN/includes/languages/dutch/extra_definitions/multisite.php
    • YOUR_ADMIN/includes/languages/dutch/extra_definitions/order_site.php
    • YOUR_ADMIN/includes/languages/english/multisite.php
    • YOUR_ADMIN/includes/languages/english/extra_definitions/multisite.php
    • YOUR_ADMIN/includes/languages/english/extra_definitions/order_site.php
    • YOUR_ADMIN/includes/clipboard.swf
    • YOUR_ADMIN/includes/shBrushPhp.js
    • YOUR_ADMIN/includes/shBrushXml.js
    • YOUR_ADMIN/includes/shCore.js
    • YOUR_ADMIN/includes/SyntaxHighlighter.css
    • includes/config_sites/2fastshoes.com_config.php (This is only an example config file)
    • includes/config_sites/help.txt (It is not required to copy this file)
    • includes/config_sites/sites_switch.php
    • includes/config_sites/www.example.com_config.php (This is only an example config file)
    • includes/functions/extra_functions/cat_filter.php
    • includes/languages/dutch/extra_definitions/site_links.php
    • includes/languages/english/extra_definitions/site_links.php
    • includes/modules/sideboxes/site_links.php
    • includes/templates/template_default/sideboxes/tpl_site_links.php

  8. Open the 2_Required_Core_Edits folder.

  9. Rename the following folder to match your admin folder name.
    • YOUR_ADMIN

  10. Before we proceed there are a couple of things to note. The files in the '2_Required_Core_Edits' folder are of two types. The first type of file CANNOT be over-ridden by the use of templates, the second type is of course the opposite and CAN be overridden by the use of Zen-Cart templates. You can read more about Zen-Cart templates on the Zen-Cart website. The files in the folders listed in the next step are the files which CAN be overridden by the use of templates. In the previous version it was advised to just override the default template files, but I advise against it. It may mean less work now, but in a future upgrade of your Zen Cart it complicates updates.
    It is also possible your custom template already contains files in the mentioned folders, which would mean the old method is useless.

  11. The next folders contain files that have to replace the existing Zen Cart files by the use of the templates. Rename the following folders to match your template folder name. You need to do this for every template installed !! The files in these folders may need merging with existing files in your template.
    • includes/modules/YOUR_TEMPLATE
    • includes/modules/sideboxes/YOUR_TEMPLATE
    • includes/templates/YOUR_TEMPLATE
    In the next folder there also already may be files present
    • includes/init_includes/overrides

  12. Upload and MERGE where needed the entire contents of the 2_Required_Core_Edits folder, includes folder and the admin folder to your server, again keeping the file structure intact.
    • YOUR_ADMIN/orders.php
    • includes/classes/category_tree.php
    • includes/classes/order.php
    • includes/classes/site_map.php
    • includes/functions/functions_categories.php
    • includes/functions/functions_lookups.php
    • includes/init_includes/overrides/init_add_crumbs.php
    • includes/init_includes/overrides/init_category_path.php
    • includes/init_includes/overrides/init_sessions.php
    • includes/init_includes/overrides/init_templates.php
    • includes/pages/advanced_search_result/header_php.php
    • includes/pages/featured_products/header_php.php
    • includes/pages/index/main_template_vars.php
    • includes/pages/products_all/header_php.php
    • includes/pages/products_new/header_php.php
    • includes/pages/reviews/header_php.php
    • includes/pages/specials/main_template_vars.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/best_sellers.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/categories.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/document_categories.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/featured.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/manufacturers.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/reviews.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/specials.php
    • includes/modules/sideboxes/YOUR_TEMPLATE/whats_new.php
    • includes/modules/YOUR_TEMPLATE/categories_tabs.php
    • includes/modules/YOUR_TEMPLATE/category_row.php
    • includes/modules/YOUR_TEMPLATE/featured_products.php
    • includes/modules/YOUR_TEMPLATE/meta_tags.php
    • includes/modules/YOUR_TEMPLATE/new_products.php
    • includes/modules/YOUR_TEMPLATE/product_listing.php
    • includes/modules/YOUR_TEMPLATE/specials_index.php
    • includes/templates/YOUR_TEMPLATE/sideboxes/tpl_categories.php
    • includes/templates/YOUR_TEMPLATE/templates/tpl_advanced_search_default.php

  13. Make a Template for each site
    • We assume that you already have a Zen-cart shop installed with some categories and products. You need to have a 2nd template that will be use for your 2nd shop. You can simply copy and past the one from your folder "includes/template/[YOUR_TEMPLATE]" Or you can download some from www.zen-cart.com.

    • TIP: In order to make the things easy, I highly advice you to rename the template to the name of each of your site. In this way, you will find easily the folder of the shop you want to modify... When you rename your template's name, think of renaming every overriding folder too ! These folders should be:
      • includes/templates/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/extra_definitions/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/html_includes/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/modules/order_total/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/modules/payment[YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/modules/shipping/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/modules/YOUR_TEMPLATE
      • includes/languages/YOUR_LANGUAGE/modules/sideboxes/YOUR_TEMPLATE

    • Do not use a template for two sites, otherwise, you will be obliged to have the same language files too (same shops' name and same sideboxes position)

    • In the includes/templates/[YOUR_TEMPLATE]/template_info.php, change the template_name to the name of your site that uses the template:
      $template_name = 'mysite';
    • So, if your sites are called www.site1.com and www.site2.net Then your should rename your template to site1 and site2.
      The file includes/templates/site1/template_info.php should have the line:
      $template_name = 'site1';

      The file includes/templates/site2/template_info.php should have the line:
      $template_name = 'site1';

      This will help you later in the admin section; the template selector is now only use for choose the site for which you want to change the sidebox setting.

  14. Create the configuration files of your sites

    Add this line at the beginning of your "includes/configure.php":

    include_once('includes/config_sites/sites_switch.php');

Multi Site is now installed and ready to use!

Go to the configuration chapter to read more on how to configure your sites.

Upgrade ( Do a fresh installation)

Upgrading from previous versions is not supported Please do a fresh installation

Configuration

  1. How to change the configuration for a specific shop?

    The Zen-cart configuration is contained in the database and declared in constants at runtime. The configuration in the admin section stands for the "default configuration". You can override this configuration by defining the constants of the setting that you want to change directly in the config file related to one of your site (folder "includes/config_sites")

    You now have to create a config file for each one of your sites! The name of the file has to be: "www.site1.com_config.php" (for the site targeted by the domain name www.site1.com). This file "www.site1.com_config.php" has to contain:

    <?php
    $template_dir = "site1";
    define('SITE_NAME','site1');
    ?>

    $template_dir is the template that you want to use for this site SITE_NAME is the name of your site (use for the category filter and for the order page in admin; column site).

    You can add constants for overriding of the default configuration from the database or from the configure.php, the following lines are only examples:

    //Do not display the categories at the main page for this site:

    define('SHOW_CATEGORIES_ALWAYS','0');

    //Display the categories of ID 5 as the main category of the website:

    define('CATEGORIES_START_MAIN','5');

    //Change the Contact us email address:

    define('STORE_OWNER_EMAIL_ADDRESS','an_email@address.com')

    //Enable the SSL only for this site:

    define('ENABLE_SSL', 'true'); //assuming as 'false' in configure.php

    Remember that the code above is only here as example and do not always need to be use.

    If you don't know what is the name of the constants of a configuration setting, you can find it by clicking in your admin on Tools => Multisite Tools. This brings up the Multisite page. Here you click on the link "Display Configuration for a new site". Now all you constants are shown. You can select and copy them to the new config file

  2. Category Filter

    The MultiSite module works by filtering the categories with the function cat_filter. It only displays the categories that have the name of the site (constant SITE_NAME) in HTML comment in the categories descriptions. Therefore, you need to add this description to EVERY categories description that have to be display in a shop. Sub categories Included!

    Example of HTML comment:

     Description of a category that will be displayed in site1, site2 and site3.

    This comment will allow this category for the shops site1 site2 and site3. the site names HAVE to be separated by "-".
    If you have Lots of categories, it may be quicker to add the categories trough the Multisite tool. Go to Tools => Multisite Tools, and click "Display the relations Categories/Sites"


    Click to enlarge

    once you have put your HTML comments in your categories, they should appear on the front end of your shop. If a category has no HTML comment, it won't be displayed in any sites.

  3. Site Links

    If you want to allow the shoppers to have a cross-sites cart (orders products from different websites in the same cart), You have to display the side-box called "site_links.php" and you have to add the sites that you want to be link by editing the file "includes\modules\sideboxes\site_links.php".

    In this file, you have to add as many add_site_link(...); as you want of site links.

    Example:

    add_site_link('Shop Site1','http://www.site1.com');
    add_site_link('Shop Site2','http://www.site2.com');

    This works too:

    add_site_link('www.site1.com');
    add_site_link('www.site2.com');

    PS: these shops Should be Your multi-sites. You can also add some other sites there but the cross-site cart won't work (and so might confused the shoppers ...)

    add_site_link('Zen Cart','http://www.zen-cart.com',false);

    By adding false as third parameter (false), it won't add the zenid to the link. It can be use either for a shop in the same domain (cookie will work for it) or an external link (cross-site cart won't work anyway....)

    For the site links header sidebox, add the following code to your include/templates/YOUR_TEMPLATE/common/tpl_header.php file

    <!-- bof header Site links - Multi site module-->
          <?php require(DIR_WS_MODULES . 'sideboxes/site_links_header.php');?>
    <!-- bof header Site links - Multi site module-->

Version History

Version 1.0.1 Current- Release Date: 2013-02-09 by Design75

  • Updated site links sodebox to use the on/off switch properly
  • Added a header site link side box. This box can be placed any where you like and displays a horizontal bar with the site links.

Version 1.0 Current- Release Date: 2013-01-21 by Design75

  • Updated most files to contain the code of Zen Cart 1.5.1
  • Added the admin module registration for Zen Cart 1.5.x
  • The module is now multilingual on the admin side as well as the front-end
  • The site-link side-box has its own tpl file
  • Added SyntaxHightlighter 1.5.1 to multisite.php for easier reading and copying code

Version 0.4 - Release Date: 2007-08-07

  • Initial release

FAQs

Maybe this section will be used in a later release

Support

You will find the official support thread at the link below. Please feel free to post any comments or questions there.

Support thread

Donations

Of course this module is presented to you for free, but you can always buy me a cup of coffee.