Basically, when you add a product to cart, you probably noticed it if Ajax isn’t enabled in your shop, your are redirected to page having the following URL structure:
Where XX is the product added to cart ID. I wanted to be able to use the SKU in the URL instead of the product ID, in other words I wanted this:
So, I wrote this plugin:
Now, I can type, let’s say http://mysite.com/?add-to-cart=5678 and the product having the SKU equal to 5678 will be added to cart. If no product has this SKU, then the product having 5678 as its ID will be added to cart.
Please note: due to a security check within WooCommerce, that method will work only with SKU containing numbers only. Letters aren’t accepted.