Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakhardage/b6aa980d4c2195bad812b40c6a997632 to your computer and use it in GitHub Desktop.
Save zakhardage/b6aa980d4c2195bad812b40c6a997632 to your computer and use it in GitHub Desktop.
{% assign member_discount_code = settings.member_discount_code %}
{% assign class_discount_code = settings.class_discount_code %}
{% assign combined_discount_code = settings.combined_discount_code %}
{% if customer %}
{% assign customer_tags = customer.tags | join:',' | downcase %}
{% if customer_tags contains 'member' %}
{% assign member = true %}
{% endif %}
{% endif %}
{% for item in cart.items %}
{% if item.product.type == 'class' %}
{% assign product_tags = item.product.tags | join:',' | downcase %}
{% if product_tags contains [qualifying_product_tag] %}
{% assign class_discount = true %}
{% endif %}
{% endif %}
{% endfor %}
{% if member %}
{% if class_discount %}
{% assign applied_discount = combined_discount_code %}
{% else %}
{% assign applied_discount = member_discount_code %}
{% endif %}
{% else %}
{% if class_discount %}
{% assign applied_discount = class_discount_code %}
{% endif %}
{% endif %}
<form action="{{ routes.cart_url }}{% if applied_discount != blank %}/?discount={{ applied_discount }}{% endif %}" method="post" novalidate class="cart">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment