Bookmark

No account yet? Register

Difficulty: Easy

Here we will cover how to hide products that have no SKU assigned on your WooCommerce store. Hiding the products that have no SKU assigned is very simple and can be done like many other things on your WooCommerce store by adding code to your Functions.php file in your theme folder.

TLDR
File: Functions.php

add_filter( 'woocommerce_product_query_meta_query', 'shop_only_products_with_sku', 10, 2 );
function shop_only_products_with_sku( $meta_query, $query ) {
     if( is_admin() ) return $meta_query;
     $meta_query[] = array(
     'key' => '_sku',
     'value' => '',
     'compare' => '!=',
      );
     return $meta_query;
}

Hiding products with no SKU

Customizing functions.php file in WordPress

To hide products that have no SKU number first navigate to your admin interface and then go to Appearance and then under Appearance select Theme Editor.

After navigating there you will see a windows like this one below. In there select Theme Functions (functions.php) and then at the end put this code.

add_filter( 'woocommerce_product_query_meta_query', 'shop_only_products_with_sku', 10, 2 );
function shop_only_products_with_sku( $meta_query, $query ) {
     if( is_admin() ) return $meta_query;
     $meta_query[] = array(
     'key' => '_sku',
     'value' => '',
     'compare' => '!=',
      );
     return $meta_query;
}

Click on button bellow to update your file/save changes and that’s it. Now your WooCommerce products with no SKU will be hidden from your WebShop.