WooCommerce Skip Cart, Go Straight to Checkout Page

March 19, 2020 0 comments
WooCommerce Skip Cart, Go Straight to Checkout Page

WooCommerce is a flexible, open-source eCommerce solution built on WordPress. Whether you’re launching a business, taking an existing brick and mortar store online, or designing sites for clients you can get started quickly and build exactly the store you want.

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.

Steps

  • First, uncheck the cart options in WooCommerce Settings -> Products.
  • Then add in your functions.phpadd_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.
  • 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.

Ashok kuikel

Ashok Kuikel is DevOps Engineer(Cloud Computing and Cyber Security), Entrepreneur working on Socio-Economic Development via Technology

He has been actively contributing as Joint Secretary of Federation of Computer Association of Nepal Kavre Chapter. Beside that, he is an official Global Peace Ambassador for Global Peace Chain, Nepal Chapter and Member of Internet Society, Nepal Chapter.

Above all, he enjoys learning about new trends and technologies and loves to share innovative ideas to contribute for the growth of the industry.

You can follow me on Social Media, GitHub, and via my Blog Channels.

Leave a Reply

Articles and Tutorials

We love writing about WordPress and latest plugins tutorials, WooCommerce stats, and much more.