• Resolved jazzu

    (@jazzu)


    Hello!

    I set that by default, all products are sorted by price – high to low.

    I want to change that only for 1 category. We sell pools and pool equipment, so I want to change that everything within the Pools (Bazeni) category is sorted from low to high. I tried few codes that I found, but had no luck. Here’s an example:

    add_filter('woocommerce_get_catalog_ordering_args', 'tk_woocommerce_catalog_orderby');
    function tk_woocommerce_catalog_orderby( $args ) {
        if( is_product_category( 'bazeni' ) ) {
            $args['orderby']  = 'meta_value_num';
            $args['order']    = 'DESC';
            $args['meta_key'] = '_price'; 
        }
        return $args;
    }

    I tried changing the product category from ‘bazeni’ to a directory (subcategory) that has products inside of it, yet, still nothing changed.

    Kind regards

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @jazzu

    Thanks for reaching out.

    by default, all products are sorted by price – high to low

    You have a choice there. You could also select one of the other options from the list as shown below:

    IMAGE
    Link to image: https://snipboard.io/o2jJLV.jpg

    However, whichever one you choose it will be effective on all categories.

    As a solution for your specific requirement you are already doing the right thing – using custom code.

    Kindly be informed that custom coding goes beyond the scope of support we are able to provide in this forum.

    I can recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    This specific forum is more focused on the default WooCommerce core features.

    Lastly, for direct assistance with code customizations, I recommend consulting with the WooCommerce Customizations Partners. https://woocommerce.com/customizations/

    Nevertheless, I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    Seems we’ve not had additional inputs on this thread. Thus, we encourage you to make use of the above resources.

    I’ll go ahead and mark the thread as resolved but please feel free to create a new thread if you have further questions.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sort products by price (low to high) only in specific category’ is closed to new replies.