Sort products by price (low to high) only in specific category
-
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)
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.