WPSlash

How to Conditionally Exclude Orders from Automatic Printing in WooCommerce

Tuesday April 6, 2021

For restaurants and food delivery businesses using WooFood’s Automatic Order Printing Software, there may be situations where you don’t want certain orders to be printed automatically. For example, gift card purchases, digital products, or specific menu items may not require a printed order ticket.

With a simple WooCommerce filter, you can dynamically exclude orders from being processed by the automatic printing software based on specific conditions.


Why Exclude Certain Orders from Automatic Printing?

✔ Prevents unnecessary order printing – Avoids wasting paper on digital or non-food items.
✔ Customizes order processing – Exclude gift cards, promotional items, or specific menu categories.
✔ Enhances workflow efficiency – Ensures only relevant food orders are sent to the kitchen.
✔ Works seamlessly with WooFood – Fully compatible with the WooFood order management system.


How to Exclude Specific Orders from WooFood’s Automatic Printing System

To prevent specific WooCommerce orders from being printed automatically, add the following PHP snippet to your theme’s functions.php file:

add_filter("woofood_rest_include_order_in_software", "wpslash_exclude_order_from_software", 10, 2);
function wpslash_exclude_order_from_software($bool, $order_data)
{
	global $woocommerce;
	foreach ( $order_data["line_items"] as $line_item ) {
   $product_id = intval($line_item['product_id']);
 	$product = wc_get_product($product_id);
		
		if ($product->is_type('gift-card')) {
        	return false;


    }
}
	return $bool;
}

How This Code Works

✅ The woofood_rest_include_order_in_software filter controls whether an order is included in the WooFood automatic printing system.
✅ The function checks all products in an order to see if any are classified as “Gift Cards”.
✅ If a gift card product type is detected, the order is excluded from printing.
✅ Otherwise, the order is processed as usual and sent to the kitchen printer.


Best Practices for Implementing Conditional Order Exclusions

🔹 Customize the product type – Modify the filter to exclude other categories, like merchandise or digital downloads.
🔹 Expand conditions – Add logic to exclude orders based on shipping method, payment type, or specific user roles.
🔹 Test before deployment – Ensure the function works correctly by placing test orders.


Upgrade Your WooCommerce Food Ordering System with WooFood

Managing restaurant and food delivery orders efficiently is essential for seamless operations. Instead of manually sorting which orders should be printed, you can automate the process with WooFood’s advanced order management features.

Why Choose WooFood?

✅ Fully customizable order processing – Control which orders are printed automatically.
✅ Perfect for food businesses – Supports delivery, pickup, and in-house dining orders.
✅ Compatible with WooCommerce – Easily integrates into your existing WordPress website.
✅ Automatic order printing – Send relevant orders directly to the kitchen without delays.

🚀 Optimize Your WooCommerce Restaurant Ordering System Today!

👉 Check out WooFood – The Ultimate WooCommerce Food Delivery Plugin and streamline your restaurant’s order processing!

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