Int to string Conversion

Highlighted
New Member
3 0 0

Hi guys,

   Could anyone tell how can convert Int to string in dotliquid ?

 

Thank you.

0 Likes
Highlighted
Shopify Partner
1 0 0

Number/int to string:

{% assign variablename = variablename | downcase %}

String to number:

{% assign variablename = variablename | plus:0 %}

SebastianStoll.com - Professional Shopify partner.
0 Likes
Highlighted
New Member
3 0 0

Thank you Sebastian.

Suppose, int Id = 1000, if i int Id convert to string , is it happens "1000" ?

0 Likes
Highlighted
Shopify Expert
9933 106 1768

Sidenote: Please don't use this method anymore. It's a legacy approach that's been replaced by a direct filter.

{% assign variablename = variablename | plus:0 %}

Use abs instead.

{% assign variablename = variablename | abs %}

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
New Member
3 0 0

Hi Jason,

    Thank you. Actually my problem is , i have a Int variable Suppose Id. Id is a incremental variable. This Id variable will append end of a string. then id variable increment continue. Lets see an example:

 {% assign Id = 1 %}

 {{ "Here is Id: " |   append: Id}} -----> So, id need to convert string

{% assign Id= Id | plus: 1 %}

 {{ "Here is Id: " |   append: Id}} -----> So,here  id need to convert also a string

This event will happen through a for loop.

Thank u again.

 

0 Likes