Hide SKU in product page

jumper

Member
Hi
I found that the way to hide the SKU field in the product page is by modifying the code.
is there any other way that you know of from woocommerce settings, without changing the code?
 

Direct Webstore

Well-Known Member
Honestly the easiest way is to add a code line into your functions.php but give this a try: https://wordpress.org/plugins/woocommerce-remove-sku/
That's ok if you want another plugin bloating your site. It also removes it from the admin area which is not recommended.

... the best way, like you said is to simply add this to your theme's function.php. It only removes it from the product page, not the admin area.


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' );
 
Last edited:

Direct Webstore

Well-Known Member
Newbie question.
Is it neccessary to hide dhe SKU?
Why we should hide it?
Thank you
It's not REALLY necessary ... a curious customer may google it and find the corresponding product at Aliexpress and discover your evil dropshipping secret. lol :)

It doesn't work for every product if you do a search ... but for the 5 minutes involved downloading, copy/pasting that code into your theme's functions.php and re-uploading ... why the the Hell not? It won't hurt. :)

PS ... keep a copy of the functions.php and re-upload it after each theme update. Normally you'd have child theme to avoid this ... but it's not really worth it for 1 file.
 

kuop

New Member
I did that in my functions.php and it gave me the errror that heading is already send and that l can't edit it.
 

Direct Webstore

Well-Known Member
I did that in my functions.php and it gave me the errror that heading is already send and that l can't edit it.
You must have put it in the wrong place. It should be the last entry and above any comments. Google "how to edit functions.php"
 

Mar

Moderator
I did that in my functions.php and it gave me the errror that heading is already send and that l can't edit it.
I use PHP code snippets plugin. You can add codes in the plugin instead of directly to functions.php. Most of the time if a code has a problem and added directly functions.php, it will break your site. In this plugin, once you click Publish, you will see a warning if the code is not good. All you have to do is hit the back button of the browser and you are back in the snippet, review or delete it. functions.php is a delicate theme file, if you are not familiar with it you will have a problem.
 

kumudu

Member
@kuop If you have not done this yet, add the below in additional CSS. It hides the SKU on the product page, not the admin area.

.product .sku_wrapper { display: none !important; }
 
Top