CS-Cart allows you to create multiple storefronts and control them from one administration panel. These storefronts work with the same database, but they can have different designs, products, categories, customers, settings, and design.
You can adapt a storefront for a separate target audience. For example, if you sell clothes, you can create a separate storefront with a different design to sell kids clothes only. You can also make a storefront look like an entirely separate store to your customers.
You can manage your storefronts under Administration → Stores. The main parameters of a storefront are as follows:
- Storefront name
- Storefront URL—the domain of the storefront, like example.com. If the storefront is situated in a subfolder, you must specify it too, for example, example.com/stores/. This parameter defines the storefront in the customer area.
CS-Cart uses the following database tables to store the information about storefronts:
- cscart_companies—the main parameters of a storefront
- cscart_company_descriptions—language-dependent parameters
The Administration Panel
The Administration panel has 3 modes of managing objects:
- All Stores—the administrator manages all the objects and settings of the store.
- Selected Storefront—the administrator manages one specific storefront.
- Simple Ultimate—there is only one storefront, and the administrator can manage all the objects without restrictions.
Scripts work faster in the Simple Ultimate mode, because some of the checks to determine the owner of an object are skipped. To separate the logic within the code, the value of
Registry::get('runtime.simple_ultimate') in the Simple Ultimate mode is set to
The value of
Registry::get('runtime.company_id') will be 0 in the All Stores and Simple Ultimate modes. To get the current storefront ID, use
Some interfaces, like themes, may require the Selected Storefront mode. In this case, the administrator will be offered to choose the storefront.
Objects can be divided in two types: they either have an owner (a specific storefront), or don’t. Below you can the lists of standard CS-Cart objects that have or don’t have an owner. Add-ons may add other objects to either of those lists.
Objects that Must Have an Owner
- Product categories
- Payment methods
- Product features
- Product options
- Shipping methods
All object tables in the database have the
company_id field that defines the owner storefront of an object. Administrators can access the object in the All Stores mode, or by choosing the owner storefront in the Selected Storefront mode.
Objects that Don’t Have an Owner
- Profile fields
You can edit these objects in the All Stores and Simple Ultimate modes only—they are not directly related to storefronts.
There are two types of settings:
- Global setting—can’t be specified for a particular storefront; available only in the All Stores mode.
- Store-specific settings—can have different values for different storefronts; available in the Selected Storefront mode. To edit these settings in the All Stores mode, you need to specify that you update them for all your storefronts.
Every setting defines its own type in the
edition_type field of the cscart_settings_objects table. If this field has the line
VENDOR, the setting is store-specific, and its values are saved in the cscart_settings_vendor_values table.
You can access the values of the settings for the current storefront from the Registry, for example:
Settings class to manage settings on the code level—this class has all the necessary methods.
Defining Storefront URL
Storefronts can use a separate domain or a subfolder of the main domain. This is specified in the Storefront URL and Secure storefront URL (for HTTPS) settings. All the logic that handles defining storefront URLs is located in the fn_init_store_params_by_host function.
For the storefronts to work properly, configure your web server to make index.php process all the requests sent to nonexistent addresses.
CS-Cart comes with the properly configured .htaccess. Make sure to allow its use in the web server settings. This code from the .htaccess file redirects all the necessary queries to index.php:
When nginx works directly with PHP (FastCGI, php-fpm), configure the redirection rules manually. Here is the part of the configuration file that redirects for nonexistent files and directories to index.php: