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!
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!
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
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
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
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!
we can use this instead of the above
If that works, then of course!
This is perfect! Thank you. Love your code snippets ๐
Thanks!
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?
Great. Nope, that’s a different thing. Sorry
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
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!
wow its working….. can it working automatically i.e. notice will appear automatically every Friday and disappear Sunday???
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!
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
Ouch. Test with a different theme please?
Great little code snippet. Works perfect with woocommerce 4.2.2 and the sober theme. Thanks a lot
Nice!
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.
Not sure I understand ๐
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.
Great!
Hi Rodolfo. Colin here in sunny Scotland. Tested this snippet in my functions file on wordpress 5.4
It works fine
Excellent
Hi,
how can use this snippet only for wholesale role?
Wholesale role is: “wholesale_customer”
Thanks
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!
Working!!!!!
date: 2020-02-17
WordPress: 5.3.2
Woocomerce: 3.9.2
Storefront: 2.5.3
very neat solution
Great!
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
It should still work
Unfortunately it doesn’t work with using Divi using their modules to create the page.
Pity. Divi heavily overrides Woo as long as I know, so some hooks might be different
Is there a way to schedule this code? For example, if I want it to run on 24 December – 5 January.
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!
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:-
2) Just comment out the line that triggers that function, not the function.
Hope this helps!
Hello this code still work.
thank you.
Great!
Hi!
Can this snippet be translated? I use WMPL but can’t find it with the string translation tool.
Thanks!
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 ๐
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!
Great!
Hello Rodolfo,
Thx for this snippet.
You speak about ON/OFF functionality, do you have Tips to add this ?
Thx.
Not at the moment, sorry!
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
Cool!
worked perfectly on the theme ‘wplms’
Great!
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).
Cool ๐ Happy new year!
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
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
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..
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
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
Hey Paul, thanks for your message! No, my snippet is generic and only compatible with default WooCommerce. Sorry ๐
Wonderful, thank you! I’d always rather add a snippet than download yet another plugin if I can go that way. Good job.
Excellent ๐
Thank you! Just added it – was exactly what I needed.
Cheers Cathy – happy holidays then ๐
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.
Excellent, thank you Tim ๐
Thank you so much. The code worked perfectly. How can I operate the button โON/OFFโ switch in the WooCommerce settings.
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
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!
Cheers Charlotte ๐
Hi, it worked pefectly! Thanks a lot, solves a big problem for me.
Cheers Louis!
Just wanted to say “Thanks all”
That was awesome and so helpful when moving servers to put the old site on ice ๐
Great, thank you Thomaz!
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.
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 ๐
I think I found my solution – if I comment out the first 2 remove actions in your code –
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 ?
Yes, that looks perfect ๐
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.
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 ๐
Thank you for this wonderful snippet, it works perfectly!!
And thank you for your wonderful feedback ๐