A PHP Error was encountered

Severity: Warning

Message: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'AWST/8.0/no DST' instead

Filename: config/flexi_cart.php

Line Number: 1050

A PHP Error was encountered

Severity: Warning

Message: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'AWST/8.0/no DST' instead

Filename: config/flexi_cart.php

Line Number: 1050

User Guide | Saving Order Data

xxx

Saving Order Data

Order Function Index | Order Config | Get Order Helper Data | Order Admin Data
Save Order Data to Database

save_order() | resave_order()

Help with Saving Order 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.

save_order()

Saves the content of the cart as an order.


Library and Requirements

Available via the admin library only.

Requires all order database tables to be enabled.

Function Parameters
save_order(custom_summary_data, custom_item_data, order_number) Help
Name Data Type Required Default Description
custom_summary_data array No FALSE Sets any additional summary data to be saved to the order summary table, that is not automatically saved by the function.
The data must be a single-dimensional array, with each array key matching the order summary table column name.
custom_item_data array No FALSE Sets any additional item data to be saved to the order details table, that is not automatically saved by the function.
The data must be a multi-dimensional array. The root array key values must be the cart row id of the data being saved.
The sub-array keys must then match the order details table column name.
order_number string | int No FALSE Sets a specific order number for the new order, by default, a random number is generated.
How it Works

The function first checks whether there are any items in the cart that are banned from being shipped to the shipping location. If the carts config settings do not permit banned items to be saved in an order, the function immediately stops.

A database transaction is then started that can rollback any saved order details if an error occurs whilst saving the cart data.

The function then proceeds to check whether a custom order number was submitted and validates that no other orders exist with this number, if the number exists, the function stops returning an error message. If no custom order number is submitted, then an order number is automatically generated.

The active order summary table columns defined via the config file are then looped through and are matched with any data from the 'custom_summary_data' array, and with the carts session summary data. The matched data is then added to an array that is used to save the cart summary data to the order summary table.

Once the summary data is saved, the function prepares the cart item data to be saved to the order details table.

If defined via the cart config settings, any items banned from being shipped are removed from the cart data so they are not saved. The cart then loops through the order detail table columns and matches any data from the 'custom_item_data' array, and from the carts sessions item data. The matched data is then added to an array that is used to save the cart item data to the order details table.

Then if defined to do so, the cart will auto allocate item stock quantities and discount usages from the database tables.

Notes

When an order is saved, unless specified otherwise via the 'custom_summary_data' array, the status of the order will be set to the status defined by the 'save_default' column (Defined by a value of 1) in the order status table.


Currency and tax rate values are saved as a number without and symbols prefixed or suffixed to them.

This function should not be used to resave an existing saved order that has been reloaded into the carts session. Instead, use the 'resave_order()' function.

Return Values

Failure:FALSE | An error message will be set.

Success:TRUE | A status message will be set.

Example
// Example #1 : Saving data only available from the cart session.

$this->flexi_cart_admin->save_order();
// Example #2 : Saving cart session data and custom data, whilst defining a specific order number.

// Setting custom summary data using a single-dimensional array.
$custom_summary_data = array(
'order_summary_tbl_column_1' => 'example_summary_value_1',
'order_summary_tbl_column_2' => 'example_summary_value_2'
);

// Setting custom item data using a multi-dimensional array.
// Note: The cart row id of each item must be used to identify each items data.
$custom_item_data = array(
'38b3eff8baf56627478ec76a704e9b52' => array(
	'order_detail_tbl_column_1' => 'item_#1_data_1',
	'order_detail_tbl_column_2' => 'item_#1_data_2'
),
'c45147dee729311ef5b5c3003946c48f' => array(
	'order_detail_tbl_column_1' => 'item_#2_data_1',
	'order_detail_tbl_column_2' => 'item_#2_data_2'
)
);

// Setting a specific order number.
$order_number = 'example_order_number';

$this->flexi_cart_admin->save_order($custom_summary_data, $custom_item_data, $order_number);

resave_order()

Resaves the content of the cart over an existing order in the database.

The difference between the 'resave_order()' and the 'update_db_order_summary()' and 'update_db_order_details()' functions is that 'resave_order()' automatically saves a cart using data from a users current session, whereas the other functions are updated via submitting data.


Library and Requirements

Available via the admin library only.

Requires all order database tables to be enabled.

Function Parameters
resave_order(custom_summary_data, custom_item_data) Help
Name Data Type Required Default Description
custom_summary_data array No FALSE Sets any additional summary data to be saved to the order summary table, that is not automatically saved by the function.
The data must be a single-dimensional array, with each array key matching the order summary table column name.
custom_item_data array No FALSE Sets any additional item data to be saved to the order details table, that is not automatically saved by the function.
The data must be a multi-dimensional array. The root array key values must be the cart row id of the data being saved.
The sub-array keys must then match the order details table column name.
How it Works

The functions works in a very similar way to the 'save_order()' function, but with a key difference.

The function can only be used to save data from a previously saved order, if the original order does not exist in the order tables, the order cannot be resaved. The function checks whether the original order exists by matching the cart sessions current order number with existing records in the order summary table.

For data from a previously saved order to be in the carts current session data, it must be loaded from the saved orders cart data, that if enabled is available from the 'cart data' table. This data is loaded using the 'load_cart_data()' function.

Notes

When an order is resaved, unless specified otherwise via the 'custom_summary_data' array, the status of the order will be set to the status defined by the 'resave_default' column (Defined by a value of 1) in the order status table.


If the item stock table and the 'item_stock_quantity' column in the order details table are enabled, the cart will save the stock quantity of an item at the time that the order was placed. The item quantity that has been ordered is not deducted from the saved stock quantity.


Currency and tax rate values are saved as a number without and symbols prefixed or suffixed to them.

Return Values

Failure:FALSE | An error message will be set.

Success:TRUE | A status message will be set.

Example
// Example #1 : Saving data only available from the cart session.

$this->flexi_cart_admin->resave_order();
// Example #2 : Saving cart session data and custom data, whilst defining a specific order number.

// Setting custom summary data using a single-dimensional array.
$custom_summary_data = array(
'order_summary_column_1' => 'example_summary_value_1',
'order_summary_column_2' => 'example_summary_value_2'
);

// Setting custom item data using a multi-dimensional array.
// Note: The cart row id of each item must be used to identify each items data.
$custom_item_data = array(
'38b3eff8baf56627478ec76a704e9b52' => array(
	'order_detail_column_1' => 'item_#1_data_1',
	'order_detail_column_2' => 'item_#1_data_2'
),
'c45147dee729311ef5b5c3003946c48f' => array(
	'order_detail_column_1' => 'item_#2_data_1',
	'order_detail_column_2' => 'item_#2_data_2'
)
);

$this->flexi_cart_admin->resave_order($custom_summary_data, $custom_item_data);
Set Order Data Functions | User Guide | flexi cart | A Shopping Cart Library for CodeIgniter

A PHP Error was encountered

Severity: Warning

Message: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'AWST/8.0/no DST' instead

Filename: includes/head.php

Line Number: 3

2015, Rob Hussey, All Rights Reserved"/>