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

List all Cart Functions | Get Cart Item Session Data | Get Cart Summary Session Data | Get Cart Helper Data | Set Cart Session Data
Get Cart Data from Session

cart_status() | cart_array() | cart_contents()

Help with Cart Functions

Show / Hide Help

Cart functions are used to alter data within the carts session data.
The functions can retrieve and format the session data for display on the website, as well as manage items and settings within the cart.


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.

cart_status()

Returns whether there are any items in the cart.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Return Values

Empty:FALSE

Not Empty:TRUE

Examples
Note: The returned example values below are displaying live data from the current cart session data.
cart_status() Do any items exist in the cart? bool(false)

cart_array()

Returns the entire cart session data as an array.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Notes

The data returned by this function is the carts actual session data. It is not formatted and no item or summary values include any applied discounts.

Return Values

Success:array

Examples
Note: The returned example values below are displaying live data from the current cart session data.
cart_array() Return the unformatted internal data for the entire cart data array. Show / Hide Array
Array
(
    [items] => Array
        (
        )

    [summary] => Array
        (
            [total_rows] => 0
            [total_items] => 0
            [total_weight] => 0
            [total_reward_points] => 0
            [item_summary_total] => 0
            [shipping_total] => 0
            [tax_total] => 0
            [surcharge_total] => 0
            [total] => 0
        )

    [settings] => Array
        (
            [currency] => Array
                (
                    [name] => GBP
                    [exchange_rate] => 1
                    [symbol] => £
                    [symbol_suffix] => 
                    [thousand_separator] => ,
                    [decimal_separator] => .
                    [default] => Array
                        (
                            [name] => GBP
                            [symbol] => £
                            [symbol_suffix] => 
                            [thousand_separator] => ,
                            [decimal_separator] => .
                        )

                )

            [shipping] => Array
                (
                    [id] => 0
                    [name] => 
                    [description] => 
                    [value] => 0
                    [tax_rate] => 
                    [location] => Array
                        (
                            [0] => Array
                                (
                                    [location_id] => 0
                                    [zone_id] => 0
                                    [type_id] => 0
                                    [parent_id] => 0
                                    [name] => 
                                )

                        )

                    [data] => Array
                        (
                            [surcharge] => 0
                            [separate_shipping_value] => 0
                            [separate_items] => 0
                            [separate_value] => 0
                            [separate_weight] => 0
                            [free_items] => 0
                            [free_value] => 0
                            [free_weight] => 0
                            [banned_shipping_items] => Array
                                (
                                )

                            [separate_shipping_items] => Array
                                (
                                )

                            [item_shipping_rates] => Array
                                (
                                )

                        )

                )

            [tax] => Array
                (
                    [name] => VAT
                    [rate] => 20.0000
                    [internal_rate] => 20.0000
                    [location] => Array
                        (
                            [0] => Array
                                (
                                    [location_id] => 0
                                    [zone_id] => 0
                                    [type_id] => 0
                                    [parent_id] => 0
                                    [name] => 
                                )

                        )

                    [data] => Array
                        (
                            [item_total_tax] => 0
                            [shipping_tax] => 0
                            [item_discount_tax] => 0
                            [summary_discount_tax] => 0
                            [reward_voucher_tax] => 0
                            [surcharge_tax] => 0
                            [cart_tax] => 0
                            [cart_taxable_value] => 0
                            [cart_non_taxable_value] => 0
                        )

                )

            [discounts] => Array
                (
                    [codes] => Array
                        (
                        )

                    [manual] => Array
                        (
                        )

                    [active_items] => Array
                        (
                        )

                    [active_summary] => Array
                        (
                        )

                    [reward_vouchers] => Array
                        (
                        )

                    [data] => Array
                        (
                            [item_discount_savings] => 0
                            [summary_discount_savings] => 0
                            [reward_vouchers] => 0
                            [void_reward_point_items] => Array
                                (
                                )

                            [excluded_discounts] => Array
                                (
                                )

                        )

                )

            [surcharges] => Array
                (
                )

            [configuration] => Array
                (
                    [id] => 1
                    [order_number_prefix] => 
                    [order_number_suffix] => 
                    [increment_order_number] => 1
                    [minimum_order] => 0
                    [quantity_decimals] => 0
                    [increment_duplicate_item_quantity] => 1
                    [quantity_limited_by_stock] => 1
                    [remove_no_stock_items] => 
                    [auto_allocate_stock] => 1
                    [save_banned_shipping_items] => 
                    [weight_type] => gram
                    [weight_decimals] => 0
                    [display_tax_prices] => 1
                    [price_inc_tax] => 1
                    [multi_row_duplicate_items] => 
                    [dynamic_reward_points] => 1
                    [reward_point_multiplier] => 10.0000
                    [reward_voucher_multiplier] => 0.0100
                    [reward_point_to_voucher_ratio] => 250
                    [reward_point_days_pending] => 14
                    [reward_point_days_valid] => 365
                    [reward_voucher_days_valid] => 365
                    [custom_status_1] => 
                    [custom_status_2] => 
                    [custom_status_3] => 
                    [cart_data_id] => 
                    [order_number] => 
                )

        )

)

cart_contents()

Returns the cart item and summary array.


Library and Requirements

Available via the lite, standard and admin libraries.

Does not require any database tables to be enabled.

Function Parameters
cart_contents(inc_discount, format, internal_value) Help
Name Data Type Required Default Description
inc_discount bool No FALSE Define whether the returned value should include any active discount.
format bool No TRUE Define whether to format the returned value.
internal_value bool No FALSE Defines whether to return the value using the carts internal currency instead of the users current currency.
How it Works

The function acts as a wrapper calling both the 'cart_items()' and 'cart_summary()' functions, which in turn calls many other item and summary functions that are available via the lite library.

Return Values

Failure:n/a

Success:array

Examples
Note: The returned example values below are displaying live data from the current cart session data.
cart_contents(TRUE, TRUE, FALSE) Return the current item and summary cart data array, including any set discounts. Show / Hide Array
Array
(
    [items] => Array
        (
        )

    [summary] => Array
        (
            [item_summary_total] => £0.00
            [item_summary_savings_total] => £0.00
            [shipping_total] => £0.00
            [item_shipping_total] => £0.00
            [summary_savings_total] => £0.00
            [savings_total] => £0.00
            [reward_voucher_total] => £0.00
            [surcharge_total] => £0.00
            [tax_total] => £0.00
            [total] => £0.00
            [total_rows] => 0
            [total_items] => 0
            [total_weight] => 0g
            [total_reward_points] => 0
        )

)
cart_contents(TRUE, TRUE, TRUE) Return the internal item and summary cart data array, including any set discounts. Show / Hide Array
Array
(
    [items] => Array
        (
        )

    [summary] => Array
        (
            [item_summary_total] => £0.00
            [item_summary_savings_total] => £0.00
            [shipping_total] => £0.00
            [item_shipping_total] => £0.00
            [summary_savings_total] => £0.00
            [savings_total] => £0.00
            [reward_voucher_total] => £0.00
            [surcharge_total] => £0.00
            [tax_total] => £0.00
            [total] => £0.00
            [total_rows] => 0
            [total_items] => 0
            [total_weight] => 0g
            [total_reward_points] => 0
        )

)