How to Fix Checkout Is Not Available Whilst Your Cart Is Empty WooCommerce

Checkout Is Not Available Whilst Your Cart Is Empty WooCommerceDo you want to fix the common error in WooCommerce – checkout is not available whilst your cart is empty WooCommerce? In this post, we will demonstrate how you can get rid of this error/notice and help you fix it once and for all.

You will be required to understand how to add a code snippet to your WooCommerce theme or if you are a WooCommerce developer, you can use this code in your WooCommerce plugin.

First, we need to understand how this notice occurs so that we can figure out how to get rid of this notice if we come across it in the WooCommerce store

Checkout Is Not Available Whilst Your Cart Is Empty WooCommerce

This is a default WooCommerce notice that appears when we try to access the checkout page and the cart does not have the products or items added.

The notice is a default WooCommerce notice that we can remove as you will see in the section below.

The checkout is not available whilst your cart is empty WooCommerce notice will appear as shown in the image below :

checkout is not available whilst your cart is empty woocommerce
To get rid of this notice we simply need to use a filter that removes the WooCommerce default notices. In this case, the filter that we will use is the one share below :

add_filter( 'woocommerce_checkout_redirect_empty_cart', '__return_false' );

As you can see in the action filter above we are returning a false to get rid of the notice since it is set to true by default. To remove checkout is not available whilst your cart is empty WooCommerce notice, you should simply add this to your WooCommerce theme functions.php file or your plugin file.

As you can see I have added this action filter to the functions.php file and the notice has disappeared in the image below :

checkout is not available whilst your cart is empty WooCommerce notice

Change Checkout Is Not Available Whilst Your Cart Is Empty WooCommerce

You can customize the checkout is not available whilst your cart is empty WooCommerce to display your custom message and you can achieve this using the code snippet below :

[php] function njengah_customize_woocommerce_checkout_notice( $custom_message ) {

$custom_message = ‘Some cool custom message here ….’;

return $custom_message ;
}
add_filter( ‘woocommerce_add_notice’, ‘njengah_customize_woocommerce_checkout_notice’, 10, 1 );
[/php]

Conclusion

In this post, we have looked at how to get rid of checkout is not available whilst your cart is empty WooCommerce notice and also how you can customize it to a custom message.

Similar Articles