SilverShop\Page\Product
This is a standard Product page-type with fields like Price, Weight, Model and basic management of groups.
It also has an associated Product_OrderItem class,
an extension of OrderItem, which is the mechanism
that links this page type class to the rest of the
eCommerce platform. This means you can add an instance
of this page type to the shopping cart.
Synopsis
class Product
extends Page
implements
Buyable
{
- // members
- private static array $db = ;
- private static array $has_one = ;
- private static array $owns = ;
- private static array $many_many = ;
- private static array $defaults = ;
- private static array $casting = ;
- private static array $summary_fields = ;
- private static array $searchable_fields = ;
- private static string $table_name = 'SilverShop_Product';
- private static string $singular_name = 'Product';
- private static string $plural_name = 'Products';
- private static string $icon = 'silvershop/core: client/dist/images/icons/package.gif';
- private static $default_parent = ProductCategory::class;
- private static string $default_sort = '"Title" ASC';
- private static boolean $global_allow_purchase = true;
- private static boolean $allow_zero_price = false;
- private static $order_item = OrderItem::class;
- private static string $weight_unit = 'kg';
- private static string $length_unit = 'cm';
- private static array $indexes = ;
- // methods
- public FieldList getCMSFields()
- public void fieldLabels()
- private array getCategoryOptions()
- private array getCategoryOptionsNoParent()
- public array getCategoryIDs()
- public DataList getCategories()
- public boolean canPurchase()
- public DBBoolean IsPurchaseable()
- public boolean IsInCart()
- public OrderItem Item()
- public void createItem()
- public void sellingPrice()
- public void getPrice()
- public void setPrice()
- public void isOrphaned()
- public Image Image()
- public string addLink()
- public string removeLink()
- public string removeallLink()
- public string getFormClass()
Hierarchy
Tasks
Line | Task |
---|---|
408 | this is not ideal, because prices manipulations will not happen in a known order |
Members
private
- $allow_zero_price
- $casting
- $db
- $default_parent
- $default_sort
- $defaults
- $global_allow_purchase
- $has_one
- $icon
- $indexes
- $length_unit
- $many_many
- $order_item
- $owns
- $plural_name
- $searchable_fields
- $singular_name
- $summary_fields
- $table_name
- $weight_unit
Methods
private
- getCategoryOptions() — Helper function for generating list of categories to select from.
- getCategoryOptionsNoParent() — Helper function for generating a list of additional categories excluding the main parent.
public
- Image() — If the product does not have an image, and a default image is defined in SiteConfig, return that instead.
- IsInCart() — Returns if the product is already in the shopping cart.
- IsPurchaseable() — Returns the purchaseable flag as `DBBoolean`. Useful for templates or summaries.
- Item() — Returns the order item which contains the product
- addLink() — Link to add this product to cart.
- canPurchase() — Conditions for whether a product can be purchased: - global allow purchase is enabled - product AllowPurchase field is true - if variations, then one of them needs to be purchasable - if not variations, selling price must be above 0
- createItem()
- fieldLabels() — Add missing translations to the fieldLabels
- getCMSFields() — Add product fields to CMS
- getCategories() — Get all categories that this product appears in.
- getCategoryIDs() — Get ids of all categories that this product appears in.
- getFormClass() — Get the form class to use to edit this product in the frontend
- getPrice() — This value is cased to Currency in temlates.
- isOrphaned() — Allow orphaned products to be viewed.
- removeLink() — Link to remove one of this product from cart.
- removeallLink() — Link to remove all of this product from cart.
- sellingPrice() — The raw retail price the visitor will get when they add to cart. Can include discounts or markups on the base price.
- setPrice()