Display message when "Continue selling when out of stock" is checked and inventory is <= 0

jnlong
New Member
6 0 0

I'm trying to display a message on my product page that says, "Available on backorder" for items that have "Continue selling when out of stock" is checked in admin, and inventory is equal to or less than 0. I'm using the Debut theme.

 

Replies 8 (8)

jnlong
New Member
6 0 0

I got it to work by adding the following code to the product-template.liquid file:

<div class="productStatus">
   {% if current_variant.available and current_variant.inventory_quantity > 0 %}
      <span class="statusAvailable">Available</span>
   {% endif %}
   {% if current_variant.available and current_variant.inventory_quantity <= 0 %}
      <span class="statusBackorder">Available on backorder. Please allow 2-3 weeks for delivery</span>
   {% endif %}
</div>

 

Jasperfoller
New Member
9 0 0

hey in what part of the code did you enter this in.

 

kfurn
Visitor
1 0 0

Where did you enter this in the code?

jnlong
New Member
6 0 0

You can enter this code wherever you want it to display on your product page. I placed it just below the product name as shown here. 

product-page-example.pngcode-screen-shot.png

CodeLogic21
Visitor
1 0 0
<div class="productStatus">
   {% if current_variant.available and current_variant.inventory_quantity > 0 %}
      <span class="statusAvailable">Available</span>
   {% endif %}
   {% if current_variant.available and current_variant.inventory_quantity <= 0 %}
      <span class="statusBackorder">Available on backorder. Please allow 2-3 weeks for delivery</span>
   {% endif %}
</div>

it works with products which dont have variants. For variants products it do not update the text
chapi15
Visitor
1 0 0

Do you know if this could be done in the new theme of Shopify? I believe it is called "Dawn", or something like that

Chrissyking
Excursionist
12 0 4

Is there a way to get this to work with variants?

Hey_Jak
Shopify Partner
96 6 13

Hope someone will find it helpful.

Jak | Top Rated Shopify Dev @ Upwork
- Shopify Blog
- Check my youtube: Hey Jak
Was your question answered? Mark it as an Accepted Solution.