Adding filter by shipping method
-
Hi, I need to a filter by shipping method on my Woocomerce Order Page. I have this code that I also saw from a forum 7 years back.
function display_shipping_dropdown(){ if (is_admin() && !empty($_GET['post_type']) && $_GET['post_type'] == 'shop_order'){ $exp_types = array(); $zones = WC_Shipping_Zones::get_zones(); foreach($zones as $z) { foreach($z['shipping_methods'] as $method) { $exp_types[] = $method->title; } } ?> <select name="shipping_method"> <option value=""><?php _e('Filter by shipping method', 'woocommerce'); ?></option> <?php $current_v = isset($_GET['shipping_method']) ? $_GET['shipping_method'] : ''; foreach ($exp_types as $label) { printf ( '<option value="%s"%s>%s</option>', $label, $label == $current_v? ' selected="selected"':'', $label ); } ?> </select> <?php } } add_action( 'restrict_manage_posts', 'display_shipping_dropdown' );Filter is showing up on my Woocommerce page but it’s not functioning. How to make it work?Please help.
The topic ‘Adding filter by shipping method’ is closed to new replies.