Sorting shop by 2 meta_keys
-
Hi, I tried to change default sort to achieve sorting by 2 meta_keys. I want to have out of stock products at the end of products list:
add_filter('woocommerce_get_catalog_ordering_args', 'custom_catalog_ordering_args'); function custom_catalog_ordering_args($args) { global $wp_query; $orderby = $args['orderby']; $order = $args['order']; $args['order'] = ''; $args['meta_key'] = '_stock_status'; $args['orderby'] = array('meta_value' => 'ASC', $orderby => $order); return $args; }
But i does not work. Is there a possibility to do this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Sorting shop by 2 meta_keys’ is closed to new replies.