Dynamically Display Delivery/Pickup Time based on Product Process Time

add_filter("woofood_adjust_pickup_time", "change_dynamically_pickup_time", 10, 1);
function change_dynamically_pickup_time($default)
{
	global $woocommerce;
	if(WC()->cart)
	{
		$woofood_delivery_time = 0;
	 $all_product_times = array();
     $total_time_to_delivery = 0;
      foreach(  WC()->cart->get_cart() as $cart_item  ):

      ## Using WC_Order_Item methods ##

      // Item ID is directly accessible from the $item_key in the foreach loop or
        $item_id = $cart_item['data']->get_id();
	
      $item_name = $cart_item['data']->get_name(); // Name of the product
      $item_type = $cart_item['data']->get_type(); // Type of the order item ("line_item")

      ## Access Order Items data properties (in an array of values) ##
      $item_data = $cart_item['data']->get_data();

      $product_name = $item_data['name'];
			
      $product_id = $item_data['id'];

 
  		$all_product_times[] =  intval(get_post_meta($product_id, 'process_time_woocommerce',  true));

     	 endforeach;

    
                    $woofood_delivery_time = max($all_product_times) + intval($woofood_delivery_time) ;

   
 

    return  $woofood_delivery_time;

  

	}
	else{
		return $default;
	}




  
}