FROM CACHE - en_header

Product Tags & Stock Quantity

Solved
Nittiyarns
Tourist
26 0 1

Hi community!

 

I recently had a problem solved in the community and now I want to tweak it a bit. I have a snippet which hides the stock quantity on the product page when the product has the tag "preorder". I want to also add in the tag "incoming" so that it doesn't show when the product is tagged with that either - can anyone help me adjust my snippet please?

 

Original solution by @LitExtension :

 

 

{% for tag in product.tags %}

  {% if tag contains 'your_tab' %}

    {% assign has_preorder = true %}

  {% endif %}

{% endfor %}

{% unless has_preorder == true %}

  {%- if settings.quantity_msg -%}

    {%- assign enableqtyMsg = true -%}

    {%- if current_variant.inventory_management == "shopify" and current_variant.inventory_quantity < settings.max_quantity and current_variant.inventory_quantity != 0 -%}

      {%- assign enableqtyMsg = flase -%}

    {%- endif -%}

    {% assign qtyMsg = 'products.product.quantity_message' | t | split: '{{items}}' %}

    <div id="quantity_message" data-qty="{{settings.max_quantity}}"{%- if enableqtyMsg -%}style="display:none;"{%- endif -%}>{{qtyMsg[0]}} <span class="items">{{product.selected_or_first_available_variant.inventory_quantity}}</span> {{qtyMsg[1]}}</div>

    {% for variant in product.variants %}<span class="hide" id="pvr-{{ variant.id }}">{{variant.inventory_quantity}}</span>{% endfor %}

  {%- endif -%}

{% endunless %}

Remember: You need to change "your_tab" with the tag of that products.

Hope this helps. If you can not do that, you can add me as a staff, I'll check it for you.

Thank you!
Accepted Solution (1)

Accepted Solutions
PaulNewton
Shopify Partner
4332 321 930

This is an accepted solution.

  {% if tag contains 'your_tab' or tag contains 'your_other_tab' %}

https://shopify.dev/api/liquid/basics/operators 

 

More advanced if using transfers also beware there is a varint.next_incoming_date property that could be possibly be used for this instead

https://shopify.dev/api/liquid/objects/variant#variant-next_incoming_date 

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com

View solution in original post

Replies 7 (7)
PaulNewton
Shopify Partner
4332 321 930

This is an accepted solution.

  {% if tag contains 'your_tab' or tag contains 'your_other_tab' %}

https://shopify.dev/api/liquid/basics/operators 

 

More advanced if using transfers also beware there is a varint.next_incoming_date property that could be possibly be used for this instead

https://shopify.dev/api/liquid/objects/variant#variant-next_incoming_date 

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
Nittiyarns
Tourist
26 0 1

Thank you! That works. I'd love to know how to implement the transfer date onto the product page if assigned? i'm currently using meta fields but have to manually add the expected date to each individual product to have it display on the product page

Nittiyarns
Tourist
26 0 1

Hi Paul,

 

I'm wondering if you can help me again. I've managed to implement the "Variant.next.incoming.date" into my code, however, it doesn't show up if the product is tagged with preorder?

{% if product.selected_variant.incoming %}
<span><p style="color:red"><b>**More Stock Expected {{ product.selected_variant.next_incoming_date | date: "%b %d, 20%y"}}**</p></span></td><br>
{% endif %}
	{% for tag in product.tags %}

  {% if tag contains 'Preorder' or tag contains 'Incoming'%}

    {% assign has_preorder = true %}

  {% endif %}

{% endfor %}

{% unless has_preorder == true %}

  {%- if settings.quantity_msg -%}

    {%- assign enableqtyMsg = true -%}

    {%- if current_variant.inventory_management == "shopify" and current_variant.inventory_quantity < settings.max_quantity and current_variant.inventory_quantity != 0 -%}

      {%- assign enableqtyMsg = flase -%}

    {%- endif -%}

    {% assign qtyMsg = 'products.product.quantity_message' | t | split: '{{items}}' %}

    <div id="quantity_message" data-qty="{{settings.max_quantity}}"{%- if enableqtyMsg -%}style="display:none;"{%- endif -%}>{{qtyMsg[0]}} <span class="items">{{product.selected_or_first_available_variant.inventory_quantity}}</span> {{qtyMsg[1]}}</div>

    {% for variant in product.variants %}<span class="hide" id="pvr-{{ variant.id }}">{{variant.inventory_quantity}}</span>{% endfor %}
  {%- endif -%}

{% endunless %}
  {% if product.tags contains 'Preorder'%}
        <p style="color:red"><b><i>*This product is a preorder and will ship in 3-4 weeks - payment due at time of order*</i></b></p>
{% endif %}

 What I'd really like it to do is if the tag does have preorder, that it replaces the "this product is a preorder and will ship in 3-4 weeks" part, and if it's not a preorder it just displays normally in the same place? Is this possible?

 

TIA!

PaulNewton
Shopify Partner
4332 321 930

Is your product tagged with "Incoming" in the admins product data?

{% if tag contains 'Preorder' or tag contains 'Incoming'%}

if not you need to check for incoming again

 

{% if tag contains 'Preorder' or product.selected_variant.incoming %}
Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
Nittiyarns
Tourist
26 0 1

Hi Paul, thanks for your reply. Yes some of my products are tagged with Incoming - this was to use metafields for when stock is coming in, but I won't need it now.

 

I'm not sure if I placed the code in the wrong place, or not, but what I'm trying to achieve is

If the product doesn't contain preorder or incoming, but stock is on it's way, then it displays the incoming date using:

{% if product.selected_variant.incoming %}
<span><p style="color:red"><b>**More Stock Expected {{ product.selected_variant.next_incoming_date | date: "%b %d, 20%y"}}**</p></span></td><br>
{% endif %}

 

If the product does contain the preorder tag, and stock is on the way, then I want it to replace this:

  {% if product.tags contains 'Preorder'%}
        <p style="color:red"><b><i>*This product is a preorder and will ship in 3-4 weeks - payment due at time of order*</i></b></p>
{% endif %}

 

with this

{% if product.selected_variant.incoming %}
<span><p style="color:red"><b>**More Stock Expected {{ product.selected_variant.next_incoming_date | date: "%b %d, 20%y"}}**</p></span></td><br>
{% endif %}

 

Thank you!

Nittiyarns
Tourist
26 0 1

I fixed it by changing the code from product.selected_variant to current_variant 🙂

Nittiyarns
Tourist
26 0 1

Hi Paul,

 

Me again! Happy new year! I'm trying to set up a new theme on my store - https://themeforest.net/item/minimog-the-high-converting-shopify-theme/33380968

 

I'm trying to implement the above into the new code, but there is no product.liquid with this theme so I'm a little confused. Within the theme customization screen you have the option to add in liquid blocks, which I've managed to add in some things there like stock quantity and preorder disclaimer, but I can't get it to work all in one like we had with my other theme, and it won't bring up anything for the variant.incoming either....

 

Any ideas?

 

Thank you!