User Guide | Getting Location 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 Location Session Data

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

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.

shipping_location_data()

Returns an array of the carts current shipping locations as table ids.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Return Values

Failure:n/a

Success:array

Examples
Note: The returned example values below are displaying live data from the current cart session data.
shipping_location_data() What is the current shipping location, returned as an array? Show / Hide Array
Array
(
    [0] => Array
        (
            [location_id] => 1
            [zone_id] => 0
            [type_id] => 1
            [parent_id] => 0
            [name] => United Kingdom (EU)
        )

)

match_shipping_location_id()

Returns whether a submitted location id is set within the cart shipping location array.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
match_shipping_location_id(location_id) Help
Name Data Type Required Default Description
location_id int Yes FALSE Defines the id of the to-be-checked location.
Notes

Typically, the function is used to match whether the location id of a html select menu option is present, if so, the option can be selected.
Example: A html select menu lists countries, when the page loads, the menu auto selects the current country the carts shipping location is set as.

Return Values

Failure:FALSE

Success:TRUE

Examples
Note: The returned example values below are displaying live data from the current cart session data.
match_shipping_location_id(1) Does the current shipping location match a location id of 1? (United Kingdom location id = 1) bool(true)
match_shipping_location_id(10) Does the current shipping location match a location id of 10? (United States location id = 10) bool(false)

shipping_location_id()

Returns the location id of the current shipping location, for a defined location type.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
shipping_location_id(location_type_id) Help
Name Data Type Required Default Description
location_type_id int Yes 1 Defines the location type that the location id should be returned for.
Example: Using the demos default setup, if 'location_type_id' = 2, then the location id of a 'State' would be returned.
Return Values

Failure:FALSE

Success:int

Examples
Note: The returned example values below are displaying live data from the current cart session data.
shipping_location_id(1) What is the id of the current shipping country? (Location type 1 = Country) 1
shipping_location_id(2) What is the id of the current shipping state? (Location type 2 = State) bool(false)

shipping_location_name()

Returns the location name of the current shipping location, for a defined location type.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
shipping_location_name(location_type_id) Help
Name Data Type Required Default Description
location_type_id int Yes 1 Defines the location type that the location name should be returned for.
Example: Using the demos default setup, if 'location_type_id' = 2, then the location name of a 'State' would be returned.
Return Values

Failure:FALSE

Success:string

Examples
Note: The returned example values below are displaying live data from the current cart session data.
shipping_location_name(1) What is the name of the current shipping country? (Location type 1 = Country) United Kingdom (EU)
shipping_location_name(2) What is the name of the current shipping state? (Location type 2 = State) bool(false)

location_shipping_status()

Returns whether items in the cart are permitted to be shipped to the current shipping location.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
location_shipping_status(check_all_items_permitted) Help
Name Data Type Required Default Description
check_all_items_permitted bool No TRUE Defines whether to check if all items in the cart are permitted to be shipped.
If 'FALSE', it will check that at least 1 item in the cart is permitted.
Return Values

Not Permitted:FALSE

Permitted:TRUE

Examples
Note: The returned example values below are displaying live data from the current cart session data.
location_shipping_status(TRUE) Are all items in the cart permitted to be shipped to the current location? bool(true)
location_shipping_status(FALSE) Are any items in the cart permitted to be shipped to the current location? bool(false)

tax_location_data()

Returns an array of the carts current tax locations as table ids.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Return Values

Failure:n/a

Success:array

Examples
Note: The returned example values below are displaying live data from the current cart session data.
tax_location_data() What is the current tax location, returned as an array? Show / Hide Array
Array
(
    [0] => Array
        (
            [location_id] => 1
            [zone_id] => 4
            [type_id] => 1
            [parent_id] => 0
            [name] => United Kingdom (EU)
        )

)

match_tax_location_id()

Returns whether a submitted location id is set within the cart tax location array.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
match_tax_location_id(location_id) Help
Name Data Type Required Default Description
location_id int Yes FALSE Defines the id of the to-be-checked location.
Notes

Typically, the function is used to match whether the location id of a html select menu option is present, if so, the option can be selected.
Example: A html select menu lists countries, when the page loads, the menu auto selects the current country the carts tax location is set as.

Return Values

Failure:FALSE

Success:TRUE

Examples
Note: The returned example values below are displaying live data from the current cart session data.
match_tax_location_id(1) Does the current tax location match a location id of 1? (United Kingdom location id = 1) bool(true)
match_tax_location_id(10) Does the current tax location match a location id of 10? (United States location id = 10) bool(false)

tax_location_id()

Returns the location id of the current tax location, for a defined location type.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
tax_location_id(location_type_id) Help
Name Data Type Required Default Description
location_type_id int Yes 1 Defines the location type that the location id should be returned for.
Example: Using the demos default setup, if 'location_type_id' = 2, then the location id of a 'State' would be returned.
Return Values

Failure:FALSE

Success:int

Examples
Note: The returned example values below are displaying live data from the current cart session data.
tax_location_id(1) What is the id of the current tax country? (Location type 1 = Country) 1
tax_location_id(2) What is the id of the current tax state? (Location type 2 = State) bool(false)

tax_location_name()

Returns the location name of the current tax location, for a defined location type.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
tax_location_name(location_type_id) Help
Name Data Type Required Default Description
location_type_id int Yes 1 Defines the location type that the location name should be returned for.
Example: Using the demos default setup, if 'location_type_id' = 2, then the location name of a 'State' would be returned.
Return Values

Failure:FALSE

Success:string

Examples
Note: The returned example values below are displaying live data from the current cart session data.
tax_location_name(1) What is the name of the current tax country? (Location type 1 = Country) United Kingdom (EU)
tax_location_name(2) What is the name of the current tax state? (Location type 2 = State) bool(false)