Variant Model

Variants are Craft Elements and also Purchasables.

VariantModel’s have the following attributes and methods:

Attributes #

title #

The variants title as generated by the title formatter on the product type definition.

id #

The id of the variant in the system.

purchasableId #

Returns this variant’s id - as variants are purchasables.

product #

Returns this variant’s Product Model

price #

The listing price of the variant.

salePrice #

The price of the variant after sales have been applied. Will be equal to price if no sales were applicable.

sku #

The sku of the variant.

isDefault #

Returns true or false if this variant is the default variant of a product.

hasStock #

Returns true or false if the variant has unlimited stock or a stock count greater than zero.

unlimitedStock #

Returns true or false if this variant has unlimited stock

stock #

Returns the stock count on hand, or zero if unlimitedStock is true.

maxQty #

The maximum quanity orderable for this variant (in a single cart/order)

minQty #

The minimum quanity orderable for this variant (in a single cart/order)

weight #

The variants weight

height #

The variants height

length #

The variants length

width #

The variants width

cpEditUrl #

The url to edit this variant’s edit page in the control panel.

sortOrder #

Returns the order number of the variant as defined in the CP product edit screen.

onSale #

Returns true or false when any sales are applied to this variant. This is just a helper to test if there is a saleAmount not equal to zero.

salesApplied #

Returns an array of Sales that have been applied, allowing you to access the description of the sale with {{ variant.salesApplied[0].description }}

description #

The description of the purchasable which is the result of the product type’s ‘Order Description Format’ option.

Buy Craft Commerce

Craft Commerce site license

Includes

  • Developer support
  • One year of updates ($199/year for updates after that)
  • Craft Pro site license
Buy now for $999
Can I try before buying?

Absolutely. Just download it from the “Download” button in the site header and follow our installation instructions. You’ll have the full feature set to experiment with, without any restrictions, as long as you’re running it from a development, testing, or staging domain.

Will there be recurring/upgrade fees?

Each Commerce license comes with one year of updates. After that, you can unlock additional updates for $199 per year.

Can I use this on an existing Craft site?

Yes! And if you already have a Craft Pro license (or you don’t need one), you can purchase Craft Commerce directly from the Plugin Store or just leave the switch off that says “Include a Craft Pro license” in the purchase form.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Solo as well!

Can I try before buying?

Absolutely. Just download it from the “Download” button in the site header and follow our installation instructions. You’ll have the full feature set to experiment with, without any restrictions, as long as you’re running it from a development, testing, or staging domain.

Will there be recurring/upgrade fees?

Each Commerce license comes with one year of updates. After that, you can unlock additional updates for $199 per year.

Can I use this on an existing Craft site?

Yes! And if you already have a Craft Pro license (or you don’t need one), you can purchase Craft Commerce directly from the Plugin Store or just leave the switch off that says “Include a Craft Pro license” in the purchase form.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Solo as well!