WooCommerce One-Click Checkout – Skip the Cart

You’ll learn to replace the ‘add to cart’ buttons with ‘Buy It Now’ buttons to send the customer directly to the checkout (skip the cart). You’ll also see how to customize the cart and checkout items in your menu.

I also show how to remove the “Item has been added to your cart” message from WooCommerce, to tidy up the user experience.

All the PHP used in the video is here:

//skip cart and go straight to checkout
add_filter( 'woocommerce_add_to_cart_redirect', 'skip_wc_cart' ); 
function skip_wc_cart() {
   return wc_get_checkout_url();
}

//customize add to cart text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'lw_cart_btn_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'lw_cart_btn_text' );
//Changing Add to Cart text to Buy It Now 
function lw_cart_btn_text() {
 return __( 'Buy It Now', 'woocommerce' );
}

//remove the "has been added to your cart" message
add_filter( 'wc_add_to_cart_message_html', '__return_false' );

CSS used to hide the ‘view cart’ link in the Kadence theme mini cart:

.woocommerce.widget_shopping_cart .buttons a:not(.checkout), .woocommerce .widget_shopping_cart .buttons a:not(.checkout) {
    display: none;
}

The menu customizations here are for Kadence theme (free version), which I’ve done many tutorials here for on the channel. It’s probably #1 recommendation for a free theme at the moment.

You can use the PHP in this tutorial either by using a code snippets plugin, or by adding it to the functions.php of your child theme – we talk about both options in the video.

Here are the links for child themes for Kadence, Astra and others:

Kadence: https://www.kadencewp.com/child-themes/

Astra: https://wpastra.com/child-theme-generator/

Generator for many themes: https://childtheme-generator.com/create-child-theme

Similar Posts