Created
August 29, 2019 22:27
-
-
Save zakhardage/6537d5096ed0cd9ee46f9beb49d8d11f to your computer and use it in GitHub Desktop.
Removes duplicate strings from the beginning of variant titles (Shopify)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign string = product.variants[0].title | downcase | split:' ' %} | |
{% assign size = string | size %} | |
{% assign pass = true %} | |
{% for i in (0..size) %} | |
{% for variant in product.variants %} | |
{% assign compare = variant.title | downcase | split:' ' %} | |
{% unless string[i] == compare[i] %}{% assign pass = false %}{% endunless %} | |
{% endfor %} | |
{% if pass %}{% assign remove = remove | append:string[i] | append:' ' %}{% endif %} | |
{% endfor %} | |
<select name="id" class="product-select"> | |
{% for variant in product.variants %} | |
<option value="{{ variant.id }}">{{ variant.title | downcase | remove:remove }}</option> | |
{% endfor %} | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment