a shopify function develop ,we want use custom sort on collection page
Budget: $30 – $250 USD
a Shopify function develop,we want to use custom sort on the collection page
we want to add this code to our theme
<!-- CUSTOM PRODUCTS display -->
{% assign handles = '' %}
{% assign handleSize = 0 %}
{% if current_page == 1 %}
{% assign handles = collection.sort_by | downcase | replace:'%2C',',' | replace:'%2c',',' | split: ',' %}
{% for handle in handles %}
{%- assign product = all_products[handle] -%}
{% if product != empty %}
{% assign handleSize = handleSize|plus: 1 %}
{% assign featured = product %}
{% include 'product-grid-item' %}
{% endif %}
{% endfor %}
{% endif %}
<!-- CUSTOM PRODUCTS display end -->
<!-- default products display -->
{%- for product in collection.products -%}
{% if handles contains product.handle %}
{% continue %}
{% else %}
{% assign productIndex = productIndex | plus: 1 %}
{% if productIndex > productSize %}
{% continue %}
{% else %}
{% assign featured = product %}
{% include 'product-grid-item' %}
{% endif %}
{% endif %}
{%- endfor -%}
<!-- default products display end -->
we want to add this code to our theme
<!-- CUSTOM PRODUCTS display -->
{% assign handles = '' %}
{% assign handleSize = 0 %}
{% if current_page == 1 %}
{% assign handles = collection.sort_by | downcase | replace:'%2C',',' | replace:'%2c',',' | split: ',' %}
{% for handle in handles %}
{%- assign product = all_products[handle] -%}
{% if product != empty %}
{% assign handleSize = handleSize|plus: 1 %}
{% assign featured = product %}
{% include 'product-grid-item' %}
{% endif %}
{% endfor %}
{% endif %}
<!-- CUSTOM PRODUCTS display end -->
<!-- default products display -->
{%- for product in collection.products -%}
{% if handles contains product.handle %}
{% continue %}
{% else %}
{% assign productIndex = productIndex | plus: 1 %}
{% if productIndex > productSize %}
{% continue %}
{% else %}
{% assign featured = product %}
{% include 'product-grid-item' %}
{% endif %}
{% endif %}
{%- endfor -%}
<!-- default products display end -->