I am using WooCommerce, and I have a custom order status to which all new orders are assigned (instead of the default "Processing" status). The WooCommerce admin menu shows a helpful tip showing how many orders you have that need attention, but it only counts "Processing" orders. I want to make the count reflect my custom status.
- The function that gets the count is
wc_processing_order_count()
and is defined inwoocommerce/includes/wc-order-functions.php
. No hooks or filters. The function that displays the count is
menu_highlight()
and is defined in the classWC_Admin_Menus
. Themenu_highlight()
function is hooked in__construct()
:add_action( 'admin_head', array( $this, 'menu_highlight' ) );
The
WC_Admin_Menus
class is not stored in a global variable when instantiated, and so there is no easy access to that hook.I want to make the change without editing the core WooCommerce files, as they will be overwritten on update.
I was able to remove the 'admin_head'
action using this function. Then I could customize the menu_highlight
function and the wc_processing_order_count
. Is there a more straight-forward way to do this?
function remove_menu_highlight() {
remove_filters_with_method_name('admin_head', 'menu_highlight', 10);
}
add_action('admin_head', 'remove_menu_highlight', 11);
add_action('admin_head', 'custom_menu_highlight', 12);
Aucun commentaire:
Enregistrer un commentaire