Last active
May 8, 2024 16:10
-
-
Save jonathanmoore/626ecc74561b218331c0389969dc80c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% liquid | |
assign low_stock_threshold = 5 | |
assign selling_fast_threshold = 12 | |
assign low_stock_status = "Low stock" | |
assign selling_fast_status = "Selling fast" | |
assign in_stock_status = "In stock" | |
assign low_stock_color = "#FFD700" | |
assign selling_fast_color = "#008000" | |
assign in_stock_color = "#808080" | |
assign stock_status = in_stock_status | |
assign stock_color = in_stock_color | |
if product.selected_or_first_available_variant.inventory_management and product.selected_or_first_available_variant.inventory_quantity > 0 | |
if product.selected_or_first_available_variant.inventory_quantity < low_stock_threshold | |
assign stock_status = low_stock_status | |
assign stock_color = low_stock_color | |
elsif product.selected_or_first_available_variant.inventory_quantity <= selling_fast_threshold | |
assign stock_status = selling_fast_status | |
assign stock_color = selling_fast_color | |
endif | |
endif | |
%} | |
<div class="product__inventory rte rte-sm"> | |
{% if product.selected_or_first_available_variant.inventory_quantity > 0 and product.selected_or_first_available_variant.available %} | |
<span style="height: 10px; width: 10px; background-color: {{ stock_color }}; border-radius: 50%; display: inline-block; margin-right: 5px;"></span> | |
{{ stock_status }}: {{ product.selected_or_first_available_variant.inventory_quantity }} available | |
{% endif %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment