WooCommerce Buy Now Button

WooCommerce buy now button redirecting to checkout


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This snippet generates a secondary button “Buy Now’.

Introducing this button allows users to checkout more quickly as they skip the entire cart journey of the buying journey.

This is particularly useful if you sell just one product or if the new to add multiple products to the order is not needed.

Specifically, this snippet gets the Product ID and adds it to the cart using an add to cart URL.

However, to bypass the cart and go straight to the checkout (the whole point of the “Buy Now” function), we add the checkout endpoint to the URL.

 * Snippet Name:	WooCommerce Buy Now Button
 * Snippet Author:	ecommercehints.com

add_action ('woocommerce_after_add_to_cart_form', 'ecommercehints_buy_now', 10, 0);
function ecommercehints_buy_now() {
	global $product;
	if ( ! $product->is_type( 'simple' ) ) return; // Only show on simple products
	echo '<a href="/checkout?add-to-cart='.$product->get_ID().'" class="button">Buy Now</a>';

Snippet Benefits

  • Skip an entire step in the buying journey by bypassing the cart and send the user straight to checkout upon button click.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers