• Resolved Bloke

    (@bloke)


    The product sort is not working on page load for just one category. I went to Status->tools and and ran “regenerate product lookup table data” but still not working.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @bloke!

    It is happening with just one category? Other products are sorted correctly?

    If this is the case, it is strange behavior.

    Could you please try performing a conflict test and check if it helps to solve the issue?

    You can do this by temporarily switching your theme back to Storefront, disabling all plugins except WooCommerce, and then check again if the issue persists.

    If that solves it, reactivate the theme first and check again. Then, reactivate your other plugins, testing after each, until you find the one causing conflict.

    If you cannot perform a conflict test on your live site, we recommend creating a staging site using the WP Staging plugin.

    You can find a more detailed explanation of how to do a conflict test here: https://docs.woocommerce.com/document/how-to-test-for-conflicts/.

    Let us know how that goes for you!

    Thread Starter Bloke

    (@bloke)

    This is the custom function I have been using. I have it on other sites. So its strange just the one category does not load by default by date order. We also changed the title to “popularity” but really its date order.

    function woocommerce_product_sort( $woocommerce_sort_orderby ) {
    
    $woocommerce_sort_orderby = str_replace("Default sorting", "Product Sorting", $woocommerce_sort_orderby);
    
        return $woocommerce_sort_orderby;
    
        }
    
        add_filter( 'woocommerce_catalog_orderby', 'woocommerce_product_sort' );
        add_filter( 'woocommerce_default_catalog_orderby_options', 'woocommerce_product_sort' );
    
     
    // Modify the default WooCommerce orderby dropdown
    //https://www.speakinginbytes.com/2016/05/customize-woocommerce-sorting-dropdown/
    
    // Options: menu_order, popularity, rating, date, price, price-desc
    
    // In this example I'm changing the default "Sort by newness" to "Sort by date: newest to oldest"
    
    function patricks_woocommerce_catalog_orderby( $orderby ) {
    	
    $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    	
    
    	$orderby["date"] = __('Sort by Popularity', 'woocommerce');
    	unset($orderby["price"]);
    	unset($orderby["price-desc"]);
    	unset($orderby["rating"]);
    	unset($orderby["popularity"]);
    	return $orderby;
    
    }
    
    add_filter( "woocommerce_catalog_orderby", "patricks_woocommerce_catalog_orderby", 20 );
    

    Hi @bloke

    Please note that this forum is intended to provide support for the default version of the WooCommerce core plugin, and guidance on developing extended functionalities falls outside our scope of support. I can recommend you these links for resources and questions on developing for WooCommerce:

    Regards

    Thread Starter Bloke

    (@bloke)

    I found the plugin that was causing the conflict. post-types-order

    Hello,

    That sounds good, thanks for letting us know.

    If you have any further questions, I recommend creating a new thread, since this one is already tagged as resolved.

    Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sort is not working on page load for just one category’ is closed to new replies.