Liquid, JavaScript, themes, sales channels
We have a liquid code block on our product pages that is configured with a simple if/else statement to display a unique message for different inventory scenarios (i.e. In Stock - Ready to Ship, Made to Order, etc.). This block should render a new message if a certain product variant is out of stock. The code block currently works unless a product has some variants that are in stock and other variants that are out of stock.
For products with in and out of stock variants, the liquid block works if the user manually refreshes the page; however, assuming most people will not do that, we need the code block to automatically refresh when someone changes the product variant (i.e. size, color, etc.).
We are using Broadcast theme 3.7.1.
For reference, this is the liquid code snippet installed in our product page template, and these are the messages that should be automatically rendering:
{% if product.tags contains 'Made to Order' %}
<img src="{{ 'icon-blue-circle.svg' | asset_url }}" class="icon icon-box" <p> Made-to-Order - See Shipping Details Below </p>
{% elsif product.tags contains 'personalized' %}
<img src="{{ 'icon-blue-circle.svg' | asset_url }}" class="icon icon-box" <p> Personalized - See Shipping Details Below </p>
{% elsif product.tags contains '_preorder' %}
<img src="{{ 'icon-blue-circle.svg' | asset_url }}" class="icon icon-box" <p> Pre-Order - See Shipping Details Below </p>
{% elsif product.selected_variant.inventory_quantity <= 0 %}
<img src="{{ 'icon-blue-circle.svg' | asset_url }}" class="icon icon-box" <p> Made-to-Order: See Shipping Details Below </p>
{% else %}
<img src="{{ 'icon-taupe-circle.svg' | asset_url }}" class="icon icon-box" <p> In-Stock - Ready to Ship or Pickup in Showroom! </p>
{% endif %}
User | RANK |
---|---|
25 | |
22 | |
9 | |
6 | |
6 |
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023