Sunday 15 June 2014

php - How to implement a filter by shipping method in woocommerce backend? -



php - How to implement a filter by shipping method in woocommerce backend? -

i need implement filter in woocommerce backend, can utilize filter orders selected shipping method.

i can create filter on custom fields , alter query, problem woocommerce stores shipping method in custom table of db.

any hints on how accomplish filter?

i solved adding dropdown menu, using hook:

add_action( 'restrict_manage_posts', 'display_shipping_dropdown' );

and used other hook extend clause:

add_filter( 'posts_where', 'admin_shipping_filter', 10, 2 ); function admin_shipping_filter( $where, &$wp_query ) { global $pagenow; $method = $_get['shipping_filter']; if ( is_admin() && $pagenow=='edit.php' && $wp_query->query_vars['post_type'] == 'shop_order' && !empty($method) ) { $where .= $globals['wpdb']->prepare( 'and id in ( select order_id wp_woocommerce_order_items order_item_type = "shipping" , order_item_name = "' . $method . '" )' ); } homecoming $where; }

php wordpress woocommerce

No comments:

Post a Comment