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('add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
 global $woocommerce;
 $checkout_url = $woocommerce->cart->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.

14 Comments

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

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

    thanks a ton

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

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

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

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

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

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

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