phpwordpresswoocommerceadminhook-woocommerce

Disable WooCommerce admin Features


I would like to disable WooCommerce admin features.

I currently use this code in an Hello child theme (functions.php):

<?php
add_filter('woocommerce_admin_features', 'disable_woocommerce_features');
function disable_woocommerce_features($features) {

    $disable = array(
        'product-block-editor',
        'onboarding',
        'onboarding-tasks',
        'experimental-fashion-sample-products'
    );

    return array_diff($features, $disable);
}

But I still see this: enter image description here

Why ?


Solution

  • You can try to use the following code, to disable all WooCommerce admin features (using a different hook):

    add_filter('woocommerce_admin_get_feature_config', 'disable_wc_admin_features', 999);
    function disable_wc_admin_features( $features ) {
        // Loop through each feature from the array
        foreach( $features as $feature => $enabled ) {
            $features[$feature] = false; // Disable
        }
        return $features;
    }
    

    Untested, it could work.

    Note that the function wc_admin_get_feature_config() is used to list all admin features from WooCommerce config, in this filter hook.


    Previous simplified code:

    add_filter('woocommerce_admin_features', '__return_empty_array');