QUANTM7 Docs
QuillObjects

Variant

The variant object and its properties for size, color, pricing, and stock.

A variant is one version of a product. A t-shirt might come in Small, Medium, and Large. Each size is a variant with its own price, SKU, and stock level.

Access variants through the product object:

{% for variant in product.variants %}
  <p>{{ variant.title }} - {{ variant.price | money }}</p>
{% endfor %}

Core properties

PropertyTypeDescription
variant.idnumberThe unique variant ID
variant.titlestringThe full title (e.g. Large / Red)
variant.skustringThe stock keeping unit code
variant.barcodestringThe barcode value, if set
variant.urlstringURL to the product page with this variant selected
variant.positionnumberThe sort order of this variant
variant.availablebooleantrue if in stock
variant.selectedbooleantrue if this is the currently selected variant
variant.inventory_quantitynumberThe number of items in stock
variant.requires_shippingbooleantrue if this variant needs to be shipped

Pricing

Like product prices, variant prices are in the smallest currency unit.

PropertyTypeDescription
variant.pricenumberThe variant price
variant.compare_at_pricenumberThe compare-at price, if set
variant.costnumberThe cost price (for margin calculations)
{% for variant in product.variants %}
  <div class="variant-row">
    <span>{{ variant.title }}</span>
    <span>{{ variant.price | money }}</span>
    {% if variant.compare_at_price > variant.price %}
      <span class="was">Was {{ variant.compare_at_price | money }}</span>
    {% endif %}
  </div>
{% endfor %}

Tier pricing

Q7 supports multi-tier pricing for B2B and membership models. These fields are only populated when the store has tier pricing enabled.

PropertyTypeDescription
variant.retail_pricenumberThe retail tier price
variant.retail_sale_pricenumberThe retail tier sale price
variant.wholesale_pricenumberThe wholesale tier price
variant.wholesale_sale_pricenumberThe wholesale tier sale price
{% if customer.tier == 'wholesale' and variant.wholesale_price %}
  <p>Trade price: {{ variant.wholesale_price | money }}</p>
{% else %}
  <p>{{ variant.price | money }}</p>
{% endif %}

Options

Each variant can have up to three option values. The option names come from product.options.

PropertyTypeDescription
variant.option1stringFirst option value (e.g. Large)
variant.option2stringSecond option value (e.g. Red)
variant.option3stringThird option value, if used
{% for variant in product.variants %}
  <p>Size: {{ variant.option1 }}, Color: {{ variant.option2 }}</p>
{% endfor %}

Weight

PropertyTypeDescription
variant.weightnumberThe weight value
variant.weight_unitstringThe unit: g, kg, lb, or oz
<p>Weight: {{ variant.weight }}{{ variant.weight_unit }}</p>

Image

PropertyTypeDescription
variant.imageimageA variant-specific image, if one is set

When a variant has its own image, use it. Otherwise fall back to the product image:

{% assign image = variant.image | default: product.featured_image %}
{{ image | image_tag }}

Metafields

PropertyTypeDescription
variant.metafieldsobjectCustom data fields for this variant
{% if variant.metafields.custom.lead_time %}
  <p>Ships in {{ variant.metafields.custom.lead_time }}</p>
{% endif %}

Building a variant picker

A common pattern is to build a form that lets the visitor choose a variant:

{% form 'product', product %}
  {% for option in product.options %}
    <label>{{ option }}</label>
    <select name="option{{ forloop.index }}">
      {% for variant in product.variants %}
        <option value="{{ variant.id }}">
          {{ variant.title }} - {{ variant.price | money }}
          {% unless variant.available %} (Sold out){% endunless %}
        </option>
      {% endfor %}
    </select>
  {% endfor %}

  <button type="submit" {% unless product.available %}disabled{% endunless %}>
    Add to Cart
  </button>
{% endform %}

On this page