Skip to content
Advertisement

Sort by custom meta value doesn’t work in WooCommerce products sort by

I’m trying to add a sorting option for woocommerce products’s list.

The goal is to sort products by a meta value with meta key called _rating. For now I generate this meta value with a function executed at plugin’s activation.

Issue :

Products are not sorted by meta value but by ID instead

My plugin :

JavaScript

Advertisement

Answer

I tested your code and at first sight nothing seemed wrong but the desired result was not forthcoming. When I replaced rating with something like rank this seems to work.

This is because rating is already in use by “Sort by average rating”

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement