WooCommerce “Checkout Now” button [closed]

Try this –

Add your button inside a form and write down script to add product to the cart and redirect user directly to the checkout page. Suppose, following is the button that you can put on single product page using a WooCommerce hook.

<button name="checkout_now"> Checkout Now </button>

PHP code:

    global $woocommerce;

    $post_id = get_the_ID(); //you can directly use get_the_ID() as you are on single product page or you can also make use of global $product object and then $product->ID

    if( isset($_POST['checkout_now']) ){      //assuming the form method is 'post'
        $woocommerce->cart->add_to_cart( $post_id );
        $checkout_url = $woocommerce->cart->get_checkout_url();