Custom message when there is 0 items in stock [Supply theme]

Solved
Highlighted
New Member
12 0 0

Hello,

 

I am using Supply theme and if there are some items (variants of items) in stock the message says "Only X items left!" (standard theme feature).

What I wanted to have is custom message when there is 0 items in stock.

 

For example:

There are 5 items (variants of items) in stock so message says:

"Only 5 items left!" (as it is now)

 

There is 0 items in stock so message would say:

"Item available from a supplier. Allow 2-3 weeks to deliver"

 

Here is a code for standard "only x items left" feature inserted.

 

  {% if section.settings.product_quantity_message%}
          <div id="variantQuantity-{{ section.id }}" class="variant-quantity {% if variant.inventory_management and variant.inventory_quantity < 10 and variant.inventory_quantity > 0 %} is-visible{% endif %}">
              {% include 'svg-definitions' with 'stock-icon' %}
              {% if variant.inventory_management and variant.inventory_quantity < 10 and variant.inventory_quantity > 0 %}
                {% assign qty = variant.inventory_quantity %}
                <span id="variantQuantity-{{ section.id }}__message">{{ 'products.product.only_left' | t: count: qty }}</span>
              {% endif %}
          </div>

 

Could please anyone help?

 

Thank you.

 

Regards

 

0 Likes
Highlighted
Shopify Partner
1445 195 524

Go into Online Store > Actions > Edit Code 

 

Then navigate to your Locales folder and open your en.default.json. Scroll to around line 310 and locate the "product" object and change the "sold_out" text to whatever you want. 

 

changemessage.jpg

 

result.jpg

 

If my solution helped you, please like and accept as solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
Highlighted
Shopify Partner
242 59 122

Hi @adios,

 

Welcome to the Shopify Community!

 

I understand that you want to have a custom message show when there is 0 items in stock.

 

I may be able to help you with this. I've updated your code to show the message, but please do verify that it works as intended.

 

Note: For the code to work, you must have these options checked for the 0 inventory products:

 

Screen Shot 2019-08-29 at 9.50.48 AM.png

 

Try this code:

 

{% if section.settings.product_quantity_message or variant.inventory_management and variant.inventory_quantity <= 0 and variant.available %}
  <div id="variantQuantity-{{ section.id }}" class="variant-quantity is-visible">
  {% include 'svg-definitions' with 'stock-icon' %}
  {% assign qty = variant.inventory_quantity %}
  {% if variant.inventory_management and variant.inventory_quantity < 10 and variant.inventory_quantity > 0 %}
    <span id="variantQuantity-{{ section.id }}__message">{{ 'products.product.only_left' | t: count: qty }}</span>
  {% elsif variant.inventory_management and variant.inventory_quantity <= 0 %}
    <span id="variantQuantity-{{ section.id }}__message">Item available from a supplier. Allow 2-3 weeks to deliver.</span>
  {% endif %}
  </div>
{% endif %}

Let me know if this works 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

0 Likes
Highlighted
New Member
12 0 0

Hi @BrianAtWork,

 

All the options are checked and code was pasted, but regrettably the message does not show up.

 

Here is the product with one of variants in stock and others out of stock.

 

Thank you for the support.

 

Regards

0 Likes
Highlighted
Shopify Partner
242 59 122

Hi @adios,

 

That is odd – the code is working for my test store.

 

Your products may be set up differently.

 

Your store would need to be accessed and your products analyzed, in order to make the appropriate changes to the code.

 

If you're interested in working together, please send me a private message or email. I'm sure @Ninthony would be willing to help you too. You may also hire help from the Shopify Experts Marketplace.

 

Cheers!

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

0 Likes
Highlighted
New Member
12 0 0

Thank you for the help.

 

Btw, I have noticed that when I am refreshing the product page I can see the message but approx after one sec it disappears. I have even managed to make a screenshot:

 

msg.JPG

 

 

 

0 Likes
Highlighted
Shopify Partner
242 59 122

@adios Sounds like an app or a theme script is overriding the product description after page load. This could also be due to the placement of your code. Depends on your theme and the apps you have installed.

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

0 Likes
Highlighted
Shopify Partner
1445 195 524

I'd be happy to help. For my solution, I was under the impression that you wouldn't need the add to cart button and that they were being informed that they could purchase it from the supplier directly. You can shoot me a message on here and if you want to let me know exactly what it is you need to do I can get back to you.

If my solution helped you, please like and accept as solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
Highlighted
New Member
12 0 0

Hello @Ninthony,

 

I would need that customers could use "add to cart" button, but before they add product to a basket they would be advised that the lead time is 2-3 weeks for the particular item (item variant).

 

As you could see above there is an information with button but unfortunately the info disappears.

0 Likes
Highlighted
Shopify Partner
1445 195 524

Can you provide a link to your store? It's got to be some kind of javascript that's hiding it which would need to be tracked down. 

If my solution helped you, please like and accept as solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D