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 %}
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023