[Special Summer Sale] 40% OFF All Magento 2 Themes

Cart

Variable within liquid if statement when calling shopify settings

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9603
    allreadyhome
    Participant

    I thought this would be simple to solve but I am trying to put a variable within a liquid statement.

    I have my variable {{ loop_index }} and I want it to be within this statement :

    {% if settings.dropdown-[loop_index]-select  %}
    

    I tried putting […] round it but that didn’t work. Basically it should say settings.dropdown-1-select, settings.dropdown-2-select.

    What am I doing wrong?

    #9604
    steph-sharp
    Participant

    Create a string containing the variable name, then use the square bracket notation to access the setting with that name. For example:

    {% capture var %}dropdown-{{ loop_index }}-select{% endcapture %}
    {% if settings[var] %}
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.