how to add one variable to another shopify

tailaitai
Shopify Partner
5 0 1

i need to add number to variable like in simple javascript:

var a = 100

var b = 200

var c = a + b

but in shopify liquid code:

{% assign total_price = cart_price + shipping_price %}

tailaitai_0-1651509409502.png

i have following error

how to fix it

Reply 1 (1)

rsaberon
Shopify Partner
12 1 1

you can try converting the variables into integer, you can defined this by doing
{% liquid

assign cartPrice = cart_price | plus: 0 

assign shippingPrice = shipping_price | plus: 0

assign total_price = cartPrice + shippingPrice

%}