VIP Tiers

Show how much a customer has to spend to unlock the next tier

{% if customer and shop.metafields.rivo.loy.vip_program.enabled %}
  {% assign vip_tiers = shop.metafields.rivo.loy.vip_program.tiers %}
  {% assign current_vip_tier = vip_tiers | where: "name", customer.metafields.custom.rivo.value.vip_tier | first %}

	{% for tier in vip_tiers %}
    {% if tier.name == current_vip_tier.name %}
      {% assign next_tier_index = forloop.index0 | plus: 1 %}
      {% break %} 
    {% endif %}
  {% endfor %}

  {% assign next_vip_tier = vip_tiers[next_tier_index] %}
  {% assign total_spent_in_cents = customer.total_spent %}
  {% assign cents_to_unlock_next_tier = next_vip_tier.threshold | times: 100 | minus: total_spent_in_cents  %}
	
  <p>Spend another {{cents_to_unlock_next_tier}} to unlock the next tier</p>
{% endif %}

Show perks from a VIP tier

{% if customer %}
  {% assign vip_tiers = shop.metafields.rivo.loy.vip_program.tiers %}
  {% assign current_vip_tier = vip_tiers | where: "name", customer.metafields.custom.rivo.value.vip_tier | first %}

  <h3>Perks from your current VIP tier</h3>
  <ul>
    {% for perk in current_vip_tier.perks %}
      <li>{{perk}}</li>
    {% endfor %}
  </ul>
{% endif %}