skip to Main Content

I need and would appreciate every help I can get. I added a bestseller collection on my Shopify store. But it displays bestseller items for all time. I only want to add bestseller items for monthly duration. How do I go about this?
Thanks for your help.

2

Answers


  1. You would render your collections using your standard collection template. You would recognize the collection is ordered by best sellers. You would inspect each product. If the product fits your criteria as "good" for the month, you let it render, otherwise you hide it. This is what Liquid is for. You decide how to judge the criteria of show/hide. You do not need NodeJS, an App or any other interfering code. Just Liquid.

    Login or Signup to reply.
  2. You can use a timestamp to filter products by date. This is done using the filter ‘%s’ to convert a date to timestamp (and thus being able to compare).

    {% assign any_given_date = 'April 14, 2022' | date: '%s' %}
    {% for product in collections['given_collection'].products %}
        {% assign created_at = product.created_at | date: '%s' %}
        {% if any_given_date < created_at %}
            Do something ...
        {% else %}
            Do else ...
        {% endif %}
    {% endfor %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search