Issue in deleting items from 'Sort By' drop down

Issue in deleting items from 'Sort By' drop down

CNDY_123
Excursionist
50 0 5

Hi

 

I had pasted a code in theme.liquid to delete some items from the "Sort by" menu. 

 

The code is working fine when im checking from my system(windows) and phone(android) but when i check from my friends Macbook and iPhone, the sort by options are still there. (Please check images attached)

The code i used : 

 

<style> option[value="title-ascending"], option[value="best-selling"], option[value="title-descending"], option[value="created-ascending"], option[value="created-descending"] { display: none !important; } </style>

Check Images

1) "Sort by" as seen from my system

2) "Sort by" seen from Macbook

 

IMG-20241105-WA0021.jpgScreenshot 2024-11-05 201345.png

 

 

 

Replies 5 (5)

Mehran_Ali
Shopify Partner
462 63 70

Hi @CNDY_123 

 

You're doing it using CSS, so it might still appear when searching from a friend’s phone or desktop. This could be due to reasons like cached webkets, etc


To remove the sort option in the Dawn theme, follow these steps:

  • Go to your Online Store in Shopify.
  • Navigate to Theme.
  • Click the three dots next to the theme and select Edit Code.
  • In the code editor, search for the file named main-collection-product-grid.liquid. (In the Dawn theme, this file may be named slightly differently, but it should be similar.) Inside this file,

look for the sort code, which should resemble the following:

<select
    name="sort_by"
    class="facet-filters__sort select__select caption-large"
    id="SortBy"
    aria-describedby="a11y-refresh-page-message"
>
    {%- for option in collection.sort_options -%}
        <option
            value="{{ option.value | escape }}"
            {% if option.value == sort_by %}
                selected="selected"
            {% endif %}
        >
            {{ option.name | escape }}
        </option>
    {%- endfor -%}
</select>

 

Carefully replace this with this:  

<select
    name="sort_by"
    class="facet-filters__sort select__select caption-large"
    id="SortBy"
    aria-describedby="a11y-refresh-page-message"
>
    {%- for option in collection.sort_options -%}
        {%- unless option.value == "title-ascending" or option.value == "best-selling" or option.value == "title-descending" or option.value == "created-ascending" or option.value == "created-descending" -%}
            <option
                value="{{ option.value | escape }}"
                {% if option.value == sort_by %}
                    selected="selected"
                {% endif %}
            >
                {{ option.name | escape }}
            </option>
        {%- endunless -%}
    {%- endfor -%}
</select>

 
If you have any problem let me know

-If this solution helps you, kindly LIKE THIS REPLY and MARK AS A SOLUTION OR

Buying Me A Coffee.

-If you need an expert Shopify developer for customization and development, feel free to contact me.


Email: Mehran.ali5300@gmail.com


WhatsApp: +92 343 0211536

CNDY_123
Excursionist
50 0 5

Hi @Mehran_Ali 

 

Tried pasting the code exactly..but didnt work...Its not changing anything..

Mehran_Ali
Shopify Partner
462 63 70

Okay i can check that if you can share the collaboration code to me

-If this solution helps you, kindly LIKE THIS REPLY and MARK AS A SOLUTION OR

Buying Me A Coffee.

-If you need an expert Shopify developer for customization and development, feel free to contact me.


Email: Mehran.ali5300@gmail.com


WhatsApp: +92 343 0211536

CNDY_123
Excursionist
50 0 5

hi @Mehran_Ali 

 

The above code actually worked...The issue was only with one system...when checked from another systems the issue is not there...

 

Thank You for your valuable time!

Mehran_Ali
Shopify Partner
462 63 70

great if the above sooution working kindly mark it as solution 

-If this solution helps you, kindly LIKE THIS REPLY and MARK AS A SOLUTION OR

Buying Me A Coffee.

-If you need an expert Shopify developer for customization and development, feel free to contact me.


Email: Mehran.ali5300@gmail.com


WhatsApp: +92 343 0211536