get_max_upload_count

The WooCommerce Upload My File get max upload count function.

Description

get_max_upload_count( $order, (int) $order_item = 0 ); 

Parameters (2)

0. $order
The order.
1. $order_item — Optional. (int)
The order item.

Usage

  1. if ( !function_exists( 'get_max_upload_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-upload-my-file/inc/umf-funct.php'; 
  3.  
  4. // The order. 
  5. $order = null; 
  6.  
  7. // The order item. 
  8. $order_item = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_max_upload_count($order, $order_item); 
  12.  

Defined (1)

The function is defined in the following location(s).

/inc/umf-funct.php  
  1. function get_max_upload_count($order, $order_item=0) { 
  2. $max_upload_count=0; 
  3. //product specifiek 
  4. if( (( is_array( get_option( 'woocommerce_umf_status' ) ) && in_array( $order->status, get_option( 'woocommerce_umf_status' ) ) ) ) || $order->status == get_option( 'woocommerce_umf_status' ) ) { 
  5. if($order_item!=0) { 
  6. $product = woocommerce_umf_get_product($order_item); 
  7. if( woocommerce_umf_get_product_meta($product, 'woo_umf_enable') == 1) { 
  8. $max_upload_count=1; 
  9. } else { 
  10. // order totaal 
  11. foreach ( $order->get_items() as $order_item ) { 
  12. $product = woocommerce_umf_get_product($order_item['product_id']); 
  13. $limit=1; 
  14. if( woocommerce_umf_get_product_meta($product, 'woo_umf_enable') == 1 && $limit > 0 ) { 
  15. $max_upload_count+=$limit; 
  16. return $max_upload_count;