How To Skip WooCommerce Cart Page And Redirect To Checkout Page? - TemplateTrip Help

Saints Cyril and Methodius Day sale

Limited-time deal: Up to 70% off Hurry before it ends!
Save Now

Days

Hrs

Min

Sec

Product successfully added to your shopping cart.

How to Skip WooCommerce Cart page and redirect to Checkout page?

Table of Contents

How to Skip the Cart Page with WooCommerce Default Settings

  • First, go to WooCommerce Settings > Products.
  • Under the “Add to cart behavior” section, check the “Redirect to the cart page after successful addition” option.
  • Next, head over to the “Advanced” settings and select cart page as the checkout page.
  • That’s it! You’ve successfully skipped the cart page with just a few clicks.

How to Skip the Cart Page in WooCommerce via Code

  • Go to your WordPress dashboard.
  • Click WooCommerce Settings.
  • Click Products General.
  • In the “Add to cart behavior” section, uncheck the two options.
  • Next, open your theme folder and locate the functions.php file.
  • Add the following code snippet at the end of the functions.php file:
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;
}
  • Save the changes to the functions.php file.
  • Once the code has been added, the click action would redirect to the checkout page. As a result, the button label in the WooCommerce product should be changed from “Add to Cart” to “Buy Me”. For this, add the following filter to the functions.php file:
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 __( 'Buy Now', 'woocommerce' );
}
  • Save the changes to the functions.php file.
  • Check your WooCommerce product page, and you should see that the “Add to Cart” button is now labeled “Buy Now,” When clicked, it will redirect the user directly to the checkout page.