In this short article I will describe two possible ways how to add SKU number to WooCommerce product permalinks. The first one is available to all Permalink Manager Pro users (it is not included in free version of plugin) and the second one can be added to your website with a provided snippet.
Some of the functionalities presented in this post are available only in Permalink Manager Pro.
How to easily include SKU in WooCommerce permalinks?
This should be quite easy – all you need to is to go to “Tools -> Permalink Manager -> Permastructures” section and use “%__sku%” tag inside permastructure settings for Product.
You can insert SKU anywhere you want, but if you would like to use it instead of product slug you will also need to disable appending the slug to the end of permalink with additional code snippet.
Sample WooCommerce product permastructure settings with SKU tag:
%product%-%__sku% %product%/%__sku% products/%product%-%__sku% %product_cat%/%product%-%__sku% %product_cat%/%__sku% %__sku%
After the new permastructure settings are saved, you will also need to regenerate the old product permalinks (here you can find more detailed instructions).
The new permastructures will be automatically applied to new products.
WooCommerce SKU shortlinks
In some specific cases it may be very useful to allow the visitors to access your product pages using shortlinks based on SKU number.
Unfortunately, it is not possible with Permalink Manager at this moment but this feature can be added with a simple code snippet. Although, you do not need to install Permalink Manager if you need to utilize only this feature.
In short, after the following snippet is added to your child theme functions.php file, visitors trying to access http://example.com/SKU-NUMBER will be automatically redirected to the actual product permalink.
http://example.com/9780451452733/ will redirect to: http://example.com/product/2001-a-space-odyssey-25th-anniversary-edition.