SilverCommerce\OrdersAdmin\Factory\LineItemFactory
Factory that handles setting up line items based on submitted data
Synopsis
class LineItemFactory
{
- // constants
- const ITEM_CLASS = LineItem::class;
- const CUSTOM_CLASS = LineItemCustomisation::class;
- // members
- private static array $custom_map = ;
- private static boolean $force_check_stock = false;
- protected DataObject $item;
- protected Estimate $parent;
- protected DataObject $product;
- protected $quantity;
- protected bool $lock = false;
- protected array $customisations = ;
- protected string $product_stocked_param = "Stocked";
- protected string $product_stock_param = "StockLevel";
- protected string $product_deliverable_param = "Deliverable";
- // methods
- public LineItemFactory makeItem()
- public LineItemFactory update()
- public TaxRate findBestTaxRate()
- protected array getItemArray()
- public string getKey()
- protected DataObject createCustomisation()
- public bool checkStockLevel()
- public LineItemFactory write()
- public LineItemFactory delete()
- public DataObject getItem()
- public LineItemFactory setItem()
- public DataObject getProduct()
- public LineItemFactory setProduct()
- public array getCustomisations()
- public LineItemFactory setCustomisations()
- public int getQuantity()
- public LineItemFactory setQuantity()
- public bool getLock()
- public LineItemFactory setLock()
- public string getProductStockedParam()
- public LineItemFactory setProductStockedParam()
- public string getProductStockParam()
- public LineItemFactory setProductStockParam()
- public string getProductDeliverableParam()
- public LineItemFactory setProductDeliverableParam()
- public Estimate getParent()
- public LineItemFactory setParent()
Hierarchy
Uses
- SilverStripe\Core\Injector\Injectable
- SilverStripe\Core\Config\Configurable
Constants
Name | Value |
---|---|
ITEM_CLASS | LineItem::class |
CUSTOM_CLASS | LineItemCustomisation::class |
Members
private
- $custom_map
—
array
Data that will be added to a customisation - $force_check_stock
—
string
Should the stock stock levels be globally checked on items added? Using this setting will ignore individual product "Stocked" settings.
protected
- $customisations
—
array
List of customisation data that will need to be setup - $item
—
SilverStripe\ORM\DataObject
Current line item - $lock
—
SilverCommerce\OrdersAdmin\Factory\bool
Should this item be locked (cannot be updated, only removed)? (defaults to false) - $parent
—
SilverCommerce\OrdersAdmin\Model\Estimate
Parent estimate/invoice - $product
—
\SilverStripe\ORM\DataObject
DataObject that will act as the product - $product_deliverable_param
—
string
The name of the param used on product to determin if item is deliverable - $product_stock_param
—
string
The name of the param used on product to track Stock Level. - $product_stocked_param
—
string
The name of the param used on product to determin if stock level should be checked. - $quantity
—
int
The number of product to add/update for this line item
Methods
protected
- createCustomisation() — Create a customisation object to be added to the current order
- getItemArray() — Get an array of data for the line item
public
- checkStockLevel() — Check the available stock for the current line item. If stock checking is disabled then returns true
- delete() — Remove the current item from the DB
- findBestTaxRate() — Find the best possible tax rate for a line item. If the item is linked to an invoice/estimate, then see if there is a Country and Region set, else use product default
- getCustomisations() — Get list of customisation data that will need to be setup
- getItem() — Get current line item
- getKey() — Shortcut to get the item key from the item in this factory
- getLock() — Get should this item be locked (cannot be updated, only removed)?
- getParent() — Get current parent estimate
- getProduct() — Get dataObject that will act as the product
- getProductDeliverableParam() — Get the name of the param used on product to determin if item is deliverable
- getProductStockParam() — Get the name of the param used on product to track Stock Level.
- getProductStockedParam() — Get name of stocked parameter
- getQuantity() — Get the number of products to add/update for this line item
- makeItem() — Either find an existing line item (based on the submitted data), or return a new one.
- setCustomisations() — Set list of customisation data that will need to be setup
- setItem() — Set current line item
- setLock() — Set should this item be locked (cannot be updated, only removed)?
- setParent() — Set current parent estimate
- setProduct() — Set dataObject that will act as the product
- setProductDeliverableParam() — Set the name of the param used on product to determin if item is deliverable
- setProductStockParam() — Set the name of the param used on product to track Stock Level.
- setProductStockedParam() — Get name of stocked parameter
- setQuantity() — Set the number of products to add/update for this line item
- update() — Update the current line item
- write() — Write the current line item