Displaying Quantity on product page in Simple Theme

Solved
Excursionist
14 1 1

I'm following this thread on the board and have added this code to my product-template.liquid page:

{% comment %} Inventory tracking on product page {% endcomment %}
            <div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
              {% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
              <i>We have {{ current_variant.inventory_quantity }} in stock.</i>
              {% else %}
              <i>This product will take an additional 1 - 2 weeks to ship.</i>
              {% endif %}
            </div>

It seems to work fine with most of my products. This is out of stock but able to be ordered, and it's displaying the correct notice. This one is displaying the quantity properly. But this product has 3 in stock, is tracked by Shopify, and it's still displaying the out of stock note. Most of the newer items added to the store are doing the same thing; they are in stock and tracked by shopify, but they're displaying that message instead of the quantity.

 

Any idea why the code isn't working on some products but is on others? Thanks!

0 Likes
Excursionist
14 1 1

Please don't DM me. I'd prefer to discuss possible answers in this thread. Thanks!


0 Likes
Highlighted
Excursionist
14 1 1

Bump. Anyone?

0 Likes
Shopify Partner
239 59 70

Hi @starlightstitch,

 

I'm so sorry it's taken so long for you to get a response!

 

For the products that are still displaying the out of stock note, try verifying that you have unchecked Continue selling when out of stock on the product's variants. The code you've posted will only show the proper quantity message when that option is unchecked:

 

Screen Shot 2019-08-24 at 9.01.20 PM.png

 

Let me know if this solves your problem or if you need further help!

Brian | Shopify Partner | Ecommerce Consultant
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution  
 - Need further assistance? Visit www.BrianAtWork.com

1 Like
Excursionist
14 1 1

Thanks, @BrianAtWork ! Is there any way to modify the coding so we can have the stock number show up on products that have the Continue Selling When Out of Stock option enabled?

 

Basically, we want customers to know that shipping time will take longer only if we don't have a product on hand and need to order it. We have a lot of items that we have in stock but can still be ordered if we run out, so we need to let customers know if they can expect it right away or if there will be a wait.

0 Likes

Success.

Shopify Partner
239 59 70

Hi @starlightstitch,

 

You're most welcome. Try this:

 

{% comment %} Inventory tracking on product page {% endcomment %}
<div id="variant-inventory" class="{% unless current_variant.inventory_management == 'shopify' and current_variant.available %} hide {% endunless %}">
  {% if current_variant.inventory_quantity > 0 %}
    <i>We have {{ current_variant.inventory_quantity }} in stock.</i>
  {% else %}
    <i>This product will take an additional 1 - 2 weeks to ship.</i>
  {% endif %}
</div>

Let me if this answers your question or if you need further help!

Brian | Shopify Partner | Ecommerce Consultant
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution  
 - Need further assistance? Visit www.BrianAtWork.com

1 Like
Excursionist
14 1 1

Thanks, that works perfectly! I appreciate your help!

1 Like