How to Temporarily Disable Checkout In WooCommerce

WooCommerce Temporarily Disable Checkout
WooCommerce Temporarily Disable Checkout

There are many scenarios where online store owners might need to temporarily disable the WooCommerce checkout. For example, around the holiday season, due to a staff shortage, or simply because the products they sell are not available or on backorder.

WooCommerce Temporarily Disable Checkout

If this happens, it is a good idea to have a simple way to temporarily deactivate WooCommerce. You can also notify your customers when you will open up again. In this tutorial, I will show you to disable the checkout without deactivating the WooCommerce plugin.

You should keep in mind that if you deactivate the plugin, you would have dead links. This means that whenever a visitor tries to access your WooCommerce pages, such as your shop page or single WooCommerce product pages, they will run into a 404 page not found error message. This leads to a poor customer experience, and prospective customers might think your store is permanently closed.

Steps to Temporarily Disable Checkout

Here are the steps that you need to follow:

  1. Log into your WordPress site and access the dashboard as the admin user
  2. From the dashboard menu, click on the Appearance Menu > Theme Editor Menu. When the theme editor page is opened, look for the theme functions file with the extension functions.php. Open this functions file to Temporarily Disable Checkout
  3. Add the following line of code to the functions.php file:
/**

 *        WooCommerce Holiday/Pause Mode

*/

 // Trigger Holiday Mode

 add_action ('init', 'njengah_woocommerce_holiday_mode');

  // Disable Cart, Checkout, Add Cart

 function njengah_woocommerce_holiday_mode() {

   remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

   remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

   remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );

   remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );

   add_action( 'woocommerce_before_main_content', 'njengah_wc_shop_disabled', 5 );

   add_action( 'woocommerce_before_cart', 'njengah_wc_shop_disabled', 5 );

   add_action( 'woocommerce_before_checkout_form', 'njengah_wc_shop_disabled', 5 );

}

 // Show Holiday Notice

 function njengah_wc_shop_disabled() {

        wc_print_notice( 'Our Online Shop is Closed Today :) Please Come Back Tomorrow!', 'error');

}
  1. This is the outcome:disable woocommerce checkout

Conclusion

In this brief post, I have shared how you can temporarily disable the WooCommerce checkout. This solution will also remove the payment options and the Add to cart button. I recommend you add the code to the functions.php file of your child theme so that your changes are not lost during an update.

Similar Articles

 


Customer Reviews

NJENGAH

Customer Reviews

Jeffrey Todd 04/07/2020

Exceptional Plugin & Service

I'm in the process of building my new website, and I had a question about changing some text within the WooCommerce plugin. I was spinning my wheels trying to figure it out. Joe reached back and worked with me - going above and beyond! - until I fully understood how to effectively change what I wanted. How can you ask for more than that? I highly recommend WooCommerce (and Joe!), the plugin and service are exceptional!
-Jeffrey Todd (MyLifeChart.com)