0

I need to add query string from select option to sort out products as "Price Low to High" as default option when page load, here you can check products showing in collection t-shirt https://soft-theme.myshopify.com/collections/t-shirts and default option is "Newest to Oldest" and I want to change this "Price Low to High" as default option as you can see from dropdown of Sort By when we select "Price Low to high" its get change to https://soft-theme.myshopify.com/collections/t-shirts?sort_by=price-ascending

I just want this as default when page open first time.

http://prntscr.com/ehqmep

1 Answer 1

1

You can do this by trigger a specific event you want to show by default in jquery. First provide the ID to the dropdown li like

<ul class="dropdown-menu" role="menu" selected="selected">
        <li><a id="id1" href="manual">Featured</a></li>
        <li><a id="id2" id="test" href="price-ascending">Price: Low to High</a></li>
        <li><a id="id3" href="price-descending">Price: High to Low</a></li>
        <li><a id="id4" href="title-ascending">A-Z</a></li>
        <li><a id="id5" href="title-descending">Z-A</a></li>
        <li><a id="id6" href="created-ascending">Oldest to Newest</a></li>
        <li><a id="id7" href="created-descending">Newest to Oldest</a></li>
        <li><a id="id8" href="best-selling">Best Selling</a></li>
      </ul>

Then in jquery document ready function trigger the event like below

$(function(){
    $("#id2").click(); //as price low to high
});
Sign up to request clarification or add additional context in comments.

2 Comments

I need it to change on page load not on click
call this on page load: $("#id2").click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.