Disabling WooCommerce Marketing without disabling Shipping functions
Disabling WooCommerce Marketing without disabling Shipping functions
This solution (or most others) disable the Marketing, but also the Shipping functions in WooCommerce, specifically the popup settings and toggle for the three default shipping options (Local Pickup, Free, and Flat Rate)
The following solution is from Remove WooCommerce Marketing Menu Item (wp-admin) Using Hook - and this is (one of the solutions) that disables the shipping as well as marketing
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:
add_filter( 'woocommerce_admin_features', function( $features ) {
/**
* Filter list of features and remove those not needed *
*/
return array_values(
array_filter( $features, function($feature) {
return $feature !== 'marketing';
} )
);
} );
Here is the console error log:
load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.2:5 JQMIGRATE: Migrate is installed, version 3.4.1
wc-shipping-zone-methods.min.js?ver=8.4.0:1 Uncaught TypeError: Cannot read properties of undefined (reading 'ShippingCurrencyContext')
at addCurrencySymbol (wc-shipping-zone-methods.min.js?ver=8.4.0:1:8821)
at wc-shipping-zone-methods.min.js?ver=8.4.0:1:8505
at Array.reduce (<anonymous>)
at n.reformatSettingsHTML (wc-shipping-zone-methods.min.js?ver=8.4.0:1:8491)
at HTMLAnchorElement.onConfigureShippingMethod (wc-shipping-zone-methods.min.js?ver=8.4.0:1:7102)
at HTMLBodyElement.dispatch (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.2:2:40035)
at v.handle (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.2:2:38006)
addCurrencySymbol @ wc-shipping-zone-methods.min.js?ver=8.4.0:1
(anonymous) @ wc-shipping-zone-methods.min.js?ver=8.4.0:1
reformatSettingsHTML @ wc-shipping-zone-methods.min.js?ver=8.4.0:1
onConfigureShippingMethod @ wc-shipping-zone-methods.min.js?ver=8.4.0:1
dispatch @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.2:2
v.handle @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.2:2
Try the following revisited code version (for WooCommerce v4.3 and above):
add_filter('woocommerce_admin_features', 'disable_marketing_feature');
function disable_marketing_feature($features){
$key = array_search('marketing', $features);
if ( ! empty($key) ) {
unset($features[$key]);
}
return $features;
}
Code goes in functions.php file of your child theme (or in a plugin). It should work.
For WooCommerce prior versions (< v4.3), simply use:
add_filter('woocommerce_marketing_menu_items', '__return_empty_array');
January 27, 2024
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand
January 27, 2024