我有标准的 Shopify 主题 Minimal。产品被分配到系列。
每个产品上的相关商品仅显示在相关集合中找到的前 4 件商品。由于每个系列中有很多商品,很多时候数百种产品中的相关商品都是完全相同的。
如何编辑代码以随机化相关产品的结果?
最佳答案
Steph 的答案更好,但也有一个非 javascript(也不是真正随机的,但我无论如何喜欢它)解决方案来破解日期:
{% assign relatedCollection = collections['related-products'] %}
{% assign index = 'now' | date: '%S' %}
{% assign index = index | times: relatedCollection.products.size %}
{% assign index = index | divided_by: 60 %}
{% for product in relatedCollection.products offset: index %}
...
{% endfor %}
关于shopify - 如何在 Shopify 中随机化相关产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19274489/