Conditionally Exclude Orders from Automatic Printing Software

April 6, 2021

TutorialsWooFood
woocommerce food orderingwordpress food ordering plugin

The following snippet will exclude orders including Products with type “Gift Card”

You can adjust the following snippet to your needs to conditionally change the orders to be included in software

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;
}