Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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