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.

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

  • Standard tech support
  • Unlimited app updates
  • 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, with just one limitation: you won’t be able to charge credit cards. Until Craft Commerce has been purchased and activated, it’s limited to a single dummy gateway.

Will there be recurring/upgrade fees?

Nope, it’s just a one-time license fee per site.

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), just flip that “Include a Craft Pro license” switch in the purchase form, and we’ll drop the price to $700.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Client and Personal editions 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, with just one limitation: you won’t be able to charge credit cards. Until Craft Commerce has been purchased and activated, it’s limited to a single dummy gateway.

Will there be recurring/upgrade fees?

Nope, it’s just a one-time license fee per site.

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), just flip that “Include a Craft Pro license” switch in the purchase form, and we’ll drop the price to $700.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Client and Personal editions as well!