Skip to content

Instantly share code, notes, and snippets.

@carbone
Last active February 14, 2018 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbone/4ad9d020a18b457f65ead94e01d8a10c to your computer and use it in GitHub Desktop.
Save carbone/4ad9d020a18b457f65ead94e01d8a10c to your computer and use it in GitHub Desktop.
Add this to custom_fields_accordions.liquid
{% comment %}
Help Article
https://customfields.zendesk.com/hc/en-us/articles/360000919672
Theme Files
/assets/custom-fields-accordions.js
/assets/custom-fields-accordions.scss.css
theme.liquid <head> section.
product.liquid or product-template.liquid, changes made to include this file.
{% endcomment %}
{% assign acc = shop.metafields.custom_fields["accordion_definition"] | split: '|' %}
{% if acc %}
<div id="custom-fields-accordion">
{% assign acc_item = '' %}
{% assign acc_index = '' %}
{% for acc_info in acc %}
{% assign acc_item = acc_info | split: '=' %}
{% assign acc_index = acc_item[0] %}
{% assign acc_label = acc_item[1] %}
{% if product.metafields.custom_fields[acc_index] != null %}
<div class="accordion-section">
<a class="accordion-section-title" href="#{{ acc_index }}">{{ acc_label }}</a>
<div id="{{ acc_index }}" class="accordion-section-content">
{{ product.metafields.custom_fields[acc_index] }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment