Promotions

Display promotional pricing and marketing content.

See also: Promotion object

Promotions are discounts configured on individual variants.

A promotion becomes active when:

  • The current date is on or after the promotion start date.
  • The promotion has not reached its end date (if one is set).
  • The promotion has not been manually expired.

Use variant.promotion.active to determine whether a promotion should be displayed.

Display promotion details

Promotions can include marketing content that you may wish to display throughout your theme, including:

  • Category
  • Tagline
  • Expiry date
  • Discount amount

For example:

{% for variant in product.variants %}
  {% if variant.promotion.active %}

    {% assign promotion = variant.promotion %}

    {% if promotion.discount_is_percentage %}
      {% assign discount = promotion.discount_percentage | append: "%" %}
    {% else %}
      {% assign discount = promotion.discount_amount_fractional | money %}
    {% endif %}

    <div>
      <p>{{ variant.name }}</p>

      <p>
        Save {{ discount }} with our
        <span class="promo-label">{{ promotion.category }}</span>
      </p>

      {% if promotion.tagline != blank %}
        <p>{{ promotion.tagline }}</p>
      {% endif %}

      {% if promotion.ends_on %}
        <p>Offer ends {{ promotion.ends_on | date: "%d %B %Y" }}</p>
      {% endif %}
    </div>

  {% endif %}
{% endfor %}

This might render:

<div>
  <p>Yoga Retreat - Adult</p>
  <p>Save 20% with our <span class="promo-label">Early release offer</span></p>
  <p>Book your spot on the retreat of a lifetime</p>
  <p>Offer ends 12 January 2023</p>
</div>

Display promotional pricing

To calculate the promotional price, apply the promotion to the variant's price.

{% assign promotional_price = variant.price | apply_promotion: variant.promotion %}

The result is a VariantPriceDrop.

Access one of its price properties when displaying the value.

For example:

{% for variant in product.variants %}

  {% assign full_price = variant.price.fractional | money %}

  {% if variant.promotion.active %}

    {% assign promotional_price = variant.price | apply_promotion: variant.promotion %}

    <p>
      {{ variant.name }}
    </p>

    <p>
      Price reduced from
      {{ full_price }}
      to
      {{ promotional_price.fractional | money }}
    </p>

  {% else %}

    <p>{{ variant.name }}</p>
    <p>{{ full_price }}</p>

  {% endif %}

{% endfor %}

This might render:

<p>Yoga Retreat - Adult</p>
<p>Price reduced from $300.00 to $250.00</p>

<p>Yoga Retreat - Child</p>
<p>$20.00</p>

Developer considerations

When implementing promotions:

  • Always check variant.promotion.active before displaying promotional content.
  • Use apply_promotion to calculate promotional prices.
  • Format the returned price using the appropriate Price properties and the money filter.
  • Promotion pricing should be used when calculating deposits and payment plans.
  • Never calculate discounts manually in your theme.

On this page