Sanu Web Developer
Sanu Web Developer

Reputation: 43

Woocommerce default sorting is not working

I am using Woocommerce plugin with wordpress and getting issue in sorting. When i was try to sort with select option, page not reloading. I think this is some JavaScript issue, please help me to rectify his issue.

This is the HTML code:

<form class="woocommerce-ordering" method="get">
    <select name="orderby" class="orderby">
                    <option value="popularity">Sort by popularity</option>
                    <option value="rating">Sort by average rating</option>
                    <option value="date">Sort by latest</option>
                    <option value="price" selected="selected">Sort by price: low to high</option>
                    <option value="price-desc">Sort by price: high to low</option>
            </select>
    <input type="hidden" name="paged" value="1">
    </form>

Upvotes: 1

Views: 1883

Answers (1)

Sanu
Sanu

Reputation: 330

You can simply put this javascript function to your footer.

$(function() {
    $('.woocommerce-ordering select').change(function() {
        this.form.submit();
    });
});

Upvotes: 1

Related Questions