WooCommerce: Redirect URL With SKU To Single Product Page

Let’s say your WooCommerce product has the following permalink: example.com/shop/t-shirts-tops-and-blouses/t-shirt-casual-v-neck-longsleeve-green-medium-cotton-stretch

Wouldn’t it be shorter, more fun and neater if you could also reach the same exact single product page by using example.com/sku00001 in the browser bar, where “sku00001” is the product SKU?

Well, in today’s snippet we will create a simple redirect from a custom URL that contains the product SKU to the product page, so that you can use the URL “shortener in your email marketing, display advertising, blog posts and anywhere you want to show a “pretty link” instead of a full, long, boring product page URL.

Enjoy!

Continue reading WooCommerce: Redirect URL With SKU To Single Product Page

WooCommerce: Fix Google Search Console “No global identifier provided” Error

If you registered your WooCommerce website on Google Search Console for monitoring your SEO efforts and search appearance errors, you probably got this “No global identifier provided (e.g. gtin, brand)” email notification at some stage. I got it too.

Search Console optionally requests you set a unique product GTIN structured data for all your products – I believe in case you wish to sell on Google Shopping – and therefore sends you this error notification whenever a product is missing this.

You could use a WooCommerce GTIN plugin from the WP repo, yes. Or you could be smart, and programmatically set the GTIN to the same value of the product SKU, as long as all your products have a unique SKU value. Today, we will cover the latter. Enjoy!

Continue reading WooCommerce: Fix Google Search Console “No global identifier provided” Error

WooCommerce: Bulk Search & Replace SKUs

Yes, you could use a plugin to bulk search and replace a given string inside the WordPress database… but today I want to show you a simple snippet you can use to bulk edit SKUs in your store (please test first on staging or a development site!).

Specifically, we will replace dashes “-” with an empty string (i.e. we will remove dashes from all products’ SKU), but you can of course readapt this and for example add suffixes, remove prefixes, replace special characters and so on. Enjoy!

Continue reading WooCommerce: Bulk Search & Replace SKUs

WooCommerce: Search Products By SKU (Frontend)

The frontend WooCommerce product search, for some reason, doesn’t work for SKU values. If it does, then your theme developers were smart enough to include this in their code, because this is a big problem especially for B2B stores.

Today, we’ll study how to alter the product search query, as well as the wc_get_product_id_by_sku() function, which is super helpful to determine the product ID for a given SKU. Enjoy!

Continue reading WooCommerce: Search Products By SKU (Frontend)

WooCommerce: Display Variations’ SKU @ Product Admin

I find it quite annoying that variable products display an empty SKU cell in the WordPress > Products admin page even if their variations may have one available.

Today, we go fix that. With this simple snippet, your variable products will display the SKU of each variation, and if there is none, empty brackets (so, it’s easy to identify if any variation is missing its SKU).

So, let’s see how it’s done. Enjoy!

Continue reading WooCommerce: Display Variations’ SKU @ Product Admin

WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

When SKU matters to the end user, displaying it in the Cart page, Checkout page, Thank you page, My Account View Order page and Order Emails under the item name is a must.

Ideal for B2B businesses and international brands, this simple customization can help you learn how to add any sort of content under the Cart/Checkout/Order item names. Simply use the same hook and try “getting” something different than SKU with this guide. Enjoy!

Continue reading WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

WooCommerce: Hide Category & Tag @ Single Product Page

SKU, Category list and Tag list on the WooCommerce single product page are called “product meta”. We already saw how to hide just the SKU (while leaving Cats and Tags there), so in this “episode” we will study how to do the opposite i.e. keeping the SKU there while hiding Cats and/or Tags.

If you are a developer, you’d think there were a specific WooCommerce “filter” for this, but there is not. So, we have to first remove the whole “product meta” block and then add back the info we want (just the Cats, for example). If you’re not a dev – not to worry – just copy paste one of the snippets below in your functions.php and magic will happen. Enjoy!

Continue reading WooCommerce: Hide Category & Tag @ Single Product Page