WPSlash

How to Disable Actions and Show an Overlay When Your WooCommerce Store is Closed

Thursday June 2, 2022

If you’re running a WooCommerce restaurant ordering system, you may want to disable ordering and display an overlay when your store is closed or not accepting orders. This ensures that customers know when ordering is unavailable, improving the user experience.

In this guide, we’ll show you how to use a simple PHP snippet to automatically disable WooCommerce orders and display an overlay notification when the store is closed.


Why Disable Actions and Show an Overlay When the Store is Closed?

✔ Prevents customers from placing orders when your restaurant is not operating
✔ Enhances the user experience by providing clear availability updates
✔ Avoids confusion and reduces customer complaints about unexpected order closures
✔ Improves order management for restaurants using WooCommerce

For WooCommerce food delivery websites, this feature is especially useful when using a dedicated ordering plugin like WooFood.


How to Show an Overlay When the Store is Closed in WooFood

To display a store closed overlay when orders are disabled in WooFood, add the following PHP snippet to your theme’s functions.php file:

<?php
add_action( 'wp_footer', 'wpslash_woofood_disabled_store_overlay');

function wpslash_woofood_disabled_store_overlay()
{
   $woofood_options = get_option('woofood_options');
  $order_types = woofood_get_order_types();
  $default_order_type=woofood_get_default_order_type();
  $order_types_enabled_now = array();
  foreach( $order_types as $order_type => $order_type_name)
  {
    $is_enabed = isset($woofood_options["woofood_force_disable_".$order_type."_option"]) ? $woofood_options["woofood_force_disable_".$order_type."_option"] : null;
    if(!$is_enabed)
    {
       $order_types_enabled_now[$order_type] =true;
    }


  }

  if(empty($order_types_enabled_now))
  {
    ?>
<div class="woofood-disabled-overlay">
    <div class="woofood-overlay-content-disabled">
       <?php echo apply_filters('woofood_disabled_overlay_message', esc_html__('Store is currently disabled..', 'woofood-plugin')); ?>
    </div>
    </div>
    <?php
  }


}
?>

How This Code Works

✅ The function wpslash_woofood_disabled_store_overlay() checks whether WooFood ordering is currently disabled.
✅ If all order types (delivery and takeaway) are disabled, it displays an overlay message.
✅ The overlay appears on all pages, preventing users from placing orders.
✅ The CSS styles make the overlay visually clear, with a background notification.


Best Practices for Implementing the Store Closed Overlay

🔹 Customize the overlay message using the WooFood filter hook woofood_disabled_overlay_message.
🔹 Modify the CSS styles to match your restaurant’s branding.
🔹 Test the feature on a staging website before deploying it to your live WooCommerce store.


Looking for an Advanced WooCommerce Food Delivery Solution?

Managing restaurant orders on WooCommerce can be challenging, especially when handling delivery schedules, order restrictions, and customer notifications. If you want a complete restaurant ordering systemWooFood is the best choice.

Why Choose WooFood?

✅ Full WooCommerce integration – Manage all orders from your WordPress dashboard.
✅ Flexible ordering options – Accept both pickup and delivery orders.
✅ Schedule-based ordering – Automatically disable orders when your restaurant is closed.
✅ Custom delivery zones – Set delivery distance restrictions and fees.
✅ Automatic order printing – Print orders instantly for faster kitchen processing.

🚀 Upgrade Your Restaurant’s Ordering System Today!

👉 Check out WooFood – The Ultimate WooCommerce Food Delivery Plugin

Leave a Comment

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

Related Articles

WooFood

How to Disable Coupons for Delivery Orders in WooCommerce

If you’re running a WooCommerce-powered restaurant or food delivery service, you might want to restrict certain coupon codes for delivery orders while keeping them valid for pickup orders. This ensures better control over discounts, prevents misuse, and improves your store’s pricing strategy. Why Restrict Coupons for Delivery Orders? Offering coupons is a great way to attract customers, but in food […]
June 20, 2023
WooFood

How to Automatically Re-Enable Disabled Products in WooFood Once a Day

If you’re running a WooCommerce-powered restaurant ordering system using WooFood, you might have products that automatically get disabled due to stock limits or availability settings. To ensure a smooth customer experience, you can automate the re-enabling process using a scheduled WordPress cron job. This method allows you to reset all product availability once a day, ensuring your menu stays active without manual intervention. Why […]
March 8, 2023
WooFood

How to Add Live Product Search to WooFood in WooCommerce

Enhancing the user experience of your WooCommerce-powered restaurant ordering system is crucial, and adding a live product search feature can significantly improve navigation. This feature allows customers to quickly find food items in your WooFood-powered menu without manually browsing through categories. In this article, we’ll show you how to integrate a live product search above the accordion menu in WooFood using a simple jQuery script and PHP snippet. […]
December 29, 2022