Created
October 16, 2018 17:55
-
-
Save cameroncowden/23bf2e2260a1a818e5db49365511f948 to your computer and use it in GitHub Desktop.
A liquid snippet to sort products which are on sale and out of stock to the end of a shopify collection (per page)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign remaining = products_per_page %} | |
{% for product in collection.products limit: products_per_page %} | |
{% if product.available and product.price >= product.compare_at_price_max %} | |
{% include 'partial--product' %} | |
{% assign remaining = remaining | minus: 1 %} | |
{% endif %} | |
{% endfor %} | |
{% for product in collection.products limit: products_per_page %} | |
{% if product.compare_at_price > product.price %} | |
{% if remaining > 0 %} | |
{% include 'partial--product' %} | |
{% assign remaining = remaining | minus: 1 %} | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
{% for product in collection.products limit: products_per_page %} | |
{% if product.available == false %} | |
{% if remaining > 0 %} | |
{% include 'partial--product' %} | |
{% assign remaining = remaining | minus: 1 %} | |
{% endif %} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @cameroncowden,
Thank you for this snippet. I only have one problem with pagination. The snippet works but by page and not on the entire collection.
Do you have a solution for this situation?
Thank you very much
Audrey C.