I’ve spent much of the day setting up a new shopify site – my first experience with shopify. Most of it has been pretty straightfoward, but I’ve found myself somewhat stumped when it comes to showing inventory on the product pages. I’m using the debut theme, and using the editor to update ‘product-template.liquid’
After browsing the docs, I’ve added the following;
{% 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" %}
We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
</div>
However, this is currently returning ‘out of stock’ for items that are in fact, in stock. In addition, what I am hoping to achieve but haven’t been able to find documentation for is;
- ‘Items in stock’ = We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
- ‘No inventory, but customer allowed to order’ = Order now for delivery within 7 days
- ‘No inventory, customer not allowed to order’ = Out of Stock
Any pointers much appreciated!
2
Answers
I’m a little puzzled by this line of code:
What you are checking is if you are using shopify to track inventory and if the variant options command to allow people to order even if it is out of stock is checked in the admin panel. I would assume that the latter is checked so it is always returning the else.
If it wasn’t in stock nothing would show due to this line:
As I am unsure how you plan to differentiate between the out of stock and the out of stock can order in 7 days. As there is nothing in the inventory tracker that allows you to enter incoming product (As far as I know). If you were so inclined to enter this manually you could go to product.template.liquid find Ctrl + F
The Second one down is where to sold-out code takes place
and edit it through adding and removing tags (Using noOrder and noStockCanOrder as example tags)
You may have to play around with this a little bit as I have never done exactly what you are asking but the theory should be sound and it should get you close to what you want and you can edit it from there.
You have:
This will show the ‘Out-of-Stock’ message for either of the following conditions:
inventory_management
isblank
(which is the default value)inventory_policy
iscontinue
What you probably wanted was something like this: