\ProductStockExtension
An extension which can be applied to either the shop {@link Product} or {@link ProductVariation} class for including stock values in the CMS.
Stock is held within a .
Synopsis
class ProductStockExtension
extends DataExtension
{
- // members
- private static array $db = ;
- private static boolean $allow_out_of_stock_purchase = false;
- // methods
- public void updateCMSFields()
- public DataList getStockForEachWarehouse()
- public ProductWarehouseStock getStockForWarehouse()
- public boolean hasAvailableStock()
- public int getTotalStockInCarts()
- public boolean hasWarehouseWithUnlimitedStock()
- public DataList getWarehouseStock()
- public boolean getWarehouseStockQuantity()
- public boolean canPurchase()
- private boolean hasVariations()
- public string getStockBaseIdentifier()
- public decrementStock()
Hierarchy
Extends
- DataExtension
Tasks
Line | Task |
---|---|
255+ |
Members
private
- $allow_out_of_stock_purchase
- $db
Methods
private
- hasVariations() — As stock can either be managed on a product or a product variation level, return whether this object has variations enabled.
public
- canPurchase()
- decrementStock() — Decrements the stock for a given order item. Potentially will reduce the stock across multiple warehouses. If any of the warehouses have unlimited stock, they're used a fallback.
- getStockBaseIdentifier()
- getStockForEachWarehouse() — Returns a list of all the warehouses with a value in use for the stock GridField instance. Will create records for products that don't have them.
- getStockForWarehouse() — Returns the ProductWarehouseStock for this product goven a specific warehosue.
- getTotalStockInCarts() — Returns the number of items that are currently in other people's carts which should be considered 'held'.
- getWarehouseStock()
- getWarehouseStockQuantity() — Returns the number of available stock. Note this cannot be used to determine if stock is available as a warehouse may have an unlimited (null) value for stock.
- hasAvailableStock()
- hasWarehouseWithUnlimitedStock() — Returns whether a warehouse has unlimited stock for this product
- updateCMSFields()