Skip to content

Instantly share code, notes, and snippets.

@zakhardage
Created March 8, 2014 05:55
Show Gist options
  • Select an option

  • Save zakhardage/9426003 to your computer and use it in GitHub Desktop.

Select an option

Save zakhardage/9426003 to your computer and use it in GitHub Desktop.
// Existing Form
<form action="http://bridal-survival.myshopify.com/cart/add" method="post">
<input type="hidden" name="id" value="{{ variant.id }}" />
<input type="hidden" name="return_to" value="back" />
<input class="buy" type="submit" value="{{ variant.id }}" />
</form>
// New Form
{% if customer and customer.tags contains 'wholesale' %}
{% for variant in product.variants reversed %}
{% if variant.title contains 'wholesale' %}
{% assign variantID = variant.id %}
{% endif %}
{% endfor %}
{% else %}
{% for variant in product.variants reversed %}
{% unless variant.title contains 'wholesale' %}
{% assign variantID = variant.id %}
{% endunless %}
{% endfor %}
{% endif %}
<form action="http://bridal-survival.myshopify.com/cart/add" method="post">
<input type="hidden" name="id" value="{{ variantID }}" />
<input type="hidden" name="return_to" value="back" />
<input class="buy" type="submit" value="{{ variant.id }}" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment