Custom Sorting By Numeric Meta Value
-
I have written some code to add a custom sort order by meta value to the shop page. The data to sort by is a member product price, it displays the products with member prices by it does not sort by the value.
Here is the code
add_filter('woocommerce_get_catalog_ordering_args', 'es_add_catalog_order_args_member_price'); function es_add_catalog_order_args_member_price($args) { if(isset( $_GET['orderby'] )) { $orderby_value = woocommerce_clean( $_GET['orderby'] ); } if($orderby_value == 'member_price') { $args['meta_key'] = 'member_price'; $args['order'] = 'ASC'; $args['order_by'] = 'meta_value_num'; } return $args; }Cheers!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Custom Sorting By Numeric Meta Value’ is closed to new replies.