Add Buy Now Button in woocommerce without plugin

If you run an online shopping store you must be looking for a way to increase sales , conversions and revenue.

A Buy Now button allows customer to buy a prouduct more quickly and avoid extra steps in checkout process.

It might seems difficult to acheive this in woocommerce without plugin but you will be amazed to know you can do this without installing a plugin or any prior coding knowledge.

All you need to do is to paste the below code in your theme\’s functions.php file and its done.

** You can either add this code directly to your functions.php file or you can use code-snippet plugin and add the below code in that snippet.

/**
 * @snippet       Add Custom Field @ WooCommerce Checkout Page
  * @author        miqtiquedesigns
  * @testedwith    WooCommerce 5.8
 */
  
 
function add_content_after_addtocart() {
 
$current_product_id = get_the_ID();
 
$product = wc_get_product( $current_product_id );
 
$checkout_url = wc_get_checkout_url();
 
if( $product->is_type( \'simple\' ) ){
echo \'<a href=\"\'.$checkout_url.\'?add-to-cart=\'.$current_product_id.\'\" class=\"buy-now button\">Buy Now</a>\';
}
}
add_action( \'woocommerce_after_add_to_cart_button\', \'add_content_after_addtocart\' );

Leave a Comment

Your email address will not be published.