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