With the new WooCommerce 4.1.0 just released, there’s a new Marketing item in the menu. Looking at the URL, it goes to admin.php?page=wc-admin&path=/marketing
and by using the admin_menu
hook, I’m trying to remove this menu option.
I tried with the sub_menu
option and with remove_menu_page
option without success. If anyone can correct my code I would be very grateful.
add_action( 'admin_menu', 'remove_woocommerce_marketing_menu_option' );
function remove_woocommerce_marketing_menu_option(){
remove_menu_page( 'admin.php?page=wc-admin&path=/marketing' );
}
4
Answers
Use this For WooCommerce Version <= 4.2 :
For WooCommerce Version >= 4.3
Use this:
For WooCommerce <= v4.2
For WooCommerce >= v4.3
WooCommerce 4.3 removed the
woocommerce_marketing_menu_items
filter so the above snippet will no longer work. Thankfully, we can hook into another filter introduced in WooCommerce 4.0 as such:Is the code working?
I have tested the above code snippet on WordPress version 5.5 and WooCommerce version 4.4 and it works as expected.
Coupons moved under Marketing in WooCommerce 4.4
In WooCommerce version 4.4, the Coupons feature was moved to the Marketing menu item as sub-item. There will still be a coupon menu item in the old location, and anyone stumbling upon it will be guided on the new location and asked to remove the legacy
WooCommerce > Coupons
menu item.However, if you are using the above code snippet, your
Marketing
, and so, theMarketing > Coupons
menu items will be not available. In that case, yourCoupons
menu item will reside in the old place asWooCommerce > Coupons
.Credits: https://cinchws.com/remove-woocommerce-marketing-hub-menu-item/