User Guide | Cart Internal 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 Internal Configuration

Cart Column Config | Cart Settings Config
Cart Config Function Index | Get Cart Config Session Data | Set Cart Config Session Data | Cart Config Admin Data

Item Validation Rules

The values of item ids and names that are inserted and updated within the cart can be validated using custom Regular Expressions.


Example
// Example #1 : Defining item id to allow alpha-numeric, dashes, underscores and periods.

$config['settings']['item_id_rules'] = '\.a-z0-9_-';
// Example #2 : Defining item name to allow alpha-numeric, dashes, underscores, colons, periods and commas.

$config['settings']['item_name_rules'] = '\.\,\:\-_ a-z0-9\#';
// Example #3 : Disabling regular expression validations.

$config['settings']['item_id_rules'] = FALSE;
$config['settings']['item_name_rules'] = FALSE;

Date and Time Settings

Define the date and time data format used within flexi cart functions.


Notes

The date and time used within flexi cart functions can be defined as either a MySQL DATETIME data type, or as a UNIX timestamp.

Note: The 'date_time' value is used by the discount and order tables, therefore, both tables must use the same data type.

Example
// Example #1 : Defining the MySQL DATETIME format.

$config['settings']['date_time'] = date('Y-m-d H:i:s'); 
// Example #2 : Defining the UNIX timestamp format.

$config['settings']['date_time'] = time(); 

Email Settings

Defines the email template and settings that are used to email users a copy of their order.


Example
// Site title shown as 'from' header on emails.
$config['email']['site_title'] = 'flexi cart';

// Reply email shown as 'from' header on emails.
$config['email']['reply_email'] = 'info@website.com';

// Type of email to send, options: 'html', 'text'.
$config['email']['email_type'] = 'html';

// Path to order confirmation email template.
$config['email']['email_template'] = 'includes/email/order_email.tpl.php';

Message Delimiter Settings

Define status and error message delimiters to style cart messages.


Example
// Status Message Start Delimiter.
$config['messages']['delimiters']['status_prefix'] = <p class="status_msg">;

// Status Message End Delimiter.
$config['messages']['delimiters']['status_suffix'] = </p>;

// Error Message Start Delimiter.
$config['messages']['delimiters']['error_prefix'] = <p class="error_msg">;

// Error Message End Delimiter.
$config['messages']['delimiters']['error_suffix'] =  </p>;

Public and Admin Messages

Define which status and error messages are returned as public or admin messages, or which messages are not returned at all.
Public messages are intended to be displayed to public and admin users, whilst admin messages are intended for admin users only.

Internal Message Name Default Value Description
items_added_successfully 'public' Notifies that one or more items have been added to the cart.
no_items_added 'public' Notifies that no items were added to the cart.
items_updated_successfully 'public' Notifies that one or more items in the cart have been updated.
no_items_updated 'public' Notifies that no items in the cart have been updated.
items_deleted_successfully 'public' Notifies that one or more items in the cart have been deleted.
invalid_data 'admin' Notifies that invalid item data has been submitted to an insert, update or delete cart item function.
Typically this means the data has not been structured correctly as an array, or that a valid cart row id has not been set.
invalid_item_id 'admin' Notifies that an invalid item id has been submitted to an insert or update cart item function.
Item id validation is defined via the 'item_id_rules' config setting.
invalid_item_name 'admin' Notifies that an invalid item name has been submitted to an insert or update cart item function.
Item name validation is defined via the 'item_name_rules' config setting.
invalid_item_quantity 'admin' Notifies that an invalid item quantity has been submitted to an insert or update cart item function.
This means that either a negative or non numerical value has been set as the item quantity.
invalid_item_price 'admin' Notifies that an invalid item price has been submitted to an insert or update cart item function.
This means that either a negative or non numerical value has been set as the item price.
invalid_custom_data 'admin' Notifies that invalid custom data has been submitted to an insert or update cart item function.
Custom data validation is defined via the Custom Column 'Regex' config setting.
item_out_of_stock_removed 'public' Notifies that an item that was either added or already present in the the cart has been automatically removed as it is not longer in stock.
item_shipping_banned 'admin' Notifies that the cart contains items that are not permitted to be shipped to the current shipping location.
shipping_location_updated_successfully 'admin' Notifies that the carts shipping location has been successfully updated.
shipping_location_update_unsuccessful 'admin' Notifies that the carts shipping location was not updated.
shipping_updated_successfully 'admin' Notifies that the carts shipping option has been successfully updated.
shipping_update_unsuccessful 'admin' Notifies that the carts shipping option was not updated.
tax_location_updated_successfully 'admin' Notifies that the carts tax location has been successfully updated.
tax_location_update_unsuccessful 'admin' Notifies that the carts tax location was not updated.
tax_updated_successfully 'admin' Notifies that the carts tax has been successfully updated.
tax_update_unsuccessful 'admin' Notifies that the carts tax was not updated.
discounts_updated_successfully 'public' Notifies that one or more cart discounts have been successfully updated.
discount_update_unsuccessful 'public' Notifies that no cart discounts were updated.
discount_codes_valid 'public' Notifies that one or more cart discount codes submitted to a cart function are valid and have been successfully applied to the cart.
discount_codes_invalid 'public' Notifies that one or more cart discount codes submitted to a cart function are invalid.
discount_unset_successfully 'public' Notifies that one or more cart discounts have been successfully removed from the cart.
discount_unset_unsuccessful 'public' Notifies that no cart discounts were removed from the cart.
excluded_discount_reenabled 'public' Notifies that all excluded discounts have been successfully re-enabled and can be applied to the cart.
duplicate_discount_code 'admin' Notifies that a duplicated discount code either inserted or updated to the database already exists.
This message is set when the admin library discount CRUD functions insert or update a discount.
surcharge_updated_successfully 'admin' Notifies that one or more cart surcharges have been successfully updated.
surcharge_update_unsuccessful 'admin' Notifies that no cart surcharges were updated.
surcharge_unset_successful 'admin' Notifies that one or more cart surcharges have been successfully removed from the cart.
surcharge_unset_unsuccessful 'admin' Notifies that no cart surcharges were removed from the cart.
currency_updated_successfully 'public' Notifies that the carts currency has been successfully updated.
currency_update_unsuccessful 'public' Notifies that the carts currency was not updated.
cart_order_save_successful 'public' Notifies that the cart has been successfully saved as an order.
cart_order_save_unsuccessful 'public' Notifies that the cart was not saved as an order.
resave_order_does_not_exist 'admin' Notifies that the cart could not be resaved over an existing order as it does not exist.
This message is set if database cart data from an existing order is reloaded into the cart session as saved, but the original order number no longer exists.
order_number_exists 'admin' Notifies that the current order number already exists for an order in the database.
cart_data_save_successful 'public' Notifies that the cart session data has been successfully saved to the database.
cart_data_save_unsuccessful 'public' Notifies that the cart session data was not saved.
cart_data_load_successful 'public' Notifies that cart data has been successfully loaded from the database to the current cart session data.
cart_data_load_unsuccessful 'public' Notifies that cart data from the database could not be loaded.
cart_data_delete_successful 'public' Notifies that cart data from the database has been successfully deleted.
cart_data_delete_unsuccessful 'public' Notifies that cart data from the database could not be deleted.
send_email_successful 'public' Notifies that an email for a saved cart order has been sent successfully.
send_email_unsuccessful 'public' Notifies that an email for a saved cart order was not sent.
database_table_column_disabled 'admin' Notifies that either a database table or table column that is required for a cart feature to function is not enabled.
cart_emptied 'public' Notifies that all cart items have been removed from the cart.
cart_destroyed 'public' Notifies that all cart items have been removed from the cart, and that all cart session settings have been restored to their default values.
session_config_data_updated 'admin' Notifies that a cart session configuration has been successfully updated.
database_data_inserted 'admin' Notifies that data has been successfully inserted to a database table using an admin library insert function.
database_data_updated 'admin' Notifies that data has been successfully updated in a database table using an admin library update function.
database_data_deleted 'admin' Notifies that data has been successfully deleted from a database table using an admin library delete function.
Example
// Set the message to be displayed to public users.
$config['messages']['target_user']['items_added_successfully'] = 'public';
// Set the message to be displayed to admin users only.
$config['messages']['target_user']['items_added_successfully'] = 'admin';
// Disable a message from being set.
$config['messages']['target_user']['items_added_successfully'] = FALSE;

Define Language

Define the language of status and error messages returned by flexi cart functions.


The Language File

flexi cart uses CodeIgniters language class to allow status and error messages returned by the library to be displayed in a specific language.

To set the library to display messages in a specific language, firstly the translated language file must be added to CodeIgniters 'language' directory. If the language you require does not currently exist, you will need to create a copy of the default language file and get it translated.


To do this, copy the 'English' language file from:
'application/language/english/flexi_cart_lang.php' to 'application/language/[YOUR LANGUAGE]/flexi_cart_lang.php'.


It is recommended that any translations are made directly from the English language file rather than others, as that contains the originally intended messages of the library, with no lingual misinterpretations.

If you are unable to translate the file yourself, you could try one of the many free translators that are available online:

Defining a Language

Defining the language used by the library is done using CodeIgniters internal methods, either via the CI config. file, or by using CI's language class.

// Example #1 : Set language via CI's config file ('application/config/config.php').

$config['language'] = 'spanish';
// Example #2 : Set language via CI's language class.
// Note: This must be defined before calling the flexi cart library and would typically be done in either
// a controller or model.

// First load the language file.
$this->lang->load('flexi_cart', 'spanish');

// And then load the flexi cart library.
$this->load->library('flexi_cart');