For most woocommerce stores, it is best to redirect customers to the checkout page when they click the add-to-cart button.
Even for landing pages where users are only meant to buy one product, it is best to take them straight to the checkout page. This way, we can eliminate the cart page from the flow altogether.
PHP Snippet: Redirect user to Checkout page on Add to Cart action.
add_filter( 'woocommerce_add_to_cart_redirect', 'bcloud_redirect_checkout_add_cart' );
function bcloud_redirect_checkout_add_cart() {
return wc_get_checkout_url();
}
If you want to redirect users only from specific URLs like landing pages, use the below code: