User Guide | Location Configuration

flexi cart contains many features to aid the custom development of an e-commerce site.
In some instances, some of the features may be considered overkill, or may not require a database table to handle a feature.
In these cases, specific database tables can be disabled, or with some tables, specific columns can be disabled if not required.

In addition to this, the database tables and columns can be renamed to match the custom naming conventions.

Location Configuration

Location Function Index | Get Location Session Data | Get Location Helper Data | Set Location Session Data | Location Admin Data

Help with the Table Configuration

Show / Hide Help

Internal Name: The name that flexi cart internally references the table or column by.

Default Name: The default table or column name used in the actual table.

Data Type: The data type that is expected by the table column.

  • bool : Requires a boolean value set as either '0' (FALSE) or '1' (TRUE).
  • string : Requires a textual value.
  • int : Requires a numeric value. It does not matter whether the value is an integer, float, decimal etc.


Config File Location

The config file is located in CodeIgniters 'config' folder and is named 'flexi_cart.php'.

Location Tables Schema Diagram

A database table schema diagram, showing how the location tables are related to each other.
Table and columns names are defined using their internal names.

General Location Setup Notes

Below are some general notes to consider when setting up and managing the location tables.

  • When defining locations and zones for shipping options, taxes and discounts; the location has priority over the zone.
    Example: If multiple tax rates matched the current tax location and zone, then the tax rates that specifically match the location would be returned instead of tax rates matching the zone.
  • When a location is deleted that is related to shipping options, taxes or discounts; if the related 'child' data is not also deleted, then it becomes orphaned. This means that whilst the child data is still valid, it will no longer be accessible by helper functions until the data is updated with a new parent location.

Location Type Table

Contains data on the type of locations and zones available, i.e. countries, states, counties, cities and even zip/post codes.


Table and Column Setup
Help
Internal Name Default Name Data Type Description
table location_type - The tables name.
id loc_type_id int The tables primary key.
parent loc_type_parent_fk int Relates the location type to a parent location type, i.e. 'Country' > 'State'.
The value acts as a foreign key relating the table to the primary key of this table.
name loc_type_name string The name of the location type.
Requirements

If the table is enabled, then all columns are required and the 'Locations' and 'Location Zones' tables must be enabled too.

Example
// Example #1 : Defining the table and column names.

$config['database']['location_type']['table'] = 'location_type';
$config['database']['location_type']['columns']['id'] = 'loc_type_id';
// Example #2 : Disabling the table.

$config['database']['location_type']['table'] = FALSE;

Locations Table

Contains location and zone data used to calculate shipping and tax rates.


Table and Column Setup
Help
Internal Name Default Name Data Type Description
table locations - The tables name.
id loc_id int The tables primary key.
type loc_type_fk int Relates the location to a location type.
The value acts as a foreign key relating the table to the primary key of the Location Type table.
parent loc_parent_fk int Relates the location to a parent location, i.e. 'United States' > 'New York'.
The value acts as a foreign key relating the table to the primary key of this table.
shipping_zone loc_ship_zone_fk int Relates the location to a location zone that is used to group shipping locations together.
The value acts as a foreign key relating the table to the primary key of the Location Zone table.
tax_zone loc_tax_zone_fk int Relates the location to a location zone that is used to group tax locations together.
The value acts as a foreign key relating the table to the primary key of the Location Zone table.
name loc_name string The name of the location.
status loc_status bool Defines the status of whether the location is active or disabled.
Disabled records will not be used by flexi cart functions.
shipping_default loc_ship_default bool Defines the default shipping location to be applied to the cart when first loaded.
A table row defined as the default shipping location should be indicated with a value of 1.
tax_default loc_tax_default bool Defines the default tax location to be applied to the cart when first loaded.
A table row defined as the default tax location should be indicated with a value of 1.
This table column can be disabled.
Requirements

If the table is enabled, then with the exception of 'shipping_default' and 'tax_default', all other columns are required and the 'Location Type' and 'Location Zones' tables must be enabled too.

If either of the 'shipping_default' and 'tax_default' columns are disabled, the cart will use the default location settings defined via the config file.

Example
// Example #1 : Defining the table and column names.

$config['database']['locations']['table'] = 'locations';
$config['database']['locations']['columns']['id'] = 'loc_id';

// Defining the 'shipping_default' and 'tax_default' columns.
$config['database']['locations']['shipping_default'] = 'loc_ship_default';
$config['database']['locations']['tax_default'] = 'loc_tax_default';
// Example #2 : Disabling the table.

$config['database']['locations']['table'] = FALSE;

Location Zones Table

Contains data on the type of zones available.
The purpose of zones is to allow the grouping of locations that would otherwise be impractical using the parent-to-child relationship offered by the Location Type tiers.

For example, to create an 'EU' tax rule, you would not be able to apply it to a location of 'Europe' as not all European countries are in the 'EU'. So instead, create a zone called 'Tax EU Zone', independent countries can then be assigned to this zone that will now inherit a defined 'EU' tax rate.


Table and Column Setup
Help
Internal Name Default Name Data Type Description
table location_zones - The tables name.
id lzone_id int The tables primary key.
name lzone_name string The name of the location zone.
description lzone_description string A description of the location zone.
status lzone_status bool Defines the status of whether the location zone is active or disabled.
Disabled records will not be used by flexi cart functions.
Requirements

If the table is enabled, then all columns are required and the 'Locations Type' and 'Locations' tables must be enabled too.

Example
// Example #1 : Defining the table and column names.

$config['database']['location_zones']['table'] = 'location_zones';
$config['database']['location_zones']['columns']['id'] = 'lzone_id';
// Example #2 : Disabling the table.

$config['database']['location_zones']['table'] = FALSE;

Defining Location Defaults via the Config File.

Default shipping and tax locations can be set to correctly configure the cart when it is first loaded.

The default locations can be defined via either the config file or via the location database table.
However, since the location based functionality of flexi cart is only active if the location table is defined, it is likely to be more practical to define the defaults via a column in the location table.

To set the default shipping and tax locations via the location table, enter the value '1' into the row of the tables 'shipping_default' and 'tax_default' columns.

Default locations set via the config file are only used if no default value has been set in the location database table.


Default Settings
Parameter Name Data Type Description
location string | int | array Sets the default shipping and tax locations.
Notes

Default locations can be defined using either be a string (i.e. location name), integer (i.e. location id in database) or an array of multiple strings and/or integers.

The config values will then be matched against the location table, matching ids with table ids and string names with location names (Names are matched identically).

Example
// Example #1 : Defining the default shipping and tax location using a string.

$config['defaults']['shipping']['location'] = 'United States';
$config['defaults']['tax']['location'] = 'United States';
// Example #2 : Defining the default shipping and tax location using an array.
// Note: When defining multiple tier locations, include all parents of the child location.

$config['defaults']['shipping']['location'] = array('United States', 'New York');
$config['defaults']['tax']['location'] = array('United States', 'New York');
// Example #3 : Disabling default locations set via the config file.

$config['defaults']['shipping']['location'] = FALSE;
$config['defaults']['tax']['location'] = FALSE;