Skip to content

Instantly share code, notes, and snippets.

@tpage99
Created October 3, 2023 20:26
Show Gist options
  • Save tpage99/3f8f6e5f3e8601d5d62de61955343f41 to your computer and use it in GitHub Desktop.
Save tpage99/3f8f6e5f3e8601d5d62de61955343f41 to your computer and use it in GitHub Desktop.
Create a random number with Liquid for Customer Testimonials Metaobject
{% comment %}
my_reviews is an array of metaobjects assigned via metafields
{% endcomment %}
{% liquid
assign review_min = 1
assign review_max = my_reviews.size
assign mod_ref = review_max | minus: review_min
assign random_number = "now" | date: "%N" | modulo: mod_ref | plus: review_min
assign review = my_reviews[random_number]
%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment