User Guide | Cart Column 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.

Cart Column Configuration

Cart Settings Config | Cart Internal Settings Config
Cart Config Function Index | Get Cart Config Session Data | Set Cart Config Session Data | Cart Config 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'.

Required Cart Column Names

The following columns are the minimum required columns for the cart to function.

Internal Name Default Alias Data Type Description
row_id row_id string Items cart row identifier - set automatically.
item id int Items unique id, usually a database table row id.
item_name name string Items name and/or description.
item_quantity quantity int Quantity of items selected by user.
item_price price int Item selling price.

These columns must each be set with a unique name. Do not set them as 'FALSE' even if they are not used.

Optional Cart Column Names

The following columns can optionally be set to define additional item data.
Data manually added to these columns will overwrite any defaults set by the cart or that are available via a related database table.

Internal Name Default Alias Data Type Description
item_weight weight int Item unit weight that can be used to calculate shipping rates.
item_tax_rate tax_rate int Manually set a tax rate for the item.
item_shipping_rate shipping_rate int Manually set a shipping rate for the item.
item_separate_shipping separate_shipping int Manually set an item to have its shipping calculated separately from other cart items.
item_options options string | array Item option descriptions.
item_reward_points reward_points int Manually set reward points for the item.
item_unique_status unique bool Force item to have its own cart row, regardless of whether an identical item already exists in the cart.

Updatable Cart Columns

Define which cart columns can be updated for existing items in the cart.

How it Works

As a security measure, cart columns can be prevented from being updated by the 'update_cart()' function.

The purpose of this is prevent a potential html field being injected by a malicious user to an update cart form, with the aim of updating a cart column like the price, item shipping and tax rate columns with their own value.

This is possible if updating cart columns using POST data with matching html input names.

For example, if a html input field named 'price' (Default alias of 'item_price') was injected, and the cart was then updated by matching any identically named POST data, the data array would contain a key named 'price' that would then update the carts 'price' column.

By defining which columns are updatable, the cart will ignore any submitted data from non-updatable columns.

If the ability to update sensitive columns is required, ensure all data submitted is validated.

Setting Updatable Cart Columns

To set which cart columns are updatable, the column alias name (Not the internal name) must be added to the updatable columns array.

// Example of setting updatable cart columns by their alias.
// This examples sets the cart columns 'item_quantity' and 'item_options'.

$config['cart']['items']['updatable_columns'] = array(
	'quantity', 'options'

Reserved / Auto-calculated columns

These cart column names are reserved, so do not add any data to the cart using these array key names as the data will be removed.
The values of these columns are automatically generated and calculated by the cart.

Note: The data types and default values shown are values that are stored in the carts actual session data, this is not to be confused with the array cart data that can be returned using some of the cart library functions. Many values returned from such functions are formatted for display purposes. Help
Internal Name Default Alias Data Type Description
item_internal_price internal_price int Item selling price as carts default currency and tax settings.
item_price_total price_total int Item sub-total price.
item_tax tax int Tax value per item.
item_tax_total tax_total int Item sub-total tax value.
item_stock_quantity stock_quantity int Quantity of items in stock.
item_non_discount_quantity non_discount_quantity int Quantity of items not included in discount.
item_discount_quantity discount_quantity int Quantity of items included in discount.
item_discount_description discount_description string Item discount description.
item_discount_price discount_price int Discount value per item.
item_discount_price_total discount_price_total int Item sub-total price of discounted and non discounted items.
item_weight_total weight_total int Item sub-total weight.
item_reward_points_total reward_points_total int Item sub-total reward points.
item_status_message status_message array Item status message.
Admin Data Cart Columns.

The following 2 columns are only available when updating/editing a confirmed order after using the 'load_cart_data()' function.

Internal Name Default Alias Data Type Description
item_quantity_shipped quantity_shipped int Quantity of items from a confirmed order that have been shipped.
item_quantity_cancelled quantity_cancelled int Quantity of items from a confirmed order that have been cancelled.

These columns must each be set with a unique name. Do not set them as 'FALSE' even if they are not used.

User Defined Custom Cart Columns

Define custom columns that can will automatically be added to the carts item session data when an item is added to the cart.

Parameter Name Data Type Description
name string Sets the custom column name.
required bool Define whether data must be submitted when the item is inserted to the cart.
regex string Sets a regular expression that the columns value must be validated against when the item is inserted or updated.
Set FALSE to disable validation.
decimals int Defines the number of decimal places the column value should be formatted to.
Applies to numeric data only. Set FALSE to disable formatting.
default anything Defines the default value of the column if no value is added when the item is inserted to the cart.
updatable bool Defines whether data can be updated after item has been inserted to the cart.
How it Works

Additional user defined columns can be manually added to an items data array by including additional array keys (column names) and values when adding an item to the cart.

However, unless the custom column is defined via the config. files 'custom_columns' array, the column will only be present if data is submitted.

By pre-defining custom columns, you can format numbers, set default values and specify if a column is required when an item is added.

// Example #1 : Defining 1 custom cart column.

$config['cart']['items']['custom_columns'] = array(
	'name' => 'example_custom_column', 
	'required' => FALSE, 
	'regex' => '\.a-z0-9_-', 
	'decimals' => FALSE, 
	'default' => NULL, 
	'updatable'=> TRUE
// Example #2 : Defining multiple custom cart columns.

$config['cart']['items']['custom_columns'] = array(
	'name' => 'example_custom_column_1', 
	'required' => FALSE, 
	'regex' => '\.a-z0-9_-', 
	'decimals' => FALSE, 
	'default' => NULL, 
	'updatable'=> TRUE
	'name' => 'example_custom_column_2', 
	'required' => TRUE, 
	'regex' => FALSE, 
	'decimals' => 2, 
	'default' => 0, 
	'updatable'=> TRUE
// Example #3 : Disabling the custom columns feature.

$config['cart']['items']['custom_columns'] = FALSE;