Temporarily disable WooCommerce store

0

How to make a WordPress store made with WooCommerce plugin in maintenance?

I thought about taking the 'LOJA' menu from the top of the site, but if someone had the link saved in the browser, I could use and access it normally.

I thought about disabling the plugin, but I do not know if this will only resolve and when I want to go back to the store, it will return normally.

Remembering that there is a website in Wordpress and inside a store, what is the best way to temporarily take this shop out of the air? And then come back without missing any settings?

    
asked by anonymous 06.04.2016 / 18:18

1 answer

1

I have not tested this code but I think it might work. Add it to your theme's functions.php file.

function my_woocommerce_maintenance_mode($content) {
// condição para paginas do Woo. Mais infos: https://docs.woocommerce.com/document/conditional-tags/
    if( is_woocommerce() or is_shop() or is_product_category() or is_product_tag() or is_product() or is_cart() or is_checkout() or is_account_page() ) {
   // Mostra o que vc quiser aqui.
   $content = "Em Manutenção";
   return $content;
}
add_filter('the_content','my_woocommerce_maintenance_mode');

Maybe it's a good idea to hide the products using CSS if you've inserted them into some page outside the woo with shortcodes for example. Something like:

.products, .product {display: none !important;}

Some things I would take into consideration:

  • Do something so that Google does not index this "In Maintenance" page. It would be annoying the store's customers to search and in Google results only take on "Maintenance". And for this you can learn more about status 503 here: link
  • Maybe you want to leave this maintenance mode for everyone except you (site administrator or manager) and just add a condition like: !current_user_can( 'manage_woocommerce' ) in the function created above.
  • 14.09.2016 / 10:51