Skip to content

Show the right offers to each shopper

This content is not available in your language yet.

The data lists every published discount, including ones a given shopper cannot get. Your theme decides what to show. The checks below cover each condition the data records.

All examples assume:

{%- assign ns = 'app--284350873601--discount_os' -%}
{%- assign offers = product.metafields[ns].discounts.value -%}

A DiscountOS discount in test mode applies only to customers with the tag dos-test. It is still in the data, with test set to true. Hide it from everyone else:

{%- assign is_tester = false -%}
{%- if customer and customer.tags contains 'dos-test' -%}{%- assign is_tester = true -%}{%- endif -%}
{%- for d in offers -%}
{%- if d.test.value and is_tester == false -%}{%- continue -%}{%- endif -%}
…
{%- endfor -%}

included_markets holds market handles. Empty means every market.

{%- assign markets = d.included_markets.value -%}
{%- if markets and markets.size > 0 -%}
{%- unless markets contains localization.market.handle -%}{%- continue -%}{%- endunless -%}
{%- endif -%}

included_customer_tags: the shopper needs one of them. excluded_customer_tags: the shopper must have none of them.

{%- assign inc = d.included_customer_tags.value -%}
{%- assign member_only = false -%}
{%- if inc and inc.size > 0 -%}{%- assign member_only = true -%}{%- endif -%}
{%- assign qualifies = false -%}
{%- if customer and member_only -%}
{%- for t in inc -%}{%- if customer.tags contains t -%}{%- assign qualifies = true -%}{%- endif -%}{%- endfor -%}
{%- endif -%}

A discount with only excluded tags (“everyone except wholesale”) still applies to a shopper who is not signed in. Show it normally and add a short “Conditions apply” line.

Segments, named customers and other conditions

Section titled “Segments, named customers and other conditions”

For customer segments and hand-picked customers the data holds only a count (config.eligibility.segments.count, config.eligibility.customers.count). The theme cannot check them. The same goes for order-count and sign-in conditions.

For any offer with a customer condition:

  • Never print its value. A shopper who does not qualify would be promised something they will not get.
  • Say “Sign in to see if this applies to you”, or “Applied at checkout if your account qualifies” for a signed-in shopper.

The universal field is false for all of these, so a quick rule is: only offers with universal true may show a value on a badge.

Skip a code chip once the shopper has used the code:

{%- assign applied = false -%}
{%- for da in cart.discount_applications -%}
{%- if da.title == d.code.value -%}{%- assign applied = true -%}{%- endif -%}
{%- endfor -%}

method is automatic or code. Group them so shoppers know which ones need typing:

{%- if d.method.value == 'code' -%} … show the code …{%- endif -%}

These live on the shop only. On a product page, read both lists and skip duplicates by handle:

{%- assign seen = ',' -%}
{%- for d in offers -%}{%- assign seen = seen | append: d.system.handle | append: ',' -%}{%- endfor -%}
{%- for d in shop.metafields[ns].discounts.value -%}
{%- assign h = d.system.handle | prepend: ',' | append: ',' -%}
{%- if seen contains h -%}{%- continue -%}{%- endif -%}
{%- if d.all_products.value or d.discount_class.value == 'order' or d.discount_class.value == 'shipping' -%}
…
{%- endif -%}
{%- endfor -%}

When cart_attribute_key has a value, the discount needs that cart attribute. The data cannot tell whether the cart will carry it. Add “Conditions apply at checkout” instead of promising the reward.

Some conditions have no field of their own, for example a discount that only applies to subscription orders. When universal is false and none of the checks above explain why, show the offer with “Conditions apply at checkout” rather than a plain promise.

When shop.metafields[ns].sync_paused is true, the data is not being updated and may include offers that have ended. Show a short note, and do not show countdowns.