When running an online store with WooCommerce, sometimes customers don’t want to go through the usual Add to Cart → View Cart → Checkout process. They just want to buy right away. That’s where a Buy Now button comes in — it skips the cart and takes users directly to the checkout page with their product ready to order. In this guide, I’ll show you how to add a custom Buy Now button to your WooCommerce product pages using a simple code snippet — no extra plugins needed.

Why Add a Buy Now Button?

🚀 Faster Checkout – Reduce clicks and speed up the buying process.

📈 Better Conversions – Perfect for impulse buys and one-product stores.

🎯 Customer Experience – Makes shopping easier for returning customers.

The Code Snippet

Copy and paste the following snippet into your theme’s functions.php file or (recommended) use the Code Snippets plugin to keep it organized and safe.

				
					/**
 * Custom "Buy Now" button functionality for WooCommerce.
 *
 * This code adds a "Buy Now" button to single product pages. When clicked,
 * it clears the cart, adds the specified product with the selected quantity,
 * and redirects the user directly to the checkout page.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Add a "Buy Now" button to the single product page, after the "Add to Cart" button.
 */
function arnob_add_buy_now_button() {
    global $product;
    if ( $product && ( $product->is_type( 'simple' ) || $product->is_type( 'variable' ) ) ) {
        echo '<button type="submit" name="buy_now" value="' . esc_attr( $product->get_id() ) . '" class="single_add_to_cart_button button alt arnob-buy-now-button">' . esc_html__( 'Buy Now', 'hello-elementor' ) . '</button>';
    }
}
add_action( 'woocommerce_after_add_to_cart_button', 'arnob_add_buy_now_button' );

/**
 * Handle the "Buy Now" button click to add the product to the cart and redirect to checkout.
 */
function arnob_force_buy_now_redirect() {
    if ( ! isset( $_REQUEST['buy_now'] ) ) {
        return;
    }

    $parent_product_id = absint( $_REQUEST['buy_now'] );
    $quantity = isset( $_REQUEST['quantity'] ) ? absint( $_REQUEST['quantity'] ) : 1;
    $variation_id = isset( $_REQUEST['variation_id'] ) ? absint( $_REQUEST['variation_id'] ) : 0;

    $product_id_to_add = $variation_id > 0 ? $variation_id : $parent_product_id;

    if ( empty( $product_id_to_add ) ) {
        return;
    }

    WC()->cart->empty_cart();
    WC()->cart->add_to_cart( $product_id_to_add, $quantity );

    wp_redirect( wc_get_checkout_url() );
    exit;
}
add_action( 'template_redirect', 'arnob_force_buy_now_redirect' );

				
			

How It Works

  1. The code adds a Buy Now button under the default Add to Cart button.
  2. When clicked, it clears the cart (so only that product is purchased).
  3. The selected product (and variation if applicable) is added automatically.
  4. The customer is redirected straight to the Checkout Page.

Best Way to Add the Code

  • Use the Code Snippets plugin
    instead of editing your theme directly. This keeps your customizations safe even if you update or change themes.
  • Test it on a staging site before applying it to a live store.

🚀 Final Thoughts

Adding a Buy Now button is a small change that can make a big difference for your WooCommerce store. It improves the user experience, reduces friction, and helps boost sales — especially for businesses selling gadgets, single products, or fast-moving items.