[WooCommerce Tip] How to Redirect to checkout page after add to cart

As we all know, WooCommerce does not redirect us directly to checkout page after adding a product to cart. It’s a nice feature actually. But sometimes, we need to save a click of user and need to redirect them directly to Checkout page. Redirecting users directly to checkout page is useful and may improve the sales conversion ration.

So is this possible by a setting in WooCommerce? No!

But hold on! No need to upset because this can be done by famous hooks of WordPress.

But How?

open functions.php file and paste below code snippet and that’s it!


function add_to_cart_checkout_redirect() {

wp_safe_redirect( get_permalink( get_option( 'woocommerce_checkout_page_id' ) ) );

die();

}

add_action( 'woocommerce_add_to_cart', 'add_to_cart_checkout_redirect', 16 );