\ShoppingCartItem
Single item class that needs to be added to a shopping cart. This class is used to provide a structure of how shopping cart items can be interacted with.
This is a base class, you can add your own item class and then update
ShoppingCart.item_class in your config file.
Synopsis
class ShoppingCartItem
extends ViewableData
{
- // members
- private static string $stock_param = "StockLevel";
- public String $Key;
- public String $Title;
- public String $Content;
- public Image $Image;
- public Float $BasePrice = 0;
- public Int $Quantity = 1;
- public Float $Weight = 1;
- public Float $TaxRate = 0;
- public String $ClassName;
- public Int $ID;
- public String $StockID;
- public Boolean $Stocked = false;
- public Boolean $Locked = false;
- public Boolean $Deliverable = true;
- public array $CustomisationArray = ;
- private static array $casting = ;
- // methods
- public Currency getPrice()
- public Float getDiscount()
- public Float getTotalDiscount()
- public Currency getSubTotal()
- public Currency getTotalPrice()
- public Currency getTax()
- public Currency getTotalTax()
- public void getCustomisations()
- public DataObject FindStockItem()
- public null checkStockLevel()
Hierarchy
Extends
- ViewableData
Members
private
- $casting
-
$stock_param
The param used on a related product to track Stock Levels
public
- $BasePrice
—
Float
Base price of this item (used to calculate actual price) - $ClassName
—
String
Type of stock item that this item is matched against - $Content
—
String
Description of this object - $CustomisationArray
—
array
A list of customisations that has been made to this item. This will be rendered into the template ansd requires customisations to have the following keys by default: - $Deliverable
—
Boolean
Is this a product that can be delivered? If the cart contains only non deliverable items, shipping and delivery options wont be factored into the checkout. - $ID
—
Int
ID of the object matched - $Image
—
Image
Image attached to this object - $Key
—
String
ID used to detect this item - $Locked
—
Boolean
Is this a locked item? Locked items cannot be changed in the shopping cart. - $Quantity
—
Int
Number or items in the cart - $StockID
—
String
Unique identifier of the item - $Stocked
—
Boolean
Is this item stocked (and as such reduces in stock when bought) If ShoppingCart.check_stock_levels is set to true, then this is ignored. - $TaxRate
—
Float
Rate of tax for this item (e.g. 20.00 for 20%) - $Title
—
String
Title of the item - $Weight
—
Float
Weight of this item
Methods
public
- FindStockItem() — Find our original stock item (useful for adding links back to the original product)
- checkStockLevel() — Check stock levels for this item.
- getCustomisations()
- getDiscount() — Find the total discount amount for this line item
- getPrice() — Find the cost of all items in this line, without any tax.
- getSubTotal() — Generate the subtotal for this line item (without tax)
- getTax() — Find the tax cost for one instance of this item.
- getTotalDiscount() — Find the total discount amount for this line item
- getTotalPrice() — Generate the total price, accounting for price, quantity, discount and tax
- getTotalTax() — Find the tax cost for all of the items in this line.