WooCommerce: Holiday/Pause/Closed Mode

A WooCommerce freelance client had a special request for their online store. And sometimes, just like physical stores, your WooCommerce website need to go on holiday! This means disabling cart, checkout and show a little notice on every WooCommerce page.

WooCommerce Holiday/Pause Mode: disable cart, checkout, add to cart
WooCommerce Holiday/Pause Mode: disable cart, checkout, add to cart

PHP Snippet: WooCommerce Holiday/Pause Mode

A little note: of course this snippet can be controlled by an “ON/OFF” switch in the WooCommerce settings. To make this snippet easier, however, I haven’t provided this additional functionality.

 * @snippet       WooCommerce Holiday/Pause Mode
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=20862
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.5.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/

// Trigger Holiday Mode

add_action ('init', 'bbloomer_woocommerce_holiday_mode');

// Disable Cart, Checkout, Add Cart

function bbloomer_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', 'bbloomer_wc_shop_disabled', 5 );
   add_action( 'woocommerce_before_cart', 'bbloomer_wc_shop_disabled', 5 );
   add_action( 'woocommerce_before_checkout_form', 'bbloomer_wc_shop_disabled', 5 );

// Show Holiday Notice

function bbloomer_wc_shop_disabled() {
        wc_print_notice( 'Our Online Shop is Closed Today :)', 'error');

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

48 thoughts on “WooCommerce: Holiday/Pause/Closed Mode

  1. Unfortunately it doesn’t work with using Divi using their modules to create the page.

    1. Pity. Divi heavily overrides Woo as long as I know, so some hooks might be different

  2. Is there a way to schedule this code? For example, if I want it to run on 24 December – 5 January.

    1. Hi Zuleika, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. It works! Thanks so much. The only improvements I’d like are:-
    1. To center the message “Our Online Shop is Closed Today :)”
    2. Can I access the version which can be controlled by an β€œON/OFF” switch in the WooCommerce settings? Otherwise, to keep it simple but to disable this, should I just comment out the final lines of code:-

    function bbloomer_wc_shop_disabled() {
            wc_print_notice( 'Our Online Shop is Closed Today :)', 'error');
    1. 2) Just comment out the line that triggers that function, not the function.

      Hope this helps!

  4. Hello this code still work.
    thank you.

    1. Great!

  5. Hi!
    Can this snippet be translated? I use WMPL but can’t find it with the string translation tool.

    1. Hey Olele, thanks for your comment! In order to make a string translatable you have to wrap it in a __() function: https://codex.wordpress.org/I18n_for_WordPress_Developers#Translatable_strings – hope this helps πŸ™‚

  6. Worked like a charm, thank you!

    In combination with a cookie-enabled popup (“sold separately” πŸ™‚ ), this is exactly what the doctor ordered!

    Appreciate you sharing this useful code. Thanks!

    1. Great!

  7. Hello Rodolfo,
    Thx for this snippet.
    You speak about ON/OFF functionality, do you have Tips to add this ?

    1. Not at the moment, sorry!

      1. Hello,

        I am very newbie WP developer.

        I didn’t know how to add the ON/OFF functionallity but I put all your snippet code in a separate plugin with the following description:

        > Description: Activating this plugin will disable SHOP or Purchases.

        and I use “Activate/Deactivate” from the “WordPress -> Plugins” tab.

        If it’s stupid, but it works, then it isn’t stupid, right?

        Interestingly enough the Shop and Basket can still be visited, but you cannot “proceed to checkout” and “wc_print_notice” is displayed.

        Kind Regards,

        1. Cool!

  8. worked perfectly on the theme ‘wplms’

    1. Great!

  9. Many thanks for this code snippet, I used the above code today on a Divi themed site with php7, all worked well.

    I have copied the entire code to my blog as reference for myself, so I know how to open the shop on my return as well as linking back to this page with credit to yourself. (if that is ok).

    1. Cool πŸ™‚ Happy new year!

  10. 1st thx a lot Rodolfo! ppl plz knows someone (sure u know Rodolfo, plz answer my friend) how to do it for different days and hours? example close th store on sundays or at middays………….. thx a lot

    1. Hey there, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  11. Is there an Option, to make the Snippet Code like this, that the add to cart is disable, only on Tuesday.
    Monday, Wednesday…Sunday the add to cart is enable from 17 o clock until 2 pm?
    is this possible, i search a plugin like this, since 5 Hours… I hope you can help me..

    1. Hey Mergim, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  12. Hi, great work, I was just wondering how it is detected the opening/closing hours etc, I am using the Business Hours plugin to set those, are these automatically detected? many Thanks

    1. Hey Paul, thanks for your message! No, my snippet is generic and only compatible with default WooCommerce. Sorry πŸ™‚

  13. Wonderful, thank you! I’d always rather add a snippet than download yet another plugin if I can go that way. Good job.

  14. Thank you! Just added it – was exactly what I needed.

    1. Cheers Cathy – happy holidays then πŸ™‚

  15. Thank you for this example. I just added it to my functions.php file and it seems to be working correctly. There is a nice looking plugin in the WordPress repository as well for putting Woo shops on Vacation, however at least one order somehow slipped through that plugin.

    1. Excellent, thank you Tim πŸ™‚

  16. Thank you so much. The code worked perfectly. How can I operate the button β€œON/OFF” switch in the WooCommerce settings.

    1. Thaigon, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  17. This code was really helpful, nice easy way to ensure the shop is closed while I transfer the site over to another server and setup SSL.

    Thank you!

    1. Cheers Charlotte πŸ™‚

  18. Hi, it worked pefectly! Thanks a lot, solves a big problem for me.

  19. Just wanted to say “Thanks all”

    That was awesome and so helpful when moving servers to put the old site on ice πŸ˜‰

    1. Great, thank you Thomaz!

  20. Hi
    Thrilled to find this – set it up to test it out and it looks like it works great ! I am presently setting up a development site to replace my 14 year old oscommerce store. I am wondering if perhaps it wouldnt be beneficial or possible to allow customers to add items to their cart, but just not checkout.
    I had something similar on my oscommerce store that worked this way, the benefit it that once you return from vacation, you can view what people wanted to buy while you were away, contact them advising the store was now open and perhaps regain the sale. Would love to hear your thoughts on this.

    1. Hey Deb, thanks for your comment! You could disable automatic payments, and enable “COD” (rename it to something else). In that way the user completes the checkout but doesn’t pay, and when you come back from the Order page you can invoice them πŸ™‚

    2. I think I found my solution – if I comment out the first 2 remove actions in your code –

      // 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 );

      then customers are able to add to cart, but the checkout is still disabled. This seems to work well and it will then create an abandoned cart, and I can contact them on return from vacation. I cant see that it is negatively affecting anything else…. your thoughts ?

      1. Yes, that looks perfect πŸ™‚

  21. Rodolfo,
    How is this different than the Woocommerce site-wide store notice? I’m trying to use that to show a sale throughout the month and it is actually covering up my navigation bar so am wondering if your suggestion might meet my need and NOT cover it up.

    1. Hey Liz, thanks for your comment! Well, yes you can re-adapt this and it will show a notice inside the content, not above the page. The Woo site-wide store notice might work too, but you’ll need to play with custom CSS and z-index to decide which one should stay on top. Let me know πŸ™‚

  22. Thank you for this wonderful snippet, it works perfectly!!

    1. And thank you for your wonderful feedback πŸ™‚

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *