Skip Cart Go Straight to Checkout Page in WooCommerce

WooCommerce workflow can be a little too long for simple products, 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 less steps to the end product which makes the process simpler for the buyer.

18 Comments

  1. 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.

  2. 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();
      });

  3. 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?

  4. 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.

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

    thanks a ton

  6. 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??

  7. 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?

  8. 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.

  9. 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.

  10. 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?

  11. 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

  12. 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 a Comment





%d bloggers like this: