Re: How To Combine These Two Render Snippet Code Together using if and else condition

How To Combine These Two Render Snippet Code Together using if and else condition

Jackson-pollock
Excursionist
23 0 2

 

(Snippet Code 1 )  {% render 'error-value' %}

{% assign BISAC_value = product.metafields.Neato.BISAC  %}

{% if BISAC_value == "BIO000000" %}
  {% assign category = "Biography & Autobiography / General" %}
{% elsif BISAC_value == "BIO023000" %}
  {% assign category = "Biography & Autobiography / Adventurers & Explorers" %}
{% elsif BISAC_value == "BIO002010" %}
  {% assign category = "Biography & Autobiography / African American & Black" %}
{% elsif BISAC_value == "BIO002040" %}
  {% assign category = "Biography & Autobiography / Arab & Middle Eastern" %}
{% elsif BISAC_value == "BIO001000" %}
  {% assign category = "Biography & Autobiography / Artists, Architects, Photographers" %}
{% elsif BISAC_value == "BIO002020" %}
  {% assign category = "Biography & Autobiography / Asian & Asian American" %}
{% elsif BISAC_value == "BIO034000" %}

{% else %}
  {% assign category = "Other" %}
{% endif %}

(Snippet Code 2 )  {% render 'error-value1' %}

{% assign BISAC_value = product.metafields.Neato.BISAC  %}

{% if BISAC_value == "JUV034000" %}
  {% assign category = "Juvenile Fiction / Royalty" %}
{% elsif BISAC_value == "REF008000" %}
  {% assign category = "Reference / Dictionaries" %}
{% elsif BISAC_value == "REF009000" %}
  {% assign category = "Reference / Directories" %}
{% elsif BISAC_value == "REF010000" %}
  {% assign category = "Reference / Encyclopedias" %}
{% elsif BISAC_value == "REF011000" %}
  {% assign category = "Reference / Etiquette" %}
{% elsif BISAC_value == "REF013000" %}
  {% assign category = "Reference / Genealogy & Heraldry" %}
{% elsif BISAC_value == "REF015000" %}
  {% assign category = "Reference / Personal & Practical Guides" %}
{% elsif BISAC_value == "REF018000" %}
  {% assign category = "Reference / Questions & Answers" %}



{% else %}
  {% assign category = "Other" %}
{% endif %}

<p> <div class="h4 inline-richtext"><strong> Category: </strong> {{ category }}     </div> </p>

How we can use the above two codes on product page 

 

( this code not working )

{% assign error_value = section.settings.error_value %}

{% if error_value == "Category: Other" %}

    {% render "error-value" %}
 

{% else %}
  {% render "error-value1" %}
{% endif %}

Screenshot 2024-04-11 220848.png

 

 

I want output like this

 

Screenshot 2024-04-11 120837.png

Replies 2 (2)

Guleria
Shopify Partner
4146 809 1164

Try this

{% assign error_value = section.settings.error_value %}

{% if error_value == "Other" %}

    {% render "error-value" %}
 

{% else %}
  {% render "error-value1" %}
{% endif %}
- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder
Jackson-pollock
Excursionist
23 0 2

{% render "error-value" %}  is not working when is equal to error_value == "Other"