Home / Forums / WoodMart support forum / Critical Issue with Product Sorting in Woodmart Product Grid Widget
Home › Forums › WoodMart support forum › Critical Issue with Product Sorting in Woodmart Product Grid Widget
Critical Issue with Product Sorting in Woodmart Product Grid Widget
- This topic has 1 reply, 2 voices, and was last updated 3 months, 1 week ago by
Artem Temos.
-
AuthorPosts
-
March 24, 2026 at 2:01 pm #713916
peteris.naglisParticipantDear Woodmart Support Team,
We are experiencing a critical database error when attempting to implement custom product sorting functionality on our WooCommerce store using the Woodmart “Edit Products (grid or carousel)” widget.
**ISSUE DESCRIPTION:**
When we try to modify the SQL ORDER BY clause to sort products by discount percentage, we receive the following error:“WordPress database error: [Unknown column ‘pm_discount.meta_value’ in ‘ORDER BY’]”
**ERROR QUERY:**
The failing query shows that the LEFT JOIN for the postmeta table is NOT being included in the final SQL query, even though we’ve properly added it via theposts_joinfilter. This causes the ORDER BY clause to reference a column that doesn’t exist in the query.**ROOT CAUSE:**
It appears that the Woodmart product grid widget uses its own custom query builder (possibly via AJAX or a custom query handler) that:
1. Does not respect the standard WordPressposts_orderbyfilter
2. Does not properly merge JOINs added via theposts_joinfilter
3. Pre-calculates the product ID list, then runs a separate query with WHERE … ID IN (…)This prevents any custom ORDER BY modifications from working correctly.
**AFFECTED QUERY STRUCTURE:**
`sql
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.ID IN (27818, 27819, 27820, …)
AND wp_posts.post_type = ‘product’
AND wp_posts.post_status = ‘publish’
GROUP BY wp_posts.ID
ORDER BY CAST(pm_discount.meta_value AS SIGNED) DESC
— NOTE: No LEFT JOIN is present, so pm_discount.meta_value is undefined
OUR ATTEMPTED SOLUTIONS: We have tried multiple approaches:Using posts_join and posts_orderby filters
Using woocommerce_product_query_meta_query filter
Using subqueries with COALESCE
Using alternative meta_query approaches
NONE of these work because the Woodmart widget appears to bypass these standard WordPress hooks.REQUEST: Could you please:
Clarify which hooks/filters the Woodmart product grid widget respects for custom sorting
Provide a documented method for implementing custom ORDER BY logic in product grids
Or, consider fixing the widget to properly merge JOINs from custom filters
WORKAROUND NEEDED: We need an alternative method to sort products by discount percentage within the Woodmart product grid widget that doesn’t rely on modifying the SQL query directly.Thank you for your assistance.
Best regards, [Peteris Naglis]
March 24, 2026 at 2:22 pm #713926Hi Peteris,
Thanks for the detailed report.
The issue you’re seeing is tied to custom code that alters query parts and theme files. Customizations like this are outside our support scope.
About the widget behavior and hooks:
– WoodMart product grids and the Archive Products element use the standard WooCommerce sorting options available in the interface: popularity, price, name, rating, and date. There is no built-in option to sort by a custom metric like discount percentage.
– There isn’t a documented hook in our product grid/widget to inject custom SQL JOINs or override ORDER BY logic for meta-based sorting. The widget does not provide a method to merge custom JOINs added via posts_join or to implement custom ORDER BY for discount percentage.
– You can control which default options appear in the WooCommerce sorting dropdown with the woocommerce_catalog_orderby filter (for example, to remove unwanted options), but adding a fully custom meta-based sort to the grid via our widget isn’t supported.We don’t have a built-in workaround in the widget to sort by discount percentage. Implementing that would require custom development outside the theme’s standard options.
Kind Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register