Normally, using WooCommerce WordPress plugin, when you want to buy some products you need to add it to cart page, view the cart and only after that be able to load checkout page, some people think this is a long process, See in this article how to add products directly to checkout in WooCommerce and skip the cart page.

Add Products Directly To Checkout In WooCommerce
Add Products Directly To Checkout In WooCommerce

 

WooCommerce developers often complain of the long process of going through several screens to see the result of their work. A common workflow is bypassing the cart pages and go straight to the checkout page. This greatly shortens the development process and allows developers and users to immediately see the result of the dev processes.

Skip cart pages in WooCommerce WordPress plugin

 

Add Products Directly To Checkout In WooCommerce?

The process of skipping cart pages and going straight to checkout page in Woocommerce start with the following step:

Go To WooCommerce > Settings > Products > Display

 

On this screen, uncheck the two options in the Add to cart behaviour section.

 

The next step of the process is to add a code snippet to the functions.php (located in the theme folder). This code snippet adds a filter that redirects straight to the checkout pages:


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

Once the code has been added, the click action would redirect to the checkout page. As a result, the label of the button in the WooCommerce product should be changed from “Add to Cart” to “Go to Checkout”. For this, I will add the following filter to the functions.php:


add_filter( 'woocommerce_product_single_add_to_cart_text', 'cw_btntext_cart' );
add_filter( 'woocommerce_product_add_to_cart_text', 'cw_btntext_cart' );< function cw_btntext_cart() { return __( 'Go To Checkout', 'woocommerce' ); }

Add Products Directly To Checkout In WooCommerce
Add Products Directly To Checkout In WooCommerce

Conclusion

The basic problem I discussed in this tutorial was the rather long series of screens that developers and often users too, wish to skip and go straight to the checkout page. The solution is very simple and involves adding code snippets to functions.php. If you need help with the solution, do leave a comment.

Share This Post