Skip to content

Instantly share code, notes, and snippets.

@kyledurand
Last active August 29, 2015 14:13
Show Gist options
  • Save kyledurand/3730b57fd6835a81c20c to your computer and use it in GitHub Desktop.
Save kyledurand/3730b57fd6835a81c20c to your computer and use it in GitHub Desktop.
Multiple gift cards

Multiple Gift Cards Based on product attributes

  1. Add properties for gift cards under product.liquid. Must be within the tags.
  2. Retrieve the properties in gift_cart.liquid
  3. Celebrate
{% comment %}
Added by Kyle @ Shopify
{% endcomment %}
{% for property in gift_card.properties %}
{% assign giftcardtype = property | last %}
{% endfor %}
{% comment %}
End code added by Kyle Now you can use if statements to show different images.
i.e.
{% if giftcardtype == 'Thank You Gift Card' %}
<img src="{{ 'Thank_You_gift_card.jpg' | asset_url }}" alt="Gift card illustration">
{% endif %}
{% endcomment %}
{% if giftcardtype == 'Thank You Gift Card' %}
<img src="{{ 'Thank_You_gift_card.jpg' | asset_url }}" alt="Gift card illustration">
{% elsif giftcardtype == 'Birthday Gift Card' %}
<img src="{{ 'happy_birthday_gift_card.jpg' | asset_url }}" alt="Gift card illustration">
{% else %}
<img src="{{ 'gift-card/card.jpg' | shopify_asset_url }}" alt="Gift card illustration">
{% endif %}
{% if product.title == 'Gift Card' %}
<input type="hidden" name="properties[giftcardtype]" value="Standard Gift Card" />
{% elsif product.title == 'Thank You Gift Card' %}
<input type="hidden" name="properties[giftcardtype]" value="Thank You Gift Card" />
{% elsif product.title == 'Birthday Gift Card' %}
<input type="hidden" name="properties[giftcardtype]" value="Birthday Gift Card" />
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment