craft.commerce.variants

How to get variants #

Usually you will only want to retrieve products, giving you access to their variants. Sometimes you might want to query for variants directly.

You can access your site’s variants from your templates via craft.commerce.variants It returns an ElementCriteriaModel object.

{% set variants = craft.commerce.variants.id(8376).first() %}

{{ variant.sku }} - {{ variant.salePrice }}

Parameters #

craft.commerce.variants supports the following parameters:

ID #

The variant’s element ID.

productId #

The product ID this variant belongs to.

sku #

The variant’s SKU

default #

Whether the variant is the product’s default variant

Accepts: boolean (true or false)

stock #

The stock amount

Accepts: integer

hasStock #

Whether the variant has unlimited stock or stock greater than zero.

Accepts: boolean (true or false)

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!