Solved

How to Randomize The Collection Products Every Time Any Costumer Visit The Site

maxze1
Excursionist
26 0 4

norzana.com

Accepted Solution (1)

AvadaCommerce
Shopify Partner
3879 839 965

This is an accepted solution.

Hi @maxze1 

 

Hope you are doing great!

 

At this time, the 'collections/all' page isn't built to let you modify the order the products are placed in. This collection will always showcase your products in an alphabetical order. That said, there is a workaround you can try! 

 

What you will want to do is to create a new collection that has all your products in it, don't you?

You can see the steps on how to create a collection on this page in our Shopify Manual. Once this collection is created, you can change the order of the products to go in any order you want. It can be manual, newest, best selling, etc. Once you decide on the order you want your products to appear in, you can go through your store and update any links so that instead of people seeing the old all products page, they will see the new one you created instead. 

 

I hope this helps! If you feel like my answer is helpful, please give it a LIKE or mark it as a SOLUTION.

Let me know if you have any questions

banned

View solution in original post

Replies 8 (8)

AvadaCommerce
Shopify Partner
3879 839 965

This is an accepted solution.

Hi @maxze1 

 

Hope you are doing great!

 

At this time, the 'collections/all' page isn't built to let you modify the order the products are placed in. This collection will always showcase your products in an alphabetical order. That said, there is a workaround you can try! 

 

What you will want to do is to create a new collection that has all your products in it, don't you?

You can see the steps on how to create a collection on this page in our Shopify Manual. Once this collection is created, you can change the order of the products to go in any order you want. It can be manual, newest, best selling, etc. Once you decide on the order you want your products to appear in, you can go through your store and update any links so that instead of people seeing the old all products page, they will see the new one you created instead. 

 

I hope this helps! If you feel like my answer is helpful, please give it a LIKE or mark it as a SOLUTION.

Let me know if you have any questions

banned
ChrisYAY
Tourist
3 0 4

This does not answer the question!

The solution says to choose the order that you want, but it will not be random as requested.

 

This would be a great feature for Shopify to add.

LeinaBroughton
Visitor
2 0 1

Hi @ChrisYAY did you get anywhere with this? Did you find a way to randomise product order?

ChrisYAY
Tourist
3 0 4
Nope. We really like the idea, but it's not worth the time/expense for us.
LeinaBroughton
Visitor
2 0 1

Yes us too! 

jtraverso
Shopify Partner
9 0 3

Is not that simple to create a Random Order for a Collection, but I have found a quite close, and in my opinion, very similar solution.

 

In my store I have a collection "New arrivals", I want the shop to show some Random products from that collection, not the same every time.

 

So the solution I came by is not to select them all at random, but to randomly select a point to start and skip the products up to that point, for example if your collection have 100 products, and you want to show 8, you can select any number between 1 to 92 and show 8 products from there.

 

Is not exactly random, and because Shopify have cache It wont show different results every time, but it will change several times in an hour and show different products to regular visitors to your store in that section, so it solves the neccesity.

 

How this works:


Firstly, calculate a random start index based on the current time and ensure it's within the range to display the full set of products you want:

 

{% assign total_products = collection.products.size %}

{% assign max_start = total_products | minus: length %}

{% assign start_index = "now" | date: "%S" | modulo: max_start %}

 

In this code, length is the number of products you wish to display. We use the current second to generate a random number, ensuring the starting index plus the product count doesn't exceed the total available products.

 

Next, iterate over your collection's products and start displaying them only when the loop's index reaches the randomly chosen starting point:

 

{% assign products_shown = 0 %}
{% for product in collection.products %}
{% if forloop.index0 >= start_index %}
<!-- Insert your product display code here -->
{% assign products_shown = products_shown | plus: 1 %}
{% if products_shown >= length %}{% break %}{% endif %}
{% endif %}
{% endfor %}

 

Here, we're controlling the flow with if conditions to start showing products only after hitting our start_index and to stop after displaying the desired number of products (length).

 

This approach keeps your product display efficient while adding a dynamic touch to your Shopify collection pages. It's a simple solution that keeps the user experience fresh without requiring complex coding or external tools.

 

Hope this helps!

 

Giorgi1
Tourist
3 0 0

hello, can you help me to put this codes on right place please ^_^ 

 

jtraverso
Shopify Partner
9 0 3

Hi| I posted an example here: https://mentedigital.cl/anade-seccion-con-productos-aleatorios-a-tu-tema-shopify/ it´s in Spanish but you can translate it on the browser, it has the full code I used on my theme to display random productos on my Shopify Sore Homepage.