WTCart Class
The class used to store and order before it reaches the checkout
example:
$cart = new WTCart();
Item Index
Methods
clear
()
Clear the cart
getDiscount
()
Int
Return the discount for the cart
Returns:
getFreight
-
args
Return the freight for the cart
Parameters:
-
argsArrayAn associative array containing keys for: country, postcode, weight, quantity, order value, Freight Carrier ID
Returns:
getOrder
()
WTOrder
Return the current order node object
Returns:
getQuantity
-
id
Return the quantity of an item in the cart
Parameters:
-
idStringThe id of the item in the cart
Returns:
getTotal
()
Int
Return the total price of all the items in the cart (not including discount)
Returns:
getTotalItemCount
()
Int
Return the total number of distinct items in the cart
Returns:
getTotalQuantity
()
Int
Return the total number of items in the cart
Returns:
getTotalWeight
()
Int
Return the total weight of all items in the cart (in grams)
Returns:
registerCartDiscountFunction
-
function
Register a custom function to calculate the discount to apply to the cart
The custom function should return the discount in dollars and cents
Parameters:
-
functionFunctionThe custom function to call when calculating discount
setFromRequest
-
[addToCurrent=false] -
[requestData=null]
Add items to the cart from a post request
Parameters:
-
[addToCurrent=false]Object optionalIf an item is already in the cart, add to its quantity instead of replacing it
-
[requestData=null]Object optionalIf set, use this data instead of the data from the post request
