I need to implement a filter in the woocommerce backend, that I can use to filter the orders by the selected shipping method.
I can create a filter on custom fields and alter the query, but the problem is that woocommerce stores the shipping method in a custom table of the DB.
Any hints on how to achieve this filter?
I solved adding a dropdown menu, using this hook:
And then used this other hook to extend the where clause:
To complete Lorenzo’s answer, here is a function you can use to generate the filter html :
in Lorenzo’s solution, the algorithm will fail if the title of the shipping method is changed. (in my case dynamically by a plugin).
Using
instance_id
instead oftitle
will avoid this.If you combine MrSwed and Lorenzo’s code, you get this (please correct me if I’m wrong but it works for me):