Liquid syntax error (line 25): 'if' tag was never closed

Liquid syntax error (line 25): 'if' tag was never closed

zack19
Visitor
3 0 0

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. 

Replies 2 (2)

Stephen_Baker
Shopify Partner
7 1 4

Change your last line to:

{% endif %}

Rajvi__patel
Shopify Partner
61 4 14

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 %}
If helpful then please Like and Accept Solution.