skip to Main Content

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


  1. I’m a little puzzled by this line of code:

    {% if current_variant.inventory_management == “shopify” and current_variant.inventory_policy != “continue” %}

    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:

    div id=”variant-inventory” class=”{% unless current_variant.available %} hide {% endunless %}”>

    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

    {% unless current_variant.available %}

    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)

    {% if product.tags contains 'noOrder' %}
      <div>No inventory, customer not allowed to order' = Out of Stock</div>
      -Insert Current out of stock code here-
    {% elsif product.tags contains 'noStockCanOrder' %}
      <div>No inventory, but customer allowed to order' = Order now for delivery within 7 days</div>
      -Insert Current in stock code here-
    {% else %}
      <div>Items in stock' = We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.</div>
        -Insert Current in stock code here-
    {% endif %}
    

    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.

    Login or Signup to reply.
  2. You have:

              {% 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 %}
    

    This will show the ‘Out-of-Stock’ message for either of the following conditions:

    • inventory_management is blank (which is the default value)
    • inventory_policy is continue

    What you probably wanted was something like this:

        {% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
    
              {% comment %}
              We care about inventory on this product - is there any in stock?
              {% endcomment %}
              (% if current_variant.inventory_quantity > 0 %}
                 We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
              {% else %}
                 Out of Stock
              {% endif %}
    
        {% else %}
            {% comment %}
            Any code/messages we might want for products where we don't care about inventory
            {% endcomment %}
        {% endif %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search