FROM CACHE - en_header

Tweak quantity in stock code

Solved
Claire_Brennan
Excursionist
23 0 9

Hi, I am currently using the code below to show my stock levels. I want to change it to only show on items that has reduced in the title. I have tried adding in "if product.title contains ‘Reduced’" etc in several places but I can't get it working. Thanks

 

 

</div>
<div id="variant-inventory">
{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}
Hurry only {{ product.variants.first.inventory_quantity }} in stock!
{% endif %}
</div>

 

 

Accepted Solution (1)

Accepted Solutions
LitExtension
Shopify Partner
4435 904 934

This is an accepted solution.

Hi @Claire_Brennan,

Please change code:

{% if product.title contains 'reduced' %}
        <div id="variant-inventory">
          {% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}
          Hurry only {{ product.variants.first.inventory_quantity }} in stock!
          {% endif %}
        </div>
{% endif %}

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Get your 1-month Shopify free trial from LitExtension. CONTACT US!
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!

View solution in original post

Replies 3 (3)
LitExtension
Shopify Partner
4435 904 934

This is an accepted solution.

Hi @Claire_Brennan,

Please change code:

{% if product.title contains 'reduced' %}
        <div id="variant-inventory">
          {% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}
          Hurry only {{ product.variants.first.inventory_quantity }} in stock!
          {% endif %}
        </div>
{% endif %}

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Get your 1-month Shopify free trial from LitExtension. CONTACT US!
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!
Claire_Brennan
Excursionist
23 0 9

Perfect, thank you! I think I tried that line of code everywhere except right at the beginning! 

Beck_Prior
Tourist
9 0 4

Hi

I would like to be tweaked further if possible.

I have a product listing with multiple variants. Currently the code below makes it seem as if 0 are in stock if the first variant is out of stock. Is there a way to tweak the code per variant? 

 

{% if product.variants.first.inventory_quantity < 5 %}
<p>We have {{ product.variants.first.inventory_quantity }} item(s) remaining </p>
{% endif %}