WPSlash

How to Disable Coupons for Delivery Orders in WooCommerce

Tuesday June 20, 2023

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 delivery businesses, you may want to limit their usagefor:
✔ Preventing discounts on delivery orders where margins are lower
✔ Allowing coupon usage only for pickup orders
✔ Ensuring accurate pricing and preventing unintended losses

How to Disable Coupons for Delivery Orders in WooCommerce

To disable a WooCommerce coupon for delivery orders while keeping it valid for pickup, add the following code snippet to your child theme’s functions.php file:

add_filter( 'woocommerce_coupon_is_valid', 'wpslash_hook_disable_coupon_code_for_delivery', 10, 3 );
function wpslash_hook_disable_coupon_code_for_delivery( $is_valid, $coupon, $discount ){
    if (!is_admin())
    {

   
    $coupon_code_to_apply = "YOURCOUPONCODEHERE";
    if($coupon == $coupon_code_to_apply)
    {
      if(WC()->session)
      {
        if (WC()->session->get( 'woofood_order_type') == "delivery")
      {
        return false;
      }
      }
      
    }
  }
  
    return $is_valid;
}

Best Practices for Implementing This Code

✅ Replace "YOURCOUPONCODEHERE" with the actual coupon code you want to restrict.
✅ Test the code in a staging environment before deploying it live.
✅ Ensure that your WooCommerce setup and other plugins don’t conflict with this customization.

Need an Easier Way to Manage WooCommerce Restaurant Orders?

If you’re running a restaurant or food delivery service on WooCommerce, you need a seamless order management solution. Instead of manually restricting coupons and handling orders, you can use WooFood – WooCommerce Food Delivery Plugin.

With WooFood, you can:
✅ Accept pickup and delivery orders effortlessly
✅ Set up custom discounts and pricing rules based on order type
✅ Optimize the checkout experience for faster food ordering

👉 Check out WooFood to streamline your WooCommerce food delivery business today! 🚀

Leave a Comment

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

Related Articles

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
Tutorials WooFood

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

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 […]
June 2, 2022