Ask SkyVerge

Here’s an Ask SkyVerge question from Marley:

Is there a way for me to hide SKUs in WooCocommerce from the single product template without overriding it? I’m currently overriding the single product meta template and deleting the SKU from being adding, but I’d rather do this via a code snippet so I’m not overriding that template if it can be done.


We covered this previously in our 20 WooCommerce How to’s, but I think it’s a bit buried and deserved a dedicated post.

There are a couple of ways we can disable SKUs on the product page: we can remove them from the shop completely, or we can only remove them from the product page.

SKUs are set with the general product data while creating or editing a product:

WooCommerce set SKU

Create a Product SKU

By default, SKUs are shown on the product page with the product meta:

WooCommerce SKUs on Product Page

SKUs on Product Page

If they’re not set, the SKU will just display as SKU: n/a.

This may not be desirable, and most themes leave this information here as-is. WooCommerce doesn’t have a setting to change this, but you can do so via a code snippet.

Remove WooCommerce SKUs Completely

If you don’t need to use SKUs at all in your shop, you can disable them completely by using this code snippet in your custom site plugin or theme’s functions.php:

add_filter( 'wc_product_sku_enabled', '__return_false' );

The SKU will no longer be added to the product page display when disabled.

WooCommerce SKU removed from Product pages

SKU removed from Product pages

Not only will the remove SKUs from the product page, but they’ll also be gone from the admin as well.

WooCommerce SKU removed

SKU removed

This option completely removes SKUs from WooCommerce by disabling them throughout your entire site.

Remove WooCommerce SKUs Only on Product Pages

However, I’ve found that most stores want to keep SKUs for administration, but only disable the SKU display on product pages. While you can just hide the SKU with some CSS, here’s a snippet to disable them completely on product pages, but leave them for use in the admin.

function sv_remove_product_page_skus( $enabled ) {
    if ( ! is_admin() && is_product() ) {
        return false;
    }

    return $enabled;
}
add_filter( 'wc_product_sku_enabled', 'sv_remove_product_page_skus' );

This will stop the SKU section from ever being added to the product template, so this change should be virtually theme independent. However, the SKU will still be displayed and editable from the WooCommerce admin.

WooCommerce set SKU

SKU still intact

This is a great solution for shops that want to manage SKUs, but they don’t want to show them to customers while browsing.

Published by Beka Rice

Beka leads product direction for SkyVerge and technical documentation. She spends a lot of time on research and interviews, but likes to write so she has an excuse to spend more time jamming out to anything from The Clash to Lady Gaga.

32 Comments

  1. hi where exactly does the add_filter( ‘wc_product_sku_enabled’, ‘__return_false’ ); code go? and in what line please?

    thanks

  2. Hi Beka!! great tutorial!
    how can hide tabs “Inventory, shiping, linked, etc”
    and how to change SKU word to Ref:
    im coming crazy 🙁
    thanks!

  3. Thank you! Very helpful tip.

  4. Awesome! Thanks for the plugin & code snippet! WC should really have this option available in the admin area.

    Much better to use a plugin in my opinion to get the snippet in there. So this doesn’t break when you update your theme.

  5. I agree, this should be an option. I simply used CSS.

    .sku_wrapper {
    display:none;
    }

    • This option worked the best! Thank You!

    • WP and certainly woo-commerce novice. So to remove sku just from product display for consumer just add code:
      .sku_wrapper {
      display:none;
      }
      right? But where exactly? And must I have child theme first?

  6. Hi,
    I’ve the code to hide the SKU’s en tags from WooCommerce, and it works in Chrome and Firefox, but not in IE.
    Can you help me out with that?

  7. Hi guys,
    I read this entire post and found very informative. I have few issue in my single product page which i wanna get fix. Any one help me.

    1 – Hide thumbnail image
    2 – Hide SKU
    3 – Hide Category & Tags

    For reference see below image link.

    http://oi57.tinypic.com/zuh637.jpg

  8. Great solution but how can i make sku field required in admin product page?
    thanks

  9. Just want to say thanks! 🙂

  10. Hi Beka,

    I’ve just added the code to hide the SKU from my product page only. It works fine, but I want to hide the SKU completely from the customers so it doesn’t show on any public document such as the order notification, invoice etc.

    I still want it to be shown on all internal documents and in the admin controlpanel.

    Can you help?

    Best regards
    Anine

  11. Thank you this share., I will try now.,

  12. Worked like a charm. Just added the code to “Remove WooCommerce SKUs Only on Product Pages” to my functions.php and voila!

    Thank you very much.

  13. added the code snippet and works nicely.

  14. Thanks Beka, great snippets as always!

  15. Thanks. Very helpful tip.

  16. Thank for the exactly stright to the point answers.

  17. Thanks. That’s exactly the snippet I needed!

  18. Tnx, very userful this tutorial.

  19. Briljant little bit of code. Even a coding idiot like me can be helped with this. Maybe it’s good to note that you should put this code in the functions.php of your child theme (or is that wrong?).

    Thank’s a lot Beka!

  20. Thanks a lot! It works!

  21. Took me around 20 seconds to fix my problem thanks to this 🙂 Thanks so much!

  22. thanks for this awesome snippet.

    anyway, how to move sku position into under product title?

    thanks again! regards

  23. Does anyone know how to remove the “Product ID:” just below the tag meta data? It’s not part of meta.php. Thanks!

  24. this filter worked the best, Thank You!

  25. Works, thank you!

  26. Great! Thanks!

Hmm, looks like this article is quite old! Its content may be outdated, so comments are now closed.