WooCommerce Skip Cart, Go Straight to Checkout Page

WooCommerce workflow can be a little too long for simple products, you can provide a better user experience, here’s how to get the product to skip past the cart page and go straight to the checkout page.

woocommerce skip cart

First, uncheck the cart options in WooCommerce Settings -> Products.

Then add in your functions.php

add_filter('woocommerce_add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
 global $woocommerce;
 $checkout_url = wc_get_checkout_url();
 return $checkout_url;
}

That’s it now when you click a product add to cart it will go to checkout.

Change the ‘Add to Cart’ label

woocommerce skip cart go checkout

Now since the cart is gone we should change the ‘Add to Cart’ label in the WooCommerce product to something a bit more immediate like ‘Pay Now’. WooCommerce has a filter for that too. This is also added to your functions.php

//Add New Pay Button Text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'themeprefix_cart_button_text' ); 
 
function themeprefix_cart_button_text() {
 return __( 'Pay Now', 'woocommerce' );
}

The above filter applies the text to the single product page, however, you may have the product on another post type, there is a 2nd filter you can also use – woocommerce_product_add_to_cart_text

//Add New Pay Button Text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'themeprefix_cart_button_text' ); 
add_filter( 'woocommerce_product_add_to_cart_text', 'themeprefix_cart_button_text' ); 
 
function themeprefix_cart_button_text() {
 return __( 'Pay Now', 'woocommerce' );
}

Now there are fewer steps to the end product purchase which makes the process simpler for the buyer.

29 Comments

  1. riya on September 12, 2023 at 5:48 am

    Worked great for me also. However how can you REMOVE a product from the cart if you decide to change your selection before checking out?

  2. Lisa on March 14, 2022 at 7:54 am

    How can I use woocommerce without adding product? I want to create a invoice form and direct card payment to network international payment gateway please help me.

  3. Grehgor on January 8, 2021 at 11:06 am

    Hello, do you know how to effectively rename the “View Cart” button?

    “$ translated_text;” did not work

    • shilpi on July 5, 2021 at 6:42 am

      hello do you know how to redirect checkout page threw the cart icon.

  4. Andreas Toll on September 21, 2020 at 9:20 am

    much appreciated, thank you!

  5. vk on August 7, 2020 at 9:08 am

    You are the best!!

    Thank you!!

  6. Billy on May 5, 2019 at 10:57 pm

    You don’t need that php code. Just tweak the cart page to point to Checkout page in Woocommerce>Settings>Advanced.

  7. Alauddin on April 8, 2019 at 1:58 pm

    How can I use woocommerce without adding product? I want to create a invoice form and direct card payment to network international payment gateway please help me.

  8. virmat on January 17, 2019 at 8:28 pm

    Broke my site. I get HTTP ERROR 500. Removed the code from the functions.php file through SFTP and still can’t access the site or WP dashboard. PLEASE advise on how to fix. Thanks.

  9. Mike Devis on August 16, 2018 at 9:49 am

    Thank you for helping us. Can you please also tell how to create a sticky checkout that display the checkout page in a slider when customer clicks the cart page?

  10. Joshua on May 10, 2018 at 6:37 pm

    Hi,

    I am a non tech guy trying to set up my first booking website for accommodation’s. I have the bellevue child theme (hotel) and i have managed to set up the right calendar with a form and a book button.

    After filling in the form I would like to get directly to the cart to proceed payment. On this screenshot (left) you can see how i managed to fix it. Screenshot (right) is how i want it to be and you will be directed to the cart : https://imgur.com/a/Mcxbd3r

    I can’t figure out how this works: https://themovation.ticksy.com/article/7516

    I hope somone can figure out explaining me how i can fix this.

  11. Shane on March 27, 2018 at 7:34 pm

    First off: I can confirm this still works with Woocommerce 3.3.4

    Second: It doesn’t seem like we need to pull down the $woocommerce global variable. Unless, that is, you have a particular reason for doing so. Mine works fine like this:

    add_filter(‘woocommerce_add_to_cart_redirect’, ‘themeprefix_add_to_cart_redirect’);
    function themeprefix_add_to_cart_redirect() {
    $checkout_url = wc_get_checkout_url();
    return $checkout_url;
    }

    • Shane on March 27, 2018 at 7:38 pm

      And it might just be easier all around to simplify it to this:

      add_filter(‘woocommerce_add_to_cart_redirect’, function () {
      return wc_get_checkout_url();
      });

  12. carlos on February 18, 2018 at 2:18 am

    How can I post the email of the buyer if I bypass the cart. Is there a way to pass it to checkout page by a hook?

  13. David on November 30, 2016 at 12:36 am

    Hiya

    I love the first bit of code BUT how can you make that happen only for one product? It’s sending me mental trying.

  14. rajkumar on November 13, 2016 at 8:58 pm

    thanks a ton

  15. Bettina on November 11, 2016 at 3:58 pm

    Thank you for this post! This may be a stupid question, but where exactly do I input this .php file??

    • Chad on November 12, 2016 at 2:11 pm

      You need to put this inside of functions.php inside of your child theme.

  16. Hetch on January 28, 2016 at 3:37 am

    Worked great for me also. However how can you REMOVE a product from the cart if you decide to change your selection before checking out?

  17. kas on November 11, 2015 at 12:42 am

    Worked like a charm on the individual product pages, but still see the “Add to Cart” option on the default Shop page in Woo Commerce. Anyway to update the default purchase flow and button on the shop page too.

  18. Stas on November 4, 2015 at 4:19 pm

    does themeprefix have to be replaced maybe? with the themename or what would be the exact value? thx.

    • Neil Gee on November 8, 2015 at 9:46 pm

      No the name ‘themeprefix’ does not need replacing that is a placeholder you can swap something more relevant to your theme name.

  19. Stas on November 4, 2015 at 4:03 pm

    doesnt seem to work for me as well. maybe its conflicting with other woocommerce plugins like WooCommerce Germanized?

  20. Robert on July 9, 2015 at 1:27 pm

    Neil,

    Is this still working for you? I know this used to work but doesn’t appear to anymore. Is there by chance an updated snippet?

    Thanks,
    Robert

  21. Tyler on June 9, 2015 at 2:48 pm

    Thanks for the post however for me this is just redirecting to the homepage. Any idea?

    • WooCamp on September 25, 2015 at 7:44 pm

      Tyler, it sounds like your pages are not set correctly in Woo’s Settings.
      Navigate to WooCommerc > Settings > Checkout Tab, then look down the page for the heading of “Checkout Pages”. Make sure your cart and checkout pages are set correctly.

      • raheek on May 1, 2017 at 8:22 am

        thanks a lot , but i want my add to cart botton lead to the chekout page not the product add to cart boutton because sometimes the client select so many products not only one ,

Leave all Comment