User Guide | Getting Surcharge Session Data

When the flexi cart library is first loaded, an array is automatically created that is setup to match the carts default settings, this data is then stored in the browsers session. All items and settings that are then later added and altered within the cart are updated to the carts session data.

The data within the carts session can then be accessed and in many cases, formatted and customised using the large range of functions that are available from the lite and standard libraries.

Get Surcharge Session Data

Surcharge Function Index | Set Surcharge Session Data
Get Surcharge Data from Session

surcharge_status() | surcharge_data() | surcharge_description()

Help with Session Data Functions

Show / Hide Help

Name: The name of the function (method).

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

  • bool : Requires a boolean value of 'TRUE' or 'FALSE'.
  • string : Requires a textual value.
  • int : Requires a numeric value. It does not matter whether the value is an integer, float, decimal etc.
  • array : Requires an array.

Required: Defines whether the parameter requires a value to be submitted.

Default: Defines the default parameter value that is used if no other value is submitted.

surcharge_status()

Returns whether a surcharge has been applied to the cart.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Return Values

Not Applied:FALSE

Applied:TRUE

Examples
Note: The returned example values below are displaying live data from the current cart session data.
surcharge_status() Are any surcharges applied to the cart? bool(false)

surcharge_data()

Returns an array of surcharge values and descriptions for either a particular surcharge, or all surcharges.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
surcharge_data(surcharge_id, format, internal_value) Help
Name Data Type Required Default Description
surcharge_id int No FALSE Defines the surcharge id to return data for.
If no id is submitted, then the data on all surcharges will be returned.
format bool No TRUE Define whether to format the returned monetary values as currencies.
internal_value bool No FALSE Defines whether to return the monetary values using the carts internal currency instead of the users current currency.
Return Values

Failure:array (Empty)

Success:array

Examples
Note: The returned example values below are displaying live data from the current cart session data.
surcharge_data(FALSE, TRUE, TRUE) Display the current surcharge value and description for all set surcharges. Show / Hide Array
Array
(
)
surcharge_data(FALSE, TRUE, FALSE) Display the internal surcharge value and description data for all set surcharges. Show / Hide Array
Array
(
)
surcharge_data('creditcard', TRUE, TRUE) Display the current surcharge value and description data for a set surcharge with the id of 'creditcard'. Show / Hide Array
Array
(
)

surcharge_description()

Returns surcharge values and descriptions formatted as a string.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
surcharge_description(value_prefix, prefix_delimiter, suffix_delimiter, internal_value) Help
Name Data Type Required Default Description
value_prefix string No FALSE Defines a string of characters to separate the surcharge description and value.
If no 'value_prefix' is set, the surcharge value will be omitted from the returned description.
prefix_delimiter string No FALSE Defines a string of characters to prefix to the start of each surcharge description.
suffix_delimiter string No <br/> Defines a string of characters to suffix to the end of each surcharge description.
internal_value bool No FALSE Defines whether to return the monetary values using the carts internal currency instead of the users current currency.
Return Values

Failure:FALSE

Success:string

Examples
Note: The returned example values below are displaying live data from the current cart session data.
surcharge_description(FALSE, FALSE, '<br/>', FALSE) Format the surcharge description with a line break after each row and the surcharge value omitted. bool(false)
surcharge_description('@&nbsp;', '<p>', '</p>', FALSE) Format the surcharge description with a prefixed space and '@' sign between the description and current value, and with each row wrapped in a html <p> tag. bool(false)
surcharge_description('@&nbsp;', '<p>', '</p>', TRUE) Format the surcharge description with a prefixed space and '@' sign between the description and internal value, and with each row wrapped in a html <p> tag. bool(false)