Website Building » WooCommerce » How Do I Get Product SKU in WooCommerce?

How Do I Get Product SKU in WooCommerce?

Last updated on January 10, 2023 @ 8:09 pm

If you’re running a WooCommerce store, you might be wondering how you can get the product SKU for each item in your inventory. While WooCommerce doesn’t have a built-in way to do this, there is a workaround that you can use.

First, you’ll need to install the WooCommerce Product SKU plugin. Once that’s done, you can go to WooCommerce > Settings > Products > SKU and enable the “Show SKU on product page” setting.

Now, when you view a product in your store, you should see the SKU listed on the page. If you want to output the SKU in a template file, you can use the the_sku() function. For example:

PRO TIP: If you are planning to get the product SKU in WooCommerce, be aware that there is no standard way to do this. Each plugin and theme handles SKUs differently, so you will need to look at the code of each one to see how they are implemented. In addition, be aware that some plugins and themes may not use SKUs at all, so you may need to find another way to identify products.
<?php
if ( function_exists( 'the_sku' ) ) {
the_sku(); }
?>

And that’s all there is to it! With the WooCommerce Product SKU plugin installed and enabled, you can easily output product SKUs anywhere on your site.

To summarize, if you need to get the product SKU in WooCommerce, you can install the WooCommerce Product SKU plugin and then use the_sku() function in your template files.

Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.