Ad

Shopify Liquid Capture Settings Not Outputting For Some Reason

- 1 answer

I'm trying to get and display some theme settings which gets the site name and applies to end which i have setup in the schema but cant get it to display the settings.

In the promo_header.liquid snippet file i have:

{% capture promo_header_text_1 %} locale_promo_1_text_{{ shop.name }} {% endcapture %}
{% capture promo_header_url_1 %} locale_promo_1_url_{{ shop.name }} {% endcapture %}
{% capture promo_header_text_2 %} locale_promo_2_text_{{ shop.name }} {% endcapture %}
{% capture promo_header_url_2 %} locale_promo_2_url_{{ shop.name }} {% endcapture %}

<p>
  {% if settings[promo_header_text_1] %}
     <a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ settings[promo_header_url_1] }}">{{ settings[promo_header_text_1] }}</a>
  {% endif %}
  {% if settings[promo_header_text_2] %}
     <span>/</span><a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ settings[promo_header_url_2] }}">{{ settings[promo_header_text_2] }}</a>
  {% endif %}
</p>

I have also tried to output using just for example

{{ settings.promo_header_text_1 }}

But not displaying anything either... when i debug and display for example

{{ promo_header_text_1 }}

It does return

locale_promo_1_text_website-test2

Which is correct and in the schema settings file (example based on that one above it is matching and is set in theme customisation)

 {
    "type": "text",
    "id": "locale_promo_1_text_website-test2",
    "label": "Promo 1 Text",
    "default": "FREE US SHIPPING OVER $35"
 }

What am I doing wrong?

Ad

Answer

For anyone else that might come across the same issue here is the solution I got working:

{% assign promo_header_text_1 = 'locale_promo_1_text_' | append:shop.name %}

and to output

{{ settings[promo_header_text_1] }}
Ad
source: stackoverflow.com
Ad