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

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

CykelHouse
Excursionist
28 0 6

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

<br>
<p style="color:#FF0000";> 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 </p>
</body>
<br>
{% 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. 

Replies 2 (2)

sadik_ShopiDevs
Shopify Partner
40 5 14

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 %}
  <p style="color:#FF0000";>
    This product is only in our warehouse and may take a week to arrive.  
    Call 01977 520852 for details.
  </p>
{% endif %}

 


Let me know if you need help! 😊
Thank you

Found it helpful? Please like and mark the solution that helped you.
Slider Revolution - Create sliders, theme sections, banners, videos, pages, advanced animation, and social feeds.
Essential Grid Gallery - Create photo galleries, video galleries, portfolio galleries, product gallery, collection gallery and more.
EasyDisplay: Product Showcase - Easily display collections, related products, discounts, recently viewed items, and best sellers
CykelHouse
Excursionist
28 0 6

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