Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Remove some options from "Sort By" - Sense theme

Solved

Remove some options from "Sort By" - Sense theme

Iris27
Tourist
10 0 2

I would like to remove the following sort by options on my website (www.studioyouka.nl) (SENSE theme):

Alphabetical - A-Z
Alphabetical - Z-A
Date - Old to new

Can somebody tell me which code I need to use? 🙂

Accepted Solution (1)

ThePrimeWeb
Shopify Partner
2139 616 511

This is an accepted solution.

Hey @Iris27,

 

Go to your theme's "Edit Code" Option, then in the search bar type "theme.liquid"
Above the tag "</body>" tag paste the following. Screenshot attached for reference.

 

<script>
document.addEventListener('DOMContentLoaded', function() {
    try {
        const sortBySelect = document.querySelectorAll('select[name="sort_by"] option');

        for (const option of sortBySelect) {
        
          if (option.value === "title-ascending" || option.value === "title-descending" || option.value === "created-ascending") {
            option.remove();
          }
        }
    } catch {}
});
</script>

 

Screenshot for reference  

ThePrimeWeb_0-1712654812651.png

 

Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!

View solution in original post

Replies 3 (3)

ThePrimeWeb
Shopify Partner
2139 616 511

This is an accepted solution.

Hey @Iris27,

 

Go to your theme's "Edit Code" Option, then in the search bar type "theme.liquid"
Above the tag "</body>" tag paste the following. Screenshot attached for reference.

 

<script>
document.addEventListener('DOMContentLoaded', function() {
    try {
        const sortBySelect = document.querySelectorAll('select[name="sort_by"] option');

        for (const option of sortBySelect) {
        
          if (option.value === "title-ascending" || option.value === "title-descending" || option.value === "created-ascending") {
            option.remove();
          }
        }
    } catch {}
});
</script>

 

Screenshot for reference  

ThePrimeWeb_0-1712654812651.png

 

Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!
Iris27
Tourist
10 0 2

Thank you!!

menakap
Visitor
2 0 0

This solution works for the first time. Once I select the sort options say (price, low to high), disabled options come back. What would efficient event to  listen?