WooCommerce: Skip Product & Cart Pages

That’s a common issue some of you (WooCommerce users) face: how to click on one single button to add a product to the cart without even visiting the product page and skip the cart page to be directly redirected to the checkout page.

Let’s say you sell a ebook, and you lost potential sales during the Home Page > Product Page > Cart Page > Checkout Page funnel… Well this can be avoided by adding a link on the homepage and being redirected to the checkout directly with the product being added to the cart automatically.

To do it, simply add a link on your homepage (why not in the header?) and use a URL having this structure:

http://your-site.com/?add-to-cart=37

Where you replace 37 by the product ID.

Then add this snippet to the functions.php file within your theme folder, and tada ! The magic appears !