Squiz Matrix
4.12.2
|
Public Member Functions | |
Ecommerce_Cart_Processor ($checkout_id=0) | |
setCartContainer (&$cart) | |
initialiseCart () | |
clearCart () | |
& | getItem ($assetid) |
& | getCart () |
getTotal ($taxation_cost=0.0, $taxation_rate=0.0) | |
getGrandTotalExDelivery ($taxation_rate, $remove_tax, $flat_charges) | |
getFlatChargesTotal ($flat_charges) | |
getTotalDeliveryCosts ($grand_total) | |
getTotalTax ($taxation_rate=0.0) | |
_calculateItemCosts ($cost, $taxation_rate, $has_tax) | |
getCount () | |
getUniqueCount () | |
addItem ($assetid, $quantity=1) | |
updateItem ($assetid, $quantity) | |
removeItem ($assetid, $quantity=NULL) | |
hashCart () | |
printReceipt ($taxation_name='GST', $taxation_rate=0, $flat_charges=Array(), $remove_tax=FALSE, $currency_symbol='$', $float_precision=2, $refund_info='') | |
printCustomisedReceipt (&$contents_bodycopy, &$format_bodycopy, $taxation_name='GST', $taxation_rate=0, $flat_charges=Array(), $remove_tax=FALSE, $currency_symbol='$', $float_precision=2) | |
getCartXml ($taxation_name='GST', $taxation_rate=0, $flat_charges=Array(), $remove_tax=FALSE, $currency_symbol='$', $float_precision=2) | |
validateCart () | |
Data Fields | |
$cart = NULL | |
+-----------------------------------------------------------------—+ | This MySource Matrix CMS file is Copyright (c) Squiz Pty Ltd | | ABN 77 084 670 600 | +-----------------------------------------------------------------—+ | IMPORTANT: Your use of this Software is subject to the terms of | | the Licence provided in the file licence.txt. If you cannot find | | this file please contact Squiz (www.squiz.com.au) so we may provide| | you a copy. | +-----------------------------------------------------------------—+
Definition at line 33 of file ecommerce_cart_processor.inc.
_calculateItemCosts | ( | $cost, | |
$taxation_rate, | |||
$has_tax | |||
) |
Gets an individual item's tax cost
float | $cost | cost of the item |
float | $taxation_rate | tax value |
boolean | $has_tax | whether this cost already includes tax |
Definition at line 355 of file ecommerce_cart_processor.inc.
addItem | ( | $assetid, | |
$quantity = 1 |
|||
) |
Adds an item(s) to the cart
If an item already exists in the cart, add the quantity to the existing quantity Use addItem() for blindly adding items, rather than using updateItem() Returns true if the cart was updated
string | $assetid | The assetid of the item to add |
int | $quantity | The quantity to add |
Definition at line 423 of file ecommerce_cart_processor.inc.
clearCart | ( | ) |
Unsets the contents of this particular cart
Definition at line 96 of file ecommerce_cart_processor.inc.
Ecommerce_Cart_Processor | ( | $checkout_id = 0 | ) |
Constructor
Definition at line 42 of file ecommerce_cart_processor.inc.
& getCart | ( | ) |
Returns the contents of the cart in the following format:
Array( 'assetid' => Array( 'quantity' => quantity, // the number of items in the cart 'price' => value, // the cost of the item at the time of purchase 'name' => name, // the name of the asset 'taxable' => boolean // whether to calculate tax for this item 'value_has_tax' => boolean // whether this item already has tax included in the price ), )
Definition at line 145 of file ecommerce_cart_processor.inc.
getCartXml | ( | $taxation_name = 'GST' , |
|
$taxation_rate = 0 , |
|||
$flat_charges = Array() , |
|||
$remove_tax = FALSE , |
|||
$currency_symbol = '$' , |
|||
$float_precision = 2 |
|||
) |
Get the XML representation of this cart to store in the order_xml attribute of Ecommerce Order asset
string | $taxation_name | name of tax |
int | $taxation_rate | tax value (0.1 is 10%, 0.2 is 20%) |
array | $flat_charges | flat charges Array('Name' => 'Price') |
boolean | $remove_tax | whether to remove tax from taxed products, i.e. if country is not defined as taxable |
string | $currency_symbol | symbol to use as the currency for all prices |
int | $float_precision | precision of the floating numbers used for prices |
Definition at line 936 of file ecommerce_cart_processor.inc.
getCount | ( | ) |
Return the count of all the items currently in this cart
Definition at line 382 of file ecommerce_cart_processor.inc.
getFlatChargesTotal | ( | $flat_charges | ) |
Returns the total cost of all flat charges.
array | $flat_charges | Flat charges Array('Name' => 'Price') |
Definition at line 229 of file ecommerce_cart_processor.inc.
getGrandTotalExDelivery | ( | $taxation_rate, | |
$remove_tax, | |||
$flat_charges | |||
) |
Returns the grand total of the cart. Includes all tax considerations, all flat charges. Does not include any delivery fees, this must be calculated separately.
float | $taxation_rate | Taxation rate of each item |
boolean | $remove_tax | Whether to remove tax from taxed products, i.e. if country is not defined as taxable |
array | $flat_charges | Flat charges Array('Name' => 'Price') |
Definition at line 205 of file ecommerce_cart_processor.inc.
& getItem | ( | $assetid | ) |
Returns the details of one item in the following format:
Array( 'quantity' => quantity, // the number of items in the cart 'price' => value, // the cost of the item at the time of purchase )
string | $assetid | the asset to retrieve from the cart |
Definition at line 117 of file ecommerce_cart_processor.inc.
getTotal | ( | $taxation_cost = 0.0 , |
|
$taxation_rate = 0.0 |
|||
) |
Returns the sum-total of all the items currently in this cart If taxation rate is specified then it will adjust product prices accordingly. You need this parameter if you are charging tax on your products and you want accurate sub-totals. The returned total does not include any delivery fees or flat charges.
float | $taxation_cost | Taxation cost contains the total cost of tax |
float | $taxation_rate | Taxation rate of each item |
Definition at line 167 of file ecommerce_cart_processor.inc.
getTotalDeliveryCosts | ( | $grand_total | ) |
Returns the total delivery costs for this cart.
float | $grand_total | Grand total of contents of cart |
Definition at line 249 of file ecommerce_cart_processor.inc.
getTotalTax | ( | $taxation_rate = 0.0 | ) |
Return the sum of the taxation cost of all the items currently in this cart
float | $taxation_rate | tax value |
Definition at line 325 of file ecommerce_cart_processor.inc.
getUniqueCount | ( | ) |
Return the count of the unique items currently in this cart
Definition at line 403 of file ecommerce_cart_processor.inc.
hashCart | ( | ) |
Takes the contents of the cart and hashes it Used by the ecom checkout form Returns the hashed form of the cart
Definition at line 617 of file ecommerce_cart_processor.inc.
initialiseCart | ( | ) |
Prepare cart for first use, if the relevant session vars aren't there
Return 1 if the session var had to be created (ie. cart needed to be init'ed), or 0 if the cart already existed (-1 is reserved for an error condition)
Definition at line 76 of file ecommerce_cart_processor.inc.
printCustomisedReceipt | ( | & | $contents_bodycopy, |
& | $format_bodycopy, | ||
$taxation_name = 'GST' , |
|||
$taxation_rate = 0 , |
|||
$flat_charges = Array() , |
|||
$remove_tax = FALSE , |
|||
$currency_symbol = '$' , |
|||
$float_precision = 2 |
|||
) |
Prints out the contents of the Ecommerce Cart adhering to the Receipt Format bodycopy
object | &$contents_bodycopy | receipt contents bodycopy |
object | &$format_bodycopy | receipt format bodycopy |
string | $taxation_name | name of tax |
int | $taxation_rate | tax value (0.1 is 10%, 0.2 is 20%) |
array | $flat_charges | flat charges Array('Name' => 'Price') |
boolean | $remove_tax | whether to remove tax from taxed products, i.e. if country is not defined as taxable |
string | $currency_symbol | symbol to use as the currency for all prices |
int | $float_precision | precision of the floating numbers used for prices |
Definition at line 829 of file ecommerce_cart_processor.inc.
printReceipt | ( | $taxation_name = 'GST' , |
|
$taxation_rate = 0 , |
|||
$flat_charges = Array() , |
|||
$remove_tax = FALSE , |
|||
$currency_symbol = '$' , |
|||
$float_precision = 2 , |
|||
$refund_info = '' |
|||
) |
Prints out the contents of the Ecommerce Cart
string | $taxation_name | name of tax |
int | $taxation_rate | tax value (0.1 is 10%, 0.2 is 20%) |
array | $flat_charges | flat charges Array('Name' => 'Price') |
boolean | $remove_tax | whether to remove tax from taxed products, i.e. if country is not defined as taxable |
string | $currency_symbol | symbol to use as the currency for all prices |
int | $float_precision | precision of the floating numbers used for prices |
string | $refund_info | refund info to include if some product in cart are non-refundable |
Definition at line 644 of file ecommerce_cart_processor.inc.
removeItem | ( | $assetid, | |
$quantity = NULL |
|||
) |
Removes item(s) from the cart
Assumption: items were correctly added using the addItem() method and therefore, only valid items are found in the cart (because of the addItem() checking) Returns true if the cart was updated
string | $assetid | The assetid of the item to remove |
int | $quantity | The quantity of this item to remove - leave blank to remove all of that item |
Definition at line 570 of file ecommerce_cart_processor.inc.
setCartContainer | ( | & | $cart | ) |
Sets the container to use for the cart
object | &$cart | the cart to set the processor's cart to |
Definition at line 60 of file ecommerce_cart_processor.inc.
updateItem | ( | $assetid, | |
$quantity | |||
) |
Updates the quantity of an item(s) in the cart
Assumption: items were correctly added using the addItem() method and therefore, only valid items are found in the cart (because of the addItem() checking) Returns true if the cart was updated
string | $assetid | The assetid of the item to remove |
int | $quantity | The new quantity of this item |
Definition at line 526 of file ecommerce_cart_processor.inc.
validateCart | ( | ) |
Check the current cart and if the cart item does not exist, remove them from the cart
Definition at line 1081 of file ecommerce_cart_processor.inc.