If you’ve ever shopped on Amazon, you know how convenient it is to go straight from a product page to checkout with a single click. That “Buy Now” button eliminates extra steps and can make the buying process much faster. Inspired by this, I wanted to create something similar for WooCommerce stores — a simple button that lets your customers skip the cart and go straight to checkout, whether they’re buying a simple product or a single variation.
In this post, I’ll share a lightweight PHP + jQuery snippet that adds a “Buy Now” button right next to your standard “Add to Cart” button. The button dynamically updates if the product is a variable product or if the customer changes the quantity, ensuring that the checkout link is always accurate. With this solution, you can improve the user experience, reduce friction, and potentially increase conversions — all with just a few lines of code.

PHP Snippet: Display “Buy Now” Button Beside the “Add to Cart” One on the WooCommerce Single Product Page
This snippet adds a “Buy Now” button right next to the standard “Add to Cart” button on WooCommerce single product pages. The button links directly to a checkout page with the selected product and a default quantity of one.
For variable products, it dynamically updates the link if a customer selects a variation, ensuring the correct variation ID is included. It also updates the link whenever the quantity input changes, so the checkout URL always matches the customer’s selection.
The button uses a small piece of jQuery, enqueued on the page, to listen for quantity and variation changes and adjust the link in real time. The result is a smoother shopping experience that allows customers to skip the cart and go straight to checkout while handling both simple and variable products seamlessly.
Note: this snippet is not compatible with variable products that use “Any…” attributes, nor with grouped products. It has not been tested with other product types.
/**
* @snippet Add "Buy Now" Button @ Woo Single Product Page
* @tutorial https://businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 10
* @community Join https://businessbloomer.com/club/
*/
add_action( 'woocommerce_after_add_to_cart_button', 'bbloomer_buy_now_button', 1 );
function bbloomer_buy_now_button() {
global $product;
$checkout_url = wc_get_checkout_url();
$product_id = $product->get_id();
$buy_now_url = esc_url( add_query_arg(
array(
'products' => $product_id . ':' . 1,
),
'/checkout-link/'
) );
echo ' — OR — <a href="' . $buy_now_url . '" class="single_add_to_cart_button button buy_now_button" data-product-id="' . $product_id . '">Buy Now</a>';
wc_enqueue_js( "
function updateBuyNowURL() {
var qty = $('form.cart').find('input.qty').val() || 1;
var productId = $('a.buy_now_button').data('product-id');
var variationId = $('form.cart').find('input[name=\"variation_id\"]').val();
if (variationId && variationId !== '0') {
productId = variationId;
}
var newUrl = '/checkout-link/?products=' + productId + ':' + qty;
$('.buy_now_button').attr('href', newUrl);
}
// Quantity change
$(document).on('change input', 'form.cart input.qty', updateBuyNowURL);
// Variation change
$('form.cart').on('show_variation hide_variation', updateBuyNowURL);
// Initialize once on load
updateBuyNowURL();
" );
}








