So currently when the query is set to use ‘Products’, then under the ‘Order’ tab, there is no way for us to set Order By to either WooCommerce’s menu_order meta (the WooCommerce sorting), or a way for us to enter the meta key for this ‘menu_order’. If I use dynamic data, select sorce to WordPress → Custom field, then enter the meta key ‘menu_order’, it makes no affect of the query in terms of the orders.
Then if I use a function filter from Cwicly and try to use the meta field ‘menu_order’ from WooCommerce, it returns no products at all as my Query is using Frontend rendering.
Here is the code I tried:
add_filter(‘cwicly/query/args’, function ($query_args, $attributes, $id) {
// Modify the query arguments for your specific Query block
if ($id === ‘query-c2a5cb6’) {
$query_args[‘orderby’] = array(
‘meta_value_num’ => ‘ASC’, // Order by host-time custom field
);
$query_args[‘meta_key’] = ‘menu_order’; // Meta key for host-time custom field
}
return $query_args;
}, 10, 3);
So, is there any way to fix this or a way to workaround to make the Order sorting to work based on the default WooCommerce’s order_menu meta?
Well, its been almost a month so i came up with my own solution, which is to write a function and create a custom field, and run the function with cronjob to copy whatever the menu_order’s valuevto my custom field, and then use order by in query taccording to my custom field.
I don’t know why but i think WooCommerce should get more attention from Cwicly team. I personally coded a lot of custom function to make Cwicly to work with WooCommerce, but overall the integration and the way it is is already in a very good start, shouldn’t be left out as it is.
The code snippet @lukelee provided in his first post is incorrect, which explains why it didn’t work.
The Cwicly query filter cannot be blamed for improper use.
I will also add that menu_order does not appear as a valid value for the orderby parameter in the WooCommerce documentation for product queries.