skip to Main Content

How to add a “Buy Now” button before the “Add to Cart” button of WooCommerce

you can use woocommerce_before_add_to_cart_button hook as following. Add the following PHP code to functions.php.

add_action( 'woocommerce_before_add_to_cart_button', 'custom_content_after_addtocart_button', 100 );
function custom_content_after_addtocart_button() {
	global $product;
	$id = $product->get_id();
      $link = do_shortcode('[add_to_cart_url id="'.absint($id).'"]');
	echo '<a class="button alt" href="'.esc_url($link).'">'.__('Buy Now', 'textdomain').'</a>';

WooCommerce Buy Now button

Leave a Reply

Back To Top