Personalized checkout and custom promotions with Shopify Scripts
I'm trying to figure out what's wrong with my code here. I keep getting "Liquid syntax error (line 25): 'if' tag was never closed"
{% liquid
assign low_stock_count = 10
assign text_stock_low = '<b>[count] items</b> are left in stock!'
assign color_stock_low = '#000000'
assign width_stock_low = '10%'
assign text_stock_none = 'This item is sold out.'
assign color_stock_none = '#000000'
%}
{% if request.page_type == 'product' and product.tags contains 'stock-indicator-bar' and product.selected_or_first_available_variant == 'deny' %}
{% liquid
assign current_variant = product.selected_or_first_available_variant
if current_variant.inventory_quantity <= 0
assign text = text_stock_none
assign color = color_stock_none
elsif current_variant.inventory_quantity <= low_stock_count
assign text = text_stock_low | replace: '[count]', current_variant.inventory_quantity
assign color = color_stock_low
assign width = width_stock_low
endif %}
Line 25 is the last line.
Change your last line to:
{% endif %}
Hello @zack19
Please replace your code with this,
{% liquid
assign low_stock_count = 10
assign text_stock_low = '<b>[count] items</b> are left in stock!'
assign color_stock_low = '#000000'
assign width_stock_low = '10%'
assign text_stock_none = 'This item is sold out.'
assign color_stock_none = '#000000'
%}
{% if request.page_type == 'product' and product.tags contains 'stock-indicator-bar' and product.selected_or_first_available_variant == 'deny' %}
{% liquid
assign current_variant = product.selected_or_first_available_variant
if current_variant.inventory_quantity <= 0
assign text = text_stock_none
assign color = color_stock_none
elsif current_variant.inventory_quantity <= low_stock_count
assign text = text_stock_low | replace: '[count]', current_variant.inventory_quantity
assign color = color_stock_low
assign width = width_stock_low
endif %}
{% endif %}
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025