How to Add a "Discounted Products" Sort Option and Remove "Alphabetical Order" in Product Collection

How to Add a "Discounted Products" Sort Option and Remove "Alphabetical Order" in Product Collection

premsai
Tourist
30 0 3

I want to customize the Sort By options in my product collection.  Add a "Discounted Products" sort option to show items with discounts first.  Remove the "Alphabetical Order" sort option from the list. I'm currently using the Ella theme. Rivaaj Ethnic 

premsai_0-1734155383736.png

 

 

 

Reply 1 (1)

DitalTek
Shopify Partner
842 100 119

 

Hi,

 

In this theme we have no option to customize this short option as its generating by Shopify.

But we can do some custom code to remove some option.

Like this:

1. Open Section->collection-template.liquid and then find 'collection.sort_options'

Now add unless condition like below so they can remove added option from box.

 

{% for option in collection.sort_options %}
       {% unless option.value contains 'title-ascending' or option.value contains 'title-descending' %}
              <option value="{{ option.value }}"{% if sort_by == option.value %} selected="selected"{% endif %}>{{ option.name }}</option>
       {% endunless %}
{% endfor %}

So here they remove 'Alphabetically, A-Z' and Alphabetically, Z-A option.

 

You have to add condition in below line more if you want to hide option

 

 {% unless option.value contains 'title-ascending' or option.value contains 'title-descending' %}

You can use following option in condition:

1. manual

2. best-selling

3. title-ascending

4. title-descending

5. price-ascending

6. price-descending

7. created-ascending

8. created-descending

- You can please Like and Accepted Solution if my suggestion helpful.
- And you want to hire developer Theme or App Shopify => Feel free to send me a DM or contact to us via Email | WhatApp