Skip the cart page for stores with one product or simple orders: clicking Add to cart goes straight to checkout.
// Go to checkout after a successful add to cart.
add_filter( 'woocommerce_add_to_cart_redirect', function (): string {
return wc_get_checkout_url();
} );
// Shop page buttons add to cart in the background by default. Turn that off so they redirect too.
add_filter( 'pre_option_woocommerce_enable_ajax_add_to_cart', fn () => 'no' );
// Remove the "View cart" notice that would show on the checkout page.
add_filter( 'wc_add_to_cart_message_html', '__return_empty_string' );
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.
If most customers buy a single item, the cart page is an extra step with nothing to do. This snippet sends them straight to checkout after they click Add to cart.
The woocommerce_add_to_cart_redirect filter decides where to go after a product is added. Returning the checkout URL skips the cart.
Buttons on the shop page normally add products in the background without leaving the page, which skips the redirect. The second line overrides the “Enable AJAX add to cart buttons on archives” setting so those buttons redirect too. The last line removes the “added to your cart” message, which would otherwise appear at the top of checkout.
Click Add to cart on a product page and on the shop page. Both should take you to checkout with the product in the order summary.