How to Generate Random Numbers in Shopify liquid
by Kiet Huynh · January 23, 2021
Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy the first month of Shopify for $1.
Today I am sharing a script code to create a random number in Shopify liquid.
| {%- assign min = 1 -%} {%- assign max = 100 -%} {%- assign diff = max | minus: min -%} {%- assign random_number = "now" | date: "%N" | modulo: diff | plus: min -%} {{ random_number }} |
And here is an example, generate a random number from 1 to 100. Wanna change the range, just edit value of min and max.
I hope it’s helpful for you.
Happy coding.
Related
Related Posts via Categories
Looking for Shopify Experts?
Hura Apps can help you take your store to the next level
Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.
Get in touchTags: liquidliquid codeLiquid Template LanguagerandomRandom NumbersShopify liquid
You may also like...