Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.

Home Page:https://shopify.github.io/liquid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing liquid to read from multiple templates

j1345 opened this issue · comments

commented

We have the code working fr one template (show10) and now we are wanting to add in more template names such as show20, show50 but not sure how to add to the code to get it to read past show10 if the template name is 'show20' or 'show50'. See below what we have working for 'show10':

    <div id="shappify-qty-msg"></div>
    <div class="order_box">
    {% for variant in product.variants %}
    {% assign quantity = variant.inventory_quantity %}
   {% if variant.metafields.shappify_qb.qb_hide == "1" %}{% else %}
    {% if variant.available %}
        <div class="variant_row">
          <div class="variant_title">{{ variant.title }} ({% if templatename == 'show10' %}{% if quantity > 10 %}10{% else %}{{ variant.inventory_quantity }}{% endif %}{% else %}{{ variant.inventory_quantity }}{% endif %} in Stock)</div>
          <div class="variant_input"><input onfocus="this.select()" class="quantity field" data-id="{{ variant.id }}" min="0" {% if templatename == 'show10' %}max="{% if quantity > 10 %}10{% else %}{{ variant.inventory_quantity }}{% endif %}"{% else %}{% unless item.variant.inventory_management == blank or item.variant.inventory_policy == 'continue' %}{% assign max = variant.inventory_quantity %}{% for item in cart.items %}{% if item.id == variant.id %}{% assign max = max | minus: item.quantity %}{% endif %}{% endfor %} max="{{ max }}" {% endunless %}{% endif %} type="text" value="0" tabindex="1" /></div>
        </div>
    {% else %}
      <div class="variant_row">
        <div class="variant_title">{{ variant.title }} ({% if templatename == 'show10' %}{% if quantity > 10 %}10{% else %}{{ quantity }}{% endif %}{% else %}{{ variant.inventory_quantity }}{% endif %} in Stock)</div>     
        <div class="variant_input"><input class="quantity field disabled" type="text" value="0" /></div>
      </div>
    {% endif %}
  {% endif %}
  {% endfor %}
  {% if product.available %}
  <input class="action-button submit button btn center add-to-cart-order-form" type="button" value="Add to cart" />
  {% else %}
  <input class="disabled" type="button" value="Sold Out" />
  {% endif %}
  </div>

product.show20.liquid and product.show50.liquid templates have already been made

Grateful for any help on this :)