How to redirect user directly to checkout page after adding product to cart in Woocommerce?

In this tutorial we’ll learn how to redirect user directly to checkout page when they add a product to cart from product detail / single product page.

By default, when a user add a product to cart they first need to go to cart page and from there they can proceed to checkout.

Now to move users directly to checkout page, add the following lines of code at the end of you theme’s functions.php file:

add_filter ('add_to_cart_redirect', 'redirect_to_checkout');

function redirect_to_checkout() {

   return WC()->cart->get_checkout_url();

}

You can access functions.php file here:

woocommerce

Save the file by clicking on update file button after placing the above code.

Now if you click on add to cart button from single product page you’ll be redirected directly to the checkout page.

woocommerce

woocommerce

CHEERS J

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

Your email address will not be published. Required fields are marked *