Add Buy Now Button in WooCommerce Without Plugin

Help others by sharing this article

In today’s fast-paced digital landscape, convenience is key. Customers want to be able to find the products they need quickly and easily, and they want the option to purchase those products just as quickly. This is where the “Buy Now” button in WooCommerce comes into play.

What is Buy Now Button?

The “Buy Now” button is a feature that allows customers to purchase a product directly, without going through the traditional process of adding the product to a cart and then proceeding to checkout. This feature can be extremely beneficial for businesses that sell products that are considered impulse buys or have a limited stock. By giving customers the option to purchase a product directly, businesses can increase their conversion rate and sell more products.

Why Buy Now Button?

One of the biggest benefits of the “Buy Now” button is that it allows customers to quickly and easily purchase the product without any additional steps. This is particularly useful for products that customers are likely to purchase on impulse. For example, if a customer is browsing a website and comes across a product that they weren’t originally looking for but decide they want to purchase, the “Buy Now” button makes it easy for them to do so. This can lead to an increase in sales, as customers are more likely to purchase a product if the buying process is easy and straightforward.

The “Buy Now” button can also be beneficial for businesses that have a limited stock of a particular product. By giving customers the option to purchase a product directly, businesses can reduce the risk of stock running out before customers have a chance to purchase it. This can be especially beneficial for businesses that sell unique or one-of-a-kind products, as customers may be more likely to purchase the product if they know that it won’t be available for long.

What should be the position of Buy Now Button?

It is important to note that while the “Buy Now” button can increase conversion rate, it can also increase the cart abandonment rate, as customers might not have the chance to review the products they added to the cart. Therefore, it is crucial to ensure that the “Buy Now” button is placed in a strategic location on the website, such as on the product page, where customers are most likely to see it and use it.

Additionally, the “Buy Now” button should be used in conjunction with other features, such as a shopping cart and a checkout page, to ensure that customers have the option to review their purchase before completing it. This can help to reduce the cart abandonment rate and increase customer satisfaction.

More Articles:
Woocommerce Change Add to Cart Button Text.
Woocommerce Hide Price & Add to Cart for Logged out users.
Woocommerce Hide Add to Cart for already purchased products.

Video Tutorial [Hindi Language]

best woocommerce theme 2023

Steps to add Buy Now Button in Woocommerce.

To add a “Buy Now” button in WooCommerce without using a plugin, you can follow these steps:

1) Go to Appearance > Theme File Editor in your WordPress dashboard.

how to access theme file editor

2) Select active Child Theme

Select your active theme. Make sure you use child theme of your main theme. If you have not yet created your child theme, then follow this tutorial to create one. For Example: here i am selecting ColorMag Child theme.

how to change wordpress login page logo

3) Access Functions.php file

Click on the functions.php file just like the below image.

how to access theme functions or functions.php

4) Add below code in functions.php file.

Copy the below code and paste it at the end of functions.php file.

/* Dynamic Button for Simple & Variable Product */

function wpamit_add_buy_now_button_single()
    global $product;
    printf( '<button id="wpamit-adding-button" type="submit" name="wpamit-buy-now" value="%d" class="single_add_to_cart_button buy_now_button button alt">%s</button>', $product->get_ID(), esc_html__( 'Buy Now', 'wpamit' ) );

add_action( 'woocommerce_after_add_to_cart_button', 'wpamit_add_buy_now_button_single' );

function wpamit_handle_buy_now()
    if ( !isset( $_REQUEST['wpamit-buy-now'] ) )
        return false;


    $product_id = absint( $_REQUEST['wpamit-buy-now'] );
    $quantity = absint( $_REQUEST['quantity'] );

    if ( isset( $_REQUEST['variation_id'] ) ) {

        $variation_id = absint( $_REQUEST['variation_id'] );
        WC()->cart->add_to_cart( $product_id, 1, $variation_id );

        WC()->cart->add_to_cart( $product_id, $quantity );

    wp_safe_redirect( wc_get_checkout_url() );

add_action( 'wp_loaded', 'wpamit_handle_buy_now' );

5) Add CSS Code.

After adding the buy now button, it is important to give some margin between Add to Cart button and Buy Now Button. To do this add the below CSS code by going to Apperance > Customize > Additional CSS.

#wpamit-adding-button {

@media only screen and (max-width: 600px) {
 #wpamit-adding-button {

You can increase or decrease the margin between buttons by changing the values in above CSS code.

That’s it. I hope it help you to add buy now button in woocommerce without using any plugin.

Help others by sharing this article

Leave a Reply

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