Remove WooCommerce SKU: N/A Category in Products

You can remove the WooCommerce sku line – SKU: N/A Category from products in WordPress by using the ‘wc_product_sku_enabled‘ filter. Just add in your theme’s functions.php file…

add_filter( 'wc_product_sku_enabled', '__return_false' );

This will remove the sku everywhere.

Remove the SKU Item Conditionally

You may want to keep the SKU info published on some categories or products only – you can use the same filter with some conditionals.

add_filter( 'wc_product_sku_enabled', 'prefix_remove_sku' );

function prefix_remove_sku( $enabled ) {
    if ( ! // Add your WooCommerce conditionals ) {
        return false;
    }

    return $enabled;
}

So in the above add in WooCommerce conditionals in the if statement.

As the ! operator is used, anything with the conditionals will have the SKUs, and everything else will not have them.

2 Comments

  1. Theresa on July 1, 2020 at 7:34 pm

    Nice related posts format. Who do you use for that plugin?

    Thanks

Leave all Comment