How to Change SKU Text WooCommerce

change sku text woocommerce

Are you looking for a quick and easy way to change WooCommerce SKU text? I have a quick solution for you: change SKU text WooCommerce code snippet that I have tested and will demonstrate in this quick guide on how it works. This will definitely save your time and help get this done fast.

Ideally, you change the WooCommerce SKU text you need to use a filter and you can add this code to the functions.php file and also in your WooCommerce custom plugin development.

Change SKU Text WooCommerce

In this post, I will share with you the best solution that will quickly help you change the WooCommmerce SKU label.  I wanted to change the label of the SKU in WooCommerce to a different language in translation when I was customizing the WooCommerce store, I came up with WooCommerce this code snippet that you too can use in your project as well.

First, we need to understand where the SKU text is displayed in the WooCommerce store so that we can understand how to change the text to our custom text as you will see in the demonstration below.

The WooCommerce SKU text is displayed on the product page as shown on the image below :

Change SKU Text WooCommerce 1
To change the text we need to add the following code snippet to the functions.php file of your child theme or to the custom plugin code that you are working on:

[php] add_filter(‘gettext’, ‘njengah_change_sku_text’, 10, 3);
function njengah_change_sku_text($translation, $text, $domain) {
if ($domain == ‘woocommerce’) {
switch ($text) {

case ‘SKU:’:
$translation = ‘Custom Text:’;
break;
}
}
return $translation;
}

[/php]

When you add this code to the functions.php you can see the custom text you added in the code replaces the SKU default WooCommerce text. You can see the results as shown in the screenshot image below :

 

Conclusion

In this post, we have looked at how to change sku text in WooCommerce, as you can see you simply need to replace the custom text in the code snippt with your preferred text and add this code snippt in the functins.php file of your active theme and you will successfully change SKU text in the single product page.

You can easily and quickly use this solution in your WooCommerce theme or plugin development. Just in case you are stuck, I am always ready to help you implement this solution and also to further customize it to fit your specific needs.

If you need further assistance in fixing this issue, I can quickly check and advise what is the best way to get this done in your specific WooCommerce theme.  I would be glad to help you, feel free to reach out for further assistance, you can get in touch for a free consultation.

Similar Articles