PurchasableInterface

Type
Interface
Namespace
craft\commerce\base
Implemented by
craft\commerce\base\Purchasable, craft\commerce\elements\Donation, craft\commerce\elements\Variant, craft\commerce\test\mockclasses\Purchasable
Since
2.0

Interface Purchasable

View source

# Public Methods

Method Description
afterOrderComplete() Runs any logic needed for this purchasable after it was on an order that was just completed (not when an order was paid, although paying an order will complete it).
getDescription() Returns your element's title or any additional descriptive information.
getId() Returns the element’s ID.
getIsAvailable() Returns whether the purchasable is currently available for purchase.
getIsPromotable() Returns whether this purchasable can be subject to discounts or sales.
getIsShippable() Returns whether this purchasable can be shipped and whether it is counted in shipping calculations.
getIsTaxable() Returns whether this purchasable is exempt from taxes.
getLineItemRules() Returns any validation rules this purchasable required the line item to have.
getPrice() Returns the base price the item will be added to the line item with.
getPromotionRelationSource() Returns the source param used for knowing if a promotion category is related to this purchasable.
getSalePrice() Returns the base price the item will be added to the line item with.
getShippingCategoryId() Returns the purchasable's shipping category ID.
getSku() Returns a unique code. Unique as per the commerce_purchasables table.
getSnapshot() Returns an array of data that is serializable to json for storing a line item at time of adding to the cart or order.
getTaxCategoryId() Returns the purchasable's tax category ID.
hasFreeShipping() Returns whether this purchasable has free shipping.
populateLineItem() Populates the line item when this purchasable is found on it. Called when Purchasable is added to the cart and when the cart recalculates.

# afterOrderComplete()

Runs any logic needed for this purchasable after it was on an order that was just completed (not when an order was paid, although paying an order will complete it).

This is called for each line item the purchasable was contained within.

View source

Arguments

Returns

void

# getDescription()

Returns your element's title or any additional descriptive information.

View source

Returns

string

# getId()

Returns the element’s ID.

View source

Returns

integer, null

# getIsAvailable()

Returns whether the purchasable is currently available for purchase.

View source

Returns

boolean

# getIsPromotable()

Returns whether this purchasable can be subject to discounts or sales.

View source

Returns

boolean

# getIsShippable()

Returns whether this purchasable can be shipped and whether it is counted in shipping calculations.

View source

Returns

boolean

# getIsTaxable()

Returns whether this purchasable is exempt from taxes.

View source

Returns

boolean

# getLineItemRules()

Returns any validation rules this purchasable required the line item to have.

View source

Arguments

Returns

array

# getPrice()

Returns the base price the item will be added to the line item with.

View source

Returns

float – Decimal(14,4)

# getPromotionRelationSource()

Returns the source param used for knowing if a promotion category is related to this purchasable.

View source

Returns

mixed

# getSalePrice()

Returns the base price the item will be added to the line item with.

It provides opportunity to populate the salePrice if sales have not already been applied.

View source

Returns

float – Decimal(14,4)

# getShippingCategoryId()

Returns the purchasable's shipping category ID.

View source

Returns

integer

# getSku()

Returns a unique code. Unique as per the commerce_purchasables table.

View source

Returns

string

# getSnapshot()

Returns an array of data that is serializable to json for storing a line item at time of adding to the cart or order.

View source

Returns

array

# getTaxCategoryId()

Returns the purchasable's tax category ID.

View source

Returns

integer

# hasFreeShipping()

Returns whether this purchasable has free shipping.

View source

Returns

boolean

# populateLineItem()

Populates the line item when this purchasable is found on it. Called when Purchasable is added to the cart and when the cart recalculates.

This is your chance to modify the weight, height, width, length, price and saleAmount. This is called before any LineItems::EVENT_POPULATE_LINE_ITEM event listeners.

View source

Arguments