Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Ecommerce_Cart_Processor Class Reference

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
 

Detailed Description

+-----------------------------------------------------------------—+ | 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. | +-----------------------------------------------------------------—+

Id:
ecommerce_cart_processor.inc,v 1.29.2.1 2012/10/04 00:29:24 ewang Exp

Definition at line 33 of file ecommerce_cart_processor.inc.

Member Function Documentation

_calculateItemCosts (   $cost,
  $taxation_rate,
  $has_tax 
)

Gets an individual item's tax cost

Parameters
float$costcost of the item
float$taxation_ratetax value
boolean$has_taxwhether this cost already includes tax
Returns
array public

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

Parameters
string$assetidThe assetid of the item to add
int$quantityThe quantity to add
Returns
boolean public

Definition at line 423 of file ecommerce_cart_processor.inc.

clearCart ( )

Unsets the contents of this particular cart

Returns
boolean public

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
               ),
)
Returns
array public

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

Parameters
string$taxation_namename of tax
int$taxation_ratetax value (0.1 is 10%, 0.2 is 20%)
array$flat_chargesflat charges Array('Name' => 'Price')
boolean$remove_taxwhether to remove tax from taxed products, i.e. if country is not defined as taxable
string$currency_symbolsymbol to use as the currency for all prices
int$float_precisionprecision of the floating numbers used for prices
Returns
void public

Definition at line 936 of file ecommerce_cart_processor.inc.

getCount ( )

Return the count of all the items currently in this cart

Returns
float public

Definition at line 382 of file ecommerce_cart_processor.inc.

getFlatChargesTotal (   $flat_charges)

Returns the total cost of all flat charges.

Parameters
array$flat_chargesFlat charges Array('Name' => 'Price')
Returns
float public

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.

Parameters
float$taxation_rateTaxation rate of each item
boolean$remove_taxWhether to remove tax from taxed products, i.e. if country is not defined as taxable
array$flat_chargesFlat charges Array('Name' => 'Price')
Returns
float public

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 )

Parameters
string$assetidthe asset to retrieve from the cart
Returns
array public

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.

Parameters
float$taxation_costTaxation cost contains the total cost of tax
float$taxation_rateTaxation rate of each item
Returns
float public

Definition at line 167 of file ecommerce_cart_processor.inc.

getTotalDeliveryCosts (   $grand_total)

Returns the total delivery costs for this cart.

Parameters
float$grand_totalGrand total of contents of cart
Returns
float public

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

Parameters
float$taxation_ratetax value
Returns
float public

Definition at line 325 of file ecommerce_cart_processor.inc.

getUniqueCount ( )

Return the count of the unique items currently in this cart

Returns
float public

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

Returns
string public

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)

Returns
int public

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

Parameters
object&$contents_bodycopyreceipt contents bodycopy
object&$format_bodycopyreceipt format bodycopy
string$taxation_namename of tax
int$taxation_ratetax value (0.1 is 10%, 0.2 is 20%)
array$flat_chargesflat charges Array('Name' => 'Price')
boolean$remove_taxwhether to remove tax from taxed products, i.e. if country is not defined as taxable
string$currency_symbolsymbol to use as the currency for all prices
int$float_precisionprecision of the floating numbers used for prices
Returns
void public

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

Parameters
string$taxation_namename of tax
int$taxation_ratetax value (0.1 is 10%, 0.2 is 20%)
array$flat_chargesflat charges Array('Name' => 'Price')
boolean$remove_taxwhether to remove tax from taxed products, i.e. if country is not defined as taxable
string$currency_symbolsymbol to use as the currency for all prices
int$float_precisionprecision of the floating numbers used for prices
string$refund_inforefund info to include if some product in cart are non-refundable
Returns
void public

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

Parameters
string$assetidThe assetid of the item to remove
int$quantityThe quantity of this item to remove - leave blank to remove all of that item
Returns
boolean public

Definition at line 570 of file ecommerce_cart_processor.inc.

setCartContainer ( $cart)

Sets the container to use for the cart

Parameters
object&$cartthe cart to set the processor's cart to
Returns
void public

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

Parameters
string$assetidThe assetid of the item to remove
int$quantityThe new quantity of this item
Returns
boolean public

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

Returns
void public

Definition at line 1081 of file ecommerce_cart_processor.inc.


The documentation for this class was generated from the following file: