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!
Version 1.0 - Release Date: 2013-01-21
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.
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.
$template_name = 'mysite';
$template_name = 'site1';
$template_name = 'site1';
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.
Upgrading from previous versions is not supported Please do a fresh installation
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
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"
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.
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....)
Version 1.0 Current- Release Date: 2013-01-21 by Design75
Version 0.4 - Release Date: 2007-08-07
Maybe this section will be used in a later release
You will find the official support thread at the link below. Please feel free to post any comments or questions there.
Support threadOf course this module is presented to you for free, but you can always buy me a cup of coffee.