WooCommerce: Enable Holiday / Pause / Vacation Mode

Sometimes, just like physical stores, your WooCommerce website may need a few days off!

And instead of saying nothing and getting stuck with unwanted orders and tons of customer support, maybe you can temporarily pause your WooCommerce store.

In WooCommerce words, this means hiding the add to cart buttons (one line of code) and also show a little notice on every WooCommerce page (one simple setting).

In this way customers are informed that the store is on hold, preventing misunderstandings about order processing times.

Enjoy!

WooCommerce Holiday / Pause / Closed Mode: add to cart buttons are hidden and therefore it’s not possible to go to Cart, Checkout and complete an Order.

PHP Snippet: WooCommerce Vacation / Catalog Mode – Hide Add to Cart Buttons

/**
 * @snippet       WooCommerce Holiday / Pause Mode
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 8
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_is_purchasable', '__return_false' );

Setting: WooCommerce Holiday Mode – Enable Store Notice

Go to WP Dashboard > Appearance > Customize > WooCommerce > Store Notice, type in your message, and click on “Enable store notice” (see screenshot above).

Business Bloomer WooCommerce Holiday Mode Mini-Plugin

You don’t feelย confident with coding?ย You donโ€™t want to purchase yet anotherย bloated, expensive plugin? Great!

Business Bloomer WooCommerce Holiday / Pause / Vacation Mode Mini-Pluginย comes without the usual WordPress plugin hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WordPress notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. Super simple settings.

Speaking of which, here are the settings:

And here’s the outcome:

As you can see the plugin is straight forward.ย Install it, enable holiday mode, optionally disable add to cart and display notices, and you’re good to go. Simple!

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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. Follow @rmelogli

78 thoughts on “WooCommerce: Enable Holiday / Pause / Vacation Mode

  1. Works great with but with one minor exception, virtual products can still be added to the cart. The cart is disabled as expected. Using YITH WooCommerce Gift Cards plugin to create the virtual product. Woo 6.0.0, WP 5.8.2

    1. Thanks for that Neal! Virtual product (default ones) use the same add to cart button as other product types, so this will hide buttons for all standard products. If YITH uses its own buttons that I don’t know, in case you’ll need custom code for that

  2. Is it possible to apply this code to all the products but keep active 4 or 5?
    I wonder if I need to apply some kind of conditional like if($post->ID != 671),

    Thnaks

    1. Hi Renzo, 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. 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 );
    }
    

    we can use this instead of the above

    function bbloomer_woocommerce_holiday_mode() {
       add_filter( 'woocommerce_is_purchasable', '__return_false'); // 
       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 );
    }
    
    1. If that works, then of course!

  4. This is perfect! Thank you. Love your code snippets ๐Ÿ˜‰

    1. Thanks!

  5. Hi Rodolfo, this is just what I need.

    I run a store with some subscription products – will this code stop those renewals from processing during the “closed” period?

    1. Great. Nope, that’s a different thing. Sorry

  6. Hi there
    How can I use this code to open and close my woocommerce store in special hours? i.e open in 8:00 A.M and close in 11:00 P.M

    1. Hi Mohammad, 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!

  7. wow its working….. can it working automatically i.e. notice will appear automatically every Friday and disappear Sunday???

    1. Hi Umar, 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!

  8. Hi, On my site it is not showing Holiday Notice, others works fine,.

    Using WP Version 5.4.2 and WooCommerce Version 4.3.0

    1. Ouch. Test with a different theme please?

  9. Great little code snippet. Works perfect with woocommerce 4.2.2 and the sober theme. Thanks a lot

    1. Nice!

  10. Works great with Woocommerce!!! Except it still allows the person to the “shop” url which displays all the products and allows them to add to cart.

    1. Not sure I understand ๐Ÿ˜

  11. Nice little snippet! I was wondering what to do as this is the first time any of my clients have wanted to turn off the ability to purchase.

    Worked like a charm with Woocommerce 3.8.1, WP 5.3.2 and Beaver Builder.

    1. Great!

      1. Hi Rodolfo. Colin here in sunny Scotland. Tested this snippet in my functions file on wordpress 5.4
        It works fine

        1. Excellent

  12. Hi,

    how can use this snippet only for wholesale role?

    Wholesale role is: “wholesale_customer”

    Thanks

    1. Hi Mimmo, 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!

  13. Working!!!!!

    date: 2020-02-17
    WordPress: 5.3.2
    Woocomerce: 3.9.2
    Storefront: 2.5.3

    very neat solution

    1. Great!

  14. Hi, this has been working awesome until I updated to Woocommerce Version 3.8.1, is there any way to have it mended for this version? A great solution while being able to keep the shop running!

    Cheers,

    Tom

    1. It should still work

  15. 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

  16. 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!

  17. 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!

  18. Hello this code still work.
    thank you.

    1. Great!

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

    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 ๐Ÿ™‚

  20. 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!

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

    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,
        Mike

        1. Cool!

  22. worked perfectly on the theme ‘wplms’

    1. Great!

  23. 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!

  24. 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

  25. 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

  26. 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 ๐Ÿ™‚

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

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

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

  29. 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 ๐Ÿ™‚

  30. 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

  31. 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 ๐Ÿ™‚

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

  33. 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!

  34. 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 ๐Ÿ™‚

  35. 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 ๐Ÿ™‚

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

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

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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