SilverCommerce\ShoppingCart\ShoppingCartFactory
Factory to handle setting up and interacting with a ShoppingCart object.
Synopsis
class ShoppingCartFactory
extends OrderFactory
{
- // constants
- const TEST_COOKIE = "ShoppingCartFactoryTest";
- const COOKIE_NAME = "ShoppingCart.Key";
- // members
- private static string $estimate_class = ShoppingCartModel::class;
- private static string $controller = ShoppingCartController::class;
- private static boolean $check_stock_levels = false;
- private static boolean $cron_cleaner = false;
- private static integer $discount_limit = 1;
- private static boolean $use_cookies = false;
- // methods
- public ShoppingCart __construct()
- public Estimate getCurrent()
- public Session getSession()
- public ShoppingCart findOrMake()
- public null cleanOld()
- public boolean cookiesSupported()
- public ShoppingCartFactory delete()
- public ShoppingCartFactory write()
- public ShoppingCartFactory save()
Hierarchy
Extends
- SilverCommerce\OrdersAdmin\Factory\OrderFactory
Constants
Name | Value |
---|---|
TEST_COOKIE | "ShoppingCartFactoryTest" |
COOKIE_NAME | "ShoppingCart.Key" |
Members
private
- $check_stock_levels
—
string
Should the cart globally check for stock levels on items added? Using this setting will ignore individual "Stocked" settings on Shopping Cart Items. - $controller
—
string
The default class that is used by the factroy - $cron_cleaner
—
boolean
whether or not the cleaning task should be left to a cron job - $discount_limit
—
int
Allow the user to add multiple discounts to the cart 0 = unlimited - $estimate_class
—
string
The default class that is used by the factroy
Methods
public
- __construct() — Setup the shopping cart and return an instance
- cleanOld() — Run the task to clean old shopping carts
- delete() — Destroy current shopping cart
- findOrMake() — Either find an existing cart, or create a new one.
- getCurrent() — Legacy get current method
- getSession() — Get the current session from the current request
- save() — Shortcut for write
- write() — Save the current shopping cart, by writing it to the DB and generating a cookie/session (if user not logged in).