Rewrite the notice shown after adding a product to the cart, and point its button to checkout instead of the cart.
add_filter( 'wc_add_to_cart_message_html', function ( string $message, array $products ): string {
$titles = [];
foreach ( $products as $product_id => $qty ) {
$titles[] = get_the_title( $product_id );
}
return sprintf(
'<a href="%s" class="button wc-forward">Checkout</a> %s added. Nice choice!',
esc_url( wc_get_checkout_url() ),
esc_html( implode( ', ', $titles ) )
);
}, 10, 2 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
After a product is added, WooCommerce shows “Product has been added to your cart” with a View cart button. This snippet rewrites the message and sends the button straight to checkout.
The wc_add_to_cart_message_html filter receives the message HTML and the products just added, as product id => quantity. The snippet builds a new message from the product names and a Checkout button. Product names are escaped before they’re printed.
The button uses the wc-forward class so it’s styled like WooCommerce’s own.
Add a product from its product page. The notice should use your wording and its button should go to checkout.