Reducing the steps performed by the user to complete a purchase is essential for increasing sales on your e-commerce shop. The more steps it requires to place an order, the more abandoned carts there will be. That includes going to the cart instead directly to checkout.

By default in WooCommerce when clicking the Add to cart button, a message is displayed to the customer, but he stays on the same product page.

WooCommerce adding a product to cart.

How to send users to cart page after clicking Add to cart button

First off, I’ll show you how to redirect users from the product page to the cart page ater adding a product to cart. In WooCommerce admin dashboard you can set redirecting users to the cart page after successful addition. Go to WooCommerce -> Settings -> Products and under Add to cart behaviour make sure to check the Redirect to the cart page after successful addition checkbox.

WooCommerce go to cart after adding a product to cart.

PHP Snippet: How to send users to checkout page after clicking Add to cart button

Sending users to Checkout instead to Cart page requires you to add the following php snippet to your child theme’s functions.php file.

add_filter('add_to_cart_redirect', 'webroom_redirect_add_to_cart');
function webroom_redirect_add_to_cart() {
    global $woocommerce;
    $cw_redirect_url_checkout = $woocommerce->cart->get_checkout_url();
    return $cw_redirect_url_checkout;
}

That’s it! :) So, here’s the result:

WooCommerce go to checkout instead to cart after adding a product to cart.

Now, you might want to change the name of the Add to cart button to something like Proceed, Buy Now, Go To Checkout or Continue to match the appropriate behavior (going to the checkout instead of the cart).

PHP Snippet: Change Add to cart button text

Place the following snippet in your child theme’s functions.php file and change ‘Buy now’ to whatever you want the name of the Add to cart button to be.

add_filter( 'woocommerce_product_single_add_to_cart_text', 'webroom_addtocart_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'webroom_addtocart_text' );
function webroom_addtocart_text() {
    return __( 'Buy now', 'woocommerce' );
}

Learn more about the filters we used in this tutorial:




Recent Articles

Blog Categories

Related Articles

If you enjoyed reading this, then please explore our other articles below:

Comments

Leave a comment

Leave a Reply

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.