Discount Configuration
Discount Function Index |
Get Discount Session Data |
Get Discount Helper Data |
Set Discount Session Data |
Discount 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'.
Discount Table Schema Diagram
A database table schema diagram, showing how the discount tables are related to each other and the location, custom item and user tables.
Note: The custom item and user tables must be created by you. The diagram highlights how they can be related to the discount tables.
Table and columns names are defined using their internal names.
General Discount Setup Notes
Below are some general notes to consider when setting up and managing the discount tables.
-
All discount currency values must always be based on the carts internal currency, regardless of whether the customer is viewing prices in a different currency.
-
Only one discount can be applied per item or summary column, however, if applicable, the same discount can be applied to the same item multiple times.
-
If multiple discounts are eligible to be applied to an item or summary column, the discount with the lowest 'order by' value will be given priority.
-
In the event that a discount can by applied directly to an item, or to the same item within an item discount group; then the discount is applied directly to the item rather than the item group.
If a discount is then applied to the same item discount group via other items in the cart, the value and quantity of the item that has a discount directly applied to it will not be added to the item discount groups total value and quantity.
-
Discounts that are applied to items within an item discount group are applied to the cheapest items first.
-
The 'New Value' discount method cannot be applied to the summary item total (Total of all items), or summary total (Cart total) columns. If this was allowed, then a cart of unlimited items could be purchased for the 'New Value' price.
Discounts Table
Contains item and summary discounts, based on either entered discount codes or item quantities and values added to the cart.
The discount table is also used to convert customer reward points to vouchers.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discounts |
- |
The tables name. |
id |
disc_id |
int |
The tables primary key. |
type |
disc_type_fk |
int |
The value acts as a foreign key relating the table to the primary key of the discount type table.
|
method |
disc_method_fk |
int |
The value acts as a foreign key relating the table to the primary key of the discount method table.
|
tax_method |
disc_tax_method_fk |
int |
The value acts as a foreign key relating the table to the primary key of the discount tax method table.
|
user |
disc_user_acc_fk |
int |
Relates a reward voucher saved in the discount table to a user.
The column has no affect on the functioning of discounts.
The value acts as a foreign key relating the table to the primary key of a converted reward point table. It could also be used to relate the table to a custom user table, although this is not joined by default.
|
item |
disc_item_fk |
int |
Relates the discount to an item (product) in the cart.
The value CAN be used to act as a foreign key relating the table to the primary key of a custom item (product) table, although this is not joined by default.
|
group |
disc_group_fk |
int |
Relates the discount to a discount group of items (products).
The value acts as a foreign key relating the table to the primary key of a discount group table.
|
location |
disc_location_fk |
int |
Relates the discount to a location, so it will only be displayed if that location is set.
The value acts as a foreign key relating the table to the primary key of the location table.
|
zone |
disc_zone_fk |
int |
Relates the discount to a location zone, so it will only be displayed if a location from that zone is set.
The value acts as a foreign key relating the table to the primary key of the location zones table.
|
code |
disc_code |
string |
The discount code that can be set to activate the discount. |
description |
disc_description |
string |
The description of the discount. |
quantity_required |
disc_quantity_required |
int |
The minimum quantity of related items that must be added to the cart before the discount can be activated. |
quantity_discounted |
disc_quantity_discounted |
int |
The quantity of related items that the discount will be applied to. |
value_required |
disc_value_required |
int |
The minimum value (price) of related items that must be added to the cart before the discount can be activated. |
value_discounted |
disc_value_discounted |
string |
The discount value will be applied to the applicable discounted items. |
recursive |
disc_recursive |
bool |
Defines whether the discount should be reapplied recursively to items in the cart.
Example: If 'recursive' is enabled, a 'Buy 1, get 1 free' discount can be reapplied if 2, 4, 6 (etc) items are added to the cart.
If disabled, the discount is only applied for the first 2 items.
|
non_combinable |
disc_non_combinable_discount |
bool |
Defines whether other discounts can be applied if this discount is applied to the cart. |
void_reward_points |
disc_void_reward_points |
bool |
Defines whether reward points should be voided for the entire cart if the discount is applied. |
force_shipping_discount |
disc_force_ship_discount |
bool |
Defines whether the discount should be applied to the shipping option, regardless of whether the shipping option is defined as being excluded from discounts. |
custom_status_1 |
disc_custom_status_1 |
string | int |
Defines a value that the cart session custom status #1 must match for the discount to be applied. |
custom_status_2 |
disc_custom_status_2 |
string | int |
Defines a value that the cart session custom status #2 must match for the discount to be applied. |
custom_status_3 |
disc_custom_status_3 |
string | int |
Defines a value that the cart session custom status #3 must match for the discount to be applied. |
usage_limit |
disc_usage_limit |
int |
The limit to the number of times the discount can be used. |
valid_date |
disc_valid_date |
string | int |
The date and time that the discount valid from.
The data type of this column can either be mysql datetime or a unix timestamp.
Read the internal config documentation regarding setting the carts date and time settings.
|
expire_date |
disc_expire_date |
string | int |
The date and time that the discount expires by.
The data type of this column can either be mysql datetime or a unix timestamp.
Read the internal config documentation regarding setting the carts date and time settings.
|
status |
disc_status |
bool |
Defines the status of whether the discount is active or disabled.
Disabled records will not be used by flexi cart functions.
|
order_by |
disc_order_by |
int |
Defines the order priority of how a discount is applied to the cart.
Only one discount can be applied per item or per summary column.
Therefore, if two or more discounts could be applied, the discount with the lowest 'order_by' value will be applied first.
|
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
Example
$config['database']['discounts']['table'] = 'discounts';
$config['database']['discounts']['columns']['id'] = 'disc_id';
$config['database']['discounts']['table'] = FALSE;
Discount Groups Table
To maintain flexibility with different database structures, rather than being able to apply discounts to item categories, manufacturers etc., that will be different per database setup, discount groups can be used instead. A discount can then be applied to the group that will affect all items in the group.
The discount group setup consists of two tables, a table containing the group name, and a table containing the foreign key of the group id and item ids.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_groups |
- |
The tables name. |
id |
disc_group_id |
int |
The tables primary key. |
name |
disc_group |
string |
The name of the discount group. |
status |
disc_group_status |
bool |
Defines the status of whether the discount group is active or disabled.
Disabled records will not be used by flexi cart functions.
|
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
Example
$config['database']['discount_groups']['table'] = 'discount_groups';
$config['database']['discount_groups']['columns']['id'] = 'disc_group_id';
$config['database']['discount_groups']['table'] = FALSE;
Discount Group Items Table
Contains the id of items that are in a specific discount group.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_group_items |
- |
The tables name. |
id |
disc_group_item_id |
int |
The tables primary key. |
group |
disc_group_item_group_fk |
int |
Relates the discount group item to a discount group.
The value acts as a foreign key relating the table to the primary key of discount group table.
|
item |
disc_group_item_item_fk |
int |
Relates the discount group item to an item (product) in the cart.
The value CAN be used to act as a foreign key relating the table to the primary key of a custom item (product) table, although this is not joined by default.
|
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
Example
$config['database']['discount_group_items']['table'] = 'discount_group_items';
$config['database']['discount_group_items']['columns']['id'] = 'disc_group_item_id';
$config['database']['discount_group_items']['table'] = FALSE;
Discount Method Table
Contains the data for the different discount application methods.
Example: A summary discount, that targets the shipping total column with a percentage based discount.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_methods |
- |
The tables name. |
id |
disc_method_id |
int |
The tables primary key. |
type |
disc_method_type_fk |
int |
Relates the discount method to the type of discount (Item, summary, voucher discount).
The value acts as a foreign key relating the table to the primary key of the discount type table.
|
target_column |
disc_method_column_fk |
int |
Relates the discount method to the item or summary column that is to be discounted.
The value acts as a foreign key relating the table to the primary key of the discount columns table.
|
calculation |
disc_method_calculation_fk |
int |
Relates the discount method to the type of discount calculation that is to be applied (Percentage based, flat fee, new value discount).
The value acts as a foreign key relating the table to the primary key of the discount calculation table.
|
method |
disc_method |
string |
The name of the discount method. |
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
IMPORTANT NOTE: The discount 'method' text may be changed, but no rows or columns should be deleted or added.
Example
$config['database']['discount_methods']['table'] = 'discount_methods';
$config['database']['discount_methods']['columns']['id'] = 'disc_method_id';
$config['database']['discount_methods']['table'] = FALSE;
Discount Types Table
Contains the id and text label for the different types of discounts available.
Types Available: 'Item Discount', 'Summary Discount' and 'Reward Voucher' discounts.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_types |
- |
The tables name. |
id |
disc_type_id |
int |
The tables primary key. |
type |
disc_type |
string |
The name of the discount type. |
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
IMPORTANT NOTE: The discount 'type' text may be changed, but no rows or columns should be deleted or added.
Example
$config['database']['discount_types']['table'] = 'discount_types';
$config['database']['discount_types']['columns']['id'] = 'disc_type_id';
$config['database']['discount_types']['table'] = FALSE;
Discount Calculations Table
Contains the id and text label for the different types of discount calculation methods.
Types Available: 'Percentage based', 'Flat Fee' and 'New Value' discounts.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_calculation |
- |
The tables name. |
id |
disc_calculation_id |
int |
The tables primary key. |
calculation |
disc_calculation |
string |
The name of the discount calculation method. |
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
IMPORTANT NOTE: The discount 'calculation' text may be changed, but no rows or columns should be deleted or added.
Example
$config['database']['discount_calculation']['table'] = 'discount_calculation';
$config['database']['discount_calculation']['columns']['id'] = 'disc_calculation_id';
$config['database']['discount_calculation']['table'] = FALSE;
Discount Columns Table
Contains the id and text label for the different cart columns that discounts can be applied to.
Types Available: 'Item price', 'Item Shipping', 'Summary Item Total', 'Summary Shipping Total', 'Summary Total' and 'Summary Total (Voucher)'.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_columns |
- |
The tables name. |
id |
disc_column_id |
int |
The tables primary key. |
target_column |
disc_column |
string |
The name of the column the discount is to be applied to. |
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
IMPORTANT NOTE: The discount 'target_column' text may be changed, but no rows or columns should be deleted or added.
Example
$config['database']['discount_columns']['table'] = 'discount_columns';
$config['database']['discount_columns']['columns']['id'] = 'disc_column_id';
$config['database']['discount_columns']['table'] = FALSE;
Discount Tax Methods Table
Contains the id and text label for the different methods of applying tax to discounts.
Table and Column Names
Help
Internal Name |
Default Name |
Data Type |
Description |
table |
discount_tax_methods |
- |
The tables name. |
id |
disc_tax_method_id |
int |
The tables primary key. |
method |
disc_tax_method |
string |
The name of the discount tax method. |
Types of Discount Tax Methods
Tax laws vary between countries and states, so to comply with these laws, discounts and tax can be applied using three different methods.
Method #1 : Calculate non-discounted value including tax, then apply discount to value.
This method is typically used for carts setup with item prices including tax.
This is by default defined in the database discount tax method table as 'Apply Tax Before Discount'.
Method #2 : Calculate non-discounted value excluding tax, then apply discount to value, then apply tax rate to discounted value.
This method is typically used for carts setup with item prices excluding tax.
This is by default defined in the database discount tax method table as 'Apply Discount Before Tax'.
Method #3 : Calculate tax of non-discounted value, then apply discount to value excluding tax, then add the original tax value to discounted value.
This method is typically used for 'Manufacturer Coupon' discounts, when the items full non-discounted tax value must still be paid by the customer.
This is by default defined in the database discount tax method table as 'Apply Discount Before Tax, Add Original Tax'.
Examples of these tax methods are available via the demos 'Item Discount Examples'.
Remember that the values returned will vary depending on whether cart prices are set to include taxes, so try toggling tax settings to see how the values are affected.
Notes
If the table is enabled, then all columns are required and all other discount tables must be enabled too.
The related location, custom item or user tables do not need to be enabled to use discount tables.
IMPORTANT NOTE: The discount 'method' text may be changed, but no rows or columns should be deleted or added.
Example
$config['database']['discount_tax_methods']['table'] = 'discount_tax_methods';
$config['database']['discount_tax_methods']['columns']['id'] = 'disc_tax_method_id';
$config['database']['discount_tax_methods']['table'] = FALSE;