Sorting by price does not work when plugin is active
-
I believe I found a bug in the code of the plugin.
When choosing to sort the products by price (default WC functionality) and this plugin is active, the sorting will not work. The reason is that the
orderby
WP query attribute is not set properly and items are sorted by menu_order.The problematic code is here from file
wp-content/plugins/themify-wc-product-filter/public/class-wpf-public.php
around line 395:} else { $temp = explode( ' ', $query_args['orderby']); $temp_o = !empty($query_args['order']) ? $query_args['order'] : 'DESC'; $query_args['orderby'] = array( 'menu_order' => 'ASC' ); foreach ( $temp as $v) { $query_args['orderby'][$v] = $temp_o; } }
it should be changed to this:
} else { $temp = explode( ' ', $query_args['orderby']); $temp_o = !empty($query_args['order']) ? $query_args['order'] : 'DESC'; $query_args['orderby'] = array(); foreach ( $temp as $v) { $query_args['orderby'][$v] = $temp_o; } $query_args['orderby']['menu_order'] = 'ASC'; }
My code sets the
orderby
as an empty array first, then fills the orderby array and at the end it adds the menu_order as a default/fallback – not sure if that’s even needed tho.Can you confirm this and will you update the plugin code to fix this? Thank you!
- The topic ‘Sorting by price does not work when plugin is active’ is closed to new replies.