Help with simple code (that I can’t figure out!)

Topic summary

A Shopify store owner is trying to display conditional messages on product pages based on inventory location. They currently have code showing a special order message for Ohlins products with zero inventory.

Current Goal:
Display a different message for products available only at their warehouse location (not in-store stock).

Solution Provided:
A code snippet was shared that:

  • Checks inventory across locations
  • Shows a message if product is only in warehouse stock
  • Currently targets Ohlins vendor specifically

Current Issue:
The provided code isn’t working when implemented in product.liquid, even after updating the warehouse location name to “Cykel House Warehouse”.

Additional Request:
The store owner wants to expand functionality to work with any vendor in the warehouse, not just Ohlins products.

Status: Awaiting troubleshooting help and code modification to remove vendor-specific filtering.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

So I currently have some code that puts a message on products that are supplier order only. Which is like this:

{% if product.vendor contains “Ohlins” and current_variant.inventory_quantity == 0 %}


This product is special order with Ohlins. Orders normally arrive within 1 week if in stock with our supplier, please call us on 01977 520852 if you require an ETA


{% endif %}

so what I’m wanting to do. Is put those products into a separate location. So I have 2 locations, one for the store and one for warehouse stock.

what I need help with is how I get it to put a similar message for products that are only in stock at one of the locations which is warehouse stock.

Hi @CykelHouse
Steps to Follow:

  1. Find your warehouse location name in Shopify (e.g., “Warehouse”).
  2. Add the code below to your product template (main-product.liquid).
  3. This will show a message if an Ohlins product is only in warehouse stock.

Code to Add:

{% assign warehouse_location = "Warehouse" %}
{% assign store_stock = false %}
{% assign warehouse_stock = false %}

{% for inventory in product.variants.first.inventory %}
  {% if inventory.location.name == warehouse_location and inventory.available %}
    {% assign warehouse_stock = true %}
  {% else %}
    {% assign store_stock = true %}
  {% endif %}
{% endfor %}

{% if warehouse_stock and product.vendor contains "Ohlins" and store_stock == false %}
  

    This product is only in our warehouse and may take a week to arrive.  
    Call 01977 520852 for details.
  

{% endif %}

Let me know if you need help! :blush:
Thank you

1 Like

Hey. Thanks for sending that.

I have applied it to the same place I have my other banners on the product.liquid. But it doesn’t seem to be working. I have changed warehouse location to Cykel House Warehouse. But the banner doesn’t come up.

also is there a way to make it so it does it for any vendor that’s in the warehouse and not just Ohlins.

thanks again for your help and look forward to your response.

Regards

Gavin