ByPass WooFood functionality on Checkout Page for specific products or category

The following example will exclude the products you will specify in $exluded_ids from WooFood functionality function wpslash_conditionally_disable_woofood_functionality($true) { global $woocommerce; $exluded_ids = array(1941, 134); if(WC()->cart && !is_admin()) { foreach( WC()->cart->get_cart() as $cart_item ){ $product_id= $cart_item['product_id']; if( in_array($product_id, $exluded_ids)) { return false; } } } return $true; } add_filter("woofood_core_functionality_enabled", "wpslash_conditionally_disable_woofood_functionality", 10, 1); If you want to...

January 20, 2021 WPSlash

The following example will exclude the products you will specify in $exluded_ids from WooFood functionality

function wpslash_conditionally_disable_woofood_functionality($true)
{

    global $woocommerce;

    $exluded_ids = array(1941, 134);
if(WC()->cart && !is_admin())
	{
    foreach( WC()->cart->get_cart() as $cart_item ){
        $product_id= $cart_item['product_id'];

        if( in_array($product_id, $exluded_ids))
        {
            
            return false;
        }
    }
}
    return $true;

}
add_filter("woofood_core_functionality_enabled", "wpslash_conditionally_disable_woofood_functionality", 10, 1);

If you want to exclude a whole category from WooFood functionality you can use the following code snippet

function wpslash_conditionally_disable_woofood_functionality($true)
{

    global $woocommerce;

    $exluded_cats = array(25);
if(WC()->cart && !is_admin())
	{
    foreach( WC()->cart->get_cart() as $cart_item ){
        $product_id= $cart_item['product_id'];
        $product_terms = get_the_terms( $product_id , 'product_cat' );
		$cat_ids = array();
		 foreach ($product_terms as $term_cat) { 
   			 $cat_ids[]= $term_cat->term_id; 
    
			}


        if( in_array($cat_ids[0], $exluded_cats))
        {
            
            return false;
        }
    }
}
    return $true;

}
add_filter("woofood_core_functionality_enabled", "wpslash_conditionally_disable_woofood_functionality", 10, 1);

Commission-free ordering

Run restaurant orders on your own WordPress site

FoodMaster adds delivery, pickup, dine-in, POS, and kitchen tools — with zero per-order fees.

Get FoodMaster

Leave a Comment

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

×

🔥 ONE DAY ONLY OFFER 🔥

Upgrade FoodMaster Today

Normally your license is limited to 1 Website.

Today only, get a LIFETIME Unlimited Websites License for just:
$499

✔ Unlimited Client Websites
✔ Unlimited Personal Projects
✔ Future Updates Included
✔ Save Hundreds on Additional Licenses

Offer Ends In: