Add a Buy Now Button in WooCommerce (No Plugin)

Many WooCommerce shoppers already know what they want before they reach a product page. They do not need a cart review step and they do not want to hunt for a checkout link after adding an item. A Buy Now button gives those shoppers a shorter path by adding the product and sending them straight to checkout in one action. You can add buy now button WooCommerce without plugin features by using a direct checkout link for simple campaigns and a small PHP snippet for product pages. Both methods use built in WooCommerce behaviour, so you avoid another plugin that needs updates and settings.
What does a Buy Now button do in WooCommerce?
The normal WooCommerce flow has three steps. A shopper clicks Add to Cart, reviews the cart or sees a notice, then moves to checkout to pay. A Buy Now button combines the first and third steps. WooCommerce still adds the chosen product and quantity to the cart behind the scenes, but the shopper lands on the checkout page right away. The cart still exists and the order still follows your normal checkout rules for shipping, tax, coupons and payment gateways.
Buy Now is a navigation shortcut rather than a separate checkout system. Required choices such as variation and quantity still matter, and a good setup respects that validation.
When does a Buy Now button help and when does it hurt?
A Buy Now button helps most on stores that sell one clear product at a time. Examples include a single digital download, a hero product promoted in an advert, a low priced add on item or a product with strong impulse appeal. In those cases every extra click gives the shopper another chance to leave. Sending a ready buyer straight to checkout keeps momentum and makes the next step obvious.
The same button can hurt when your store depends on larger baskets. Pushing shoppers to checkout after one item can reduce average order value. Keep both buttons visible so browsers can continue shopping while ready buyers pay now. Our guide on how to add a continue shopping button in WooCommerce covers the browsing side of the flow.
How do you create a Buy Now link with a direct checkout URL?
The fastest method uses a WooCommerce checkout link that adds a product automatically. It works well for landing pages, email buttons, social posts and simple product promotions where you control the exact offer. Start by finding the product ID. In your WordPress dashboard open Products and hover over the product name to see the ID in the row actions area. You can also open the product edit screen and read the post number in the browser address bar.
Next build the link by placing that ID at the end of your checkout address. Replace the example domain and number with your own store details.
https://yourstore.com/checkout/?add-to-cart=123
You can also set a starting quantity by adding a quantity value to the same link. This is useful for bundles or offers where two units are the normal choice.
https://yourstore.com/checkout/?add-to-cart=123&quantity=2
Place the finished link behind a clear button on a landing page, inside a product description for a simple product, in an email campaign or on a thank you page offer. Use short button text such as Buy Now or Checkout Now so the action is obvious. Test the link in a private browser window before you share it, because a logged in admin session can hide problems that a normal shopper would see.
The direct link suits simple products best because it names one product ID and one quantity. Variable products need attribute choices first, so a single link cannot guess the right variation. If your catalogue relies on options, read our guide to WooCommerce product variations and use the snippet below instead.
How do you add a Buy Now button to product pages with PHP?
For product pages you need a button inside the add to cart form so WooCommerce receives the selected quantity and variation data. The snippet below adds a second submit button after the normal Add to Cart button. When a shopper clicks Buy Now, WooCommerce processes the form as a normal add to cart request. A redirect filter then checks whether your Buy Now button name was submitted and sends only those shoppers to checkout.
Before you add any code, take a full site backup and test on a staging copy first. Add the snippet to your child theme functions.php file or to the Code Snippets plugin. Never edit the parent theme, because a theme update will erase your change. If you need a safe place for custom code, our guide on how to create a WordPress child theme explains the setup.
<?php
add_action( 'woocommerce_after_add_to_cart_button', 'vtg_add_buy_now_button' );
function vtg_add_buy_now_button() {
echo '<button type="submit" name="buy_now" value="1" class="button alt vtg-buy-now">Buy Now</button>';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'vtg_buy_now_redirect' );
function vtg_buy_now_redirect( $url ) {
if ( isset( $_REQUEST['buy_now'] ) ) {
return wc_get_checkout_url();
}
return $url;
}
The first function prints the button inside the product form because the woocommerce_after_add_to_cart_button hook runs in that location. The button uses type submit, so the browser sends the whole form including quantity and variation fields. Its name is buy_now, which gives the redirect filter a clear signal to check. The second function returns the checkout address only when that signal is present. Normal Add to Cart clicks keep your existing cart redirect setting, so both paths stay predictable.
Variable products need honest handling. Shoppers must pick required options first, and WooCommerce validation still prompts them when a choice is missing. This snippet does not promise AJAX behaviour or invent a variation choice. Read more in the official WooCommerce developer documentation.
How do you style the Buy Now button so shoppers notice it?
Two buttons with identical styling can slow shoppers down because they must stop and read both labels. Give Buy Now a distinct class and style it as the stronger action while keeping Add to Cart visible as the calmer choice. The snippet already adds the vtg-buy-now class, so you can target that class in your child theme stylesheet or in the Customizer additional CSS area. Our guide on how to add custom CSS in WordPress shows safe places to put style rules.
.vtg-buy-now {
margin-left: 8px;
background: #111827;
color: #ffffff;
}
@media (max-width: 600px) {
.vtg-buy-now {
margin-left: 0;
margin-top: 8px;
width: 100%;
}
}
Keep button text short and contrast strong on mobile. Avoid hiding Add to Cart unless your store sells one product per order.
Should Buy Now keep existing cart items or clear the cart first?
You must choose what happens when a shopper already has items in the cart. Keeping existing items is the safe default used in the snippet above. The Buy Now product joins the current cart and checkout shows everything together. This respects earlier choices and avoids the anger that comes from silently deleting items a shopper planned to buy.
Clearing the cart first can suit a single item offer, but it destroys work the shopper already did. For most stores the keep items default is better because it is predictable and fair.
How do you test the Buy Now button before launch?
Testing protects revenue because a small redirect mistake can send every buyer to the wrong page. Work through the checklist below on staging first and repeat the key checks on the live store after launch.
- Simple product test: open a simple product, click Buy Now and confirm checkout shows the correct item and quantity.
- Variable product test: choose every required option, click Buy Now and confirm the selected variation reaches checkout.
- Missing options test: click Buy Now without choosing options and confirm WooCommerce asks for the missing choice.
- Quantity test: set quantity to three, click Buy Now and confirm checkout quantity matches your choice.
- Existing cart test: add another product first, then use Buy Now and confirm earlier items remain in checkout.
- Normal button test: click Add to Cart and confirm it follows your normal cart setting instead of jumping to checkout.
- Mobile test: repeat the simple product check on a phone sized screen and confirm both buttons remain readable and tappable.
Fast checkout pages matter once shoppers arrive, so hosting quality affects the result. If checkout feels slow during testing, compare your setup with the guidance in our web hosting pillar before you blame the button.
What mistakes break a Buy Now button setup?
Most failures come from small placement or logic errors rather than from WooCommerce itself. Watch for these common problems during setup.
- Editing the parent theme: the next theme update removes your snippet and the button disappears without warning.
- Using the wrong product ID: a direct link adds a different product or fails because the ID belongs to a draft or deleted item.
- Redirecting every add to cart: a filter without a button name check sends normal Add to Cart clicks to checkout as well.
- Placing the button outside the form: the click cannot send quantity or variation data, so WooCommerce receives an incomplete request.
- Testing only as an admin: cached pages, shopper roles and payment settings can behave differently for real customers.
When something fails, disable the snippet, clear cache and retest the normal Add to Cart flow. That sequence tells you whether the problem sits in your new code or in a wider store setting.
Frequently Asked Questions
Can I add a Buy Now button in WooCommerce without a plugin?
Yes. A direct checkout link works for simple promotions, and a short PHP snippet adds a product page button that redirects to checkout after a normal add to cart request. Both methods use built in WooCommerce hooks and filters.
Does Buy Now work with variable products?
Yes, when the button sits inside the product form. The shopper chooses size, colour or other required options first, then Buy Now submits those choices and moves to checkout. Missing choices still trigger normal WooCommerce validation.
Will Buy Now remove items already in the cart?
Not with the snippet in this guide. The safe default keeps existing cart items and adds the Buy Now product beside them. Clearing the cart is possible, but it can frustrate shoppers and should only suit a clearly explained single item offer.
Where should I place the PHP snippet safely?
Place it in a child theme functions.php file or in the Code Snippets plugin. Take a backup first and test on staging. Avoid the parent theme because theme updates overwrite parent theme files.
Last updated: December 2026.



