WooCommerce: How to Skip the Cart and Go Straight to Checkout

Scenario: You have a woocommerce store with a simple product that does not require a lengthy checkout process.

Goal: Skip the cart and lead your customers straight to checkout.

Difficulty: Easy

Coding Required: Yes

First you will need to adjust your WooCommerce settings.

Log in to your wordpress back-end and go to WooCommerce > Settings > Products > General

how to skip cart direct checkout woocommerce wordpress

Under “Add to cart behaviour” uncheck the two options in the Add to cart behavior section; “Redirect to the cart page after successful addition” and “Enable AJAX add to cart buttons on archives”

Next, add the following code to your functions.php file which is located in your active theme. You can check which theme is active by navigating to Appearance > Themes

Once you have opened up your functions.php file, add the following code:

add_filter('woocommerce_add_to_cart_redirect', 'wc_get_checkout_url');

Now that we’ve changed the behavior of the “Add to cart” button, we need to make the text make sense. We can change the text by adding the following code in the functions.php file.

function wd_change_cart_btn_text() {
    return __( 'Checkout', 'woocommerce' );
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wd_change_cart_btn_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'wd_change_cart_btn_text' );

 

There you have it!

No Comments

Be the first to start a conversation