\ShoppingCart
Holder for items in the shopping cart and interacting with them, as well as rendering these items into an interface that allows editing of items,
- Author: i-lateral (http://www.i-lateral.com)
Synopsis
class ShoppingCart
extends Controller
{
- // members
- private static string $url_segment = 'checkout/cart';
- private static string $class_name = "ShoppingCart";
- private static string $item_class = "ShoppingCartItem";
- private static boolean $check_stock_levels = false;
- private static array $allowed_actions = ;
- private static $title;
- protected ArrayList $items;
- protected Discount $discount;
- protected Postage $postage;
- private static boolean $show_discount_form = false;
- private static array $casting = ;
- // methods
- public void getClassName()
- public void getTitle()
- public void getMetaTitle()
- public void getShowDiscountForm()
- public void getItems()
- public void getDiscount()
- public void setDiscount()
- public string Link()
- public ShoppingCart setAvailablePostage()
- public Boolean isCollection()
- public Boolean isDeliverable()
- public static ShoppingCart get()
- public void __construct()
- public string getViewCartButton()
- public void index()
- public Redirect remove()
- public void emptycart()
- public void usediscount()
- public Redirect setdeliverytype()
- public void add()
- public void update()
- public void removeAll()
- public void save()
- public void clear()
- public boolean ShowTax()
- public Decimal getTotalWeight()
- public Int getTotalItems()
- public Currency getSubTotalCost()
- public Currency getPostageCost()
- public Currency getDiscountAmount()
- public Currency getTaxCost()
- public Currency getTotalCost()
- public Form CartForm()
- public Form DiscountForm()
- public static boolean IncludesTax()
- public Form PostageForm()
- public void doUpdate()
- public void doAddDiscount()
- public void doSetPostage()
Hierarchy
Extends
- Controller
Members
private
- $allowed_actions
- $casting
- $check_stock_levels
—
string
Should the cart globally check for stock levels on items added? Using this settings will ignore individual "Stocked" settings on Shopping Cart Items. - $class_name
—
string
Name of the current controller. Mostly used in templates. - $item_class
—
string
Name of the current controller. Mostly used in templates. - $show_discount_form
—
boolean
Show the discount form on the shopping cart - $title
—
string
Overwrite the default title for this controller which is taken from the translation files. This is used for Title and MetaTitle variables in templates. - $url_segment
—
string
URL Used to access this controller
protected
Methods
public
- __construct()
- CartForm() — Form responsible for listing items in the shopping cart and allowing management (such as addition, removal, etc)
- DiscountForm() — Form that allows you to add a discount code which then gets added to the cart's list of discounts.
- IncludesTax() — Method that allows us to define in templates if we should show price including tax, or excluding tax
- Link() — Get the link to this controller
- PostageForm() — Form responsible for estimating shipping based on location and postal code
- ShowTax() — Shortcut to checkout config, to allow us to access it via templates
- add() — Add an item to the shopping cart. To make this process as generic as possible, we require that an object is submitted. This object can have any params, but by default we usually use:
- clear() — Clear the shopping cart object and destroy the session. Different to empty, as that retains the session.
- doAddDiscount() — Action that will find a discount based on the code
- doSetPostage() — Method that deals with get postage details and setting the postage
- doUpdate() — Action that will update cart
- emptycart() — Action that will clear shopping cart and associated sessions
- get() — Shortcut for ShoppingCart::create, exists because create() doesn't seem quite right.
- getClassName() — Getters and setters
- getDiscount()
- getDiscountAmount() — Find the total discount based on discount items added.
- getItems()
- getMetaTitle()
- getPostageCost() — Get the cost of postage
- getShowDiscountForm()
- getSubTotalCost() — Find the cost of all items in the cart, without any tax.
- getTaxCost() — Find the total cost of tax for the items in the cart, as well as shipping (if set)
- getTitle()
- getTotalCost() — Find the total cost of for all items in the cart, including tax and shipping (if applicable)
- getTotalItems() — Find the total quantity of items in the shopping cart
- getTotalWeight() — Find the total weight of all items in the shopping cart
- getViewCartButton() — Return a rendered button for the shopping cart
- index() — Default acton for the shopping cart
- isCollection() — Are we collecting the current cart? If click and collect is disabled then this returns false, otherwise checks if the user has set this via a session.
- isDeliverable() — Determine if the current cart contains delivereable items.
- remove() — Remove a product from ShoppingCart Via its ID. This action expects an ID to be sent through the URL that matches a specific key added to an item in the cart
- removeAll() — Empty the shopping cart object of all items.
- save() — Save the current products list and postage to a session.
- setAvailablePostage() — Set postage that is available to the shopping cart based on the country and zip code submitted
- setDiscount()
- setdeliverytype() — Set the current session to click and collect (meaning no shipping)
- update() — Find an existing item and update its quantity
- usediscount() — Action used to add a discount to the users session via a URL.