Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Convert a String to float/decimal?

Solved

Convert a String to float/decimal using liquid?

kallenconsult
Shopify Partner
65 1 21

I feel embarrassed by asking this question but I can't seem to find a string filter that will convert to a float/decimal number.  I know the to_i does a nice conversion to int--but I tried to_f, float, decimal, etc. with no luck.  I've googled my brains out thinking it is such a basic function but have only found folks talking about converting a float to a string, not the other way around.

 

My Google-Fu has failed me.  All help is appreciated!

Accepted Solution (1)
Alex520
Shopify Partner
15 2 5

This is an accepted solution.

float_number = string_number | times: 1.0
Alex - Developer
Available for Hire

View solution in original post

Replies 4 (4)

Alex520
Shopify Partner
15 2 5

I assume javascript?

 

parseFloat()?

Alex - Developer
Available for Hire
kallenconsult
Shopify Partner
65 1 21

My apologies.  I meant using liquid--I know I could do it using javascript.  Just looking for a cleaner approach.  I have updated the title.

Alex520
Shopify Partner
15 2 5

This is an accepted solution.

float_number = string_number | times: 1.0
Alex - Developer
Available for Hire
kallenconsult
Shopify Partner
65 1 21

Thanks!  That works.