wccm_woocommerce_delivery_notes_compat_pro

The WooCommerce Checkout Manager wccm woocommerce delivery notes compat pro function.

Description

wccm_woocommerce_delivery_notes_compat_pro( $fields, $order ); 

Parameters (2)

0. $fields
The fields.
1. $order
The order.

Usage

  1. if ( !function_exists( 'wccm_woocommerce_delivery_notes_compat_pro' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-checkout-manager/includes/classes/main.php'; 
  3.  
  4. // The fields. 
  5. $fields = null; 
  6.  
  7. // The order. 
  8. $order = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wccm_woocommerce_delivery_notes_compat_pro($fields, $order); 
  12.  

Defined (1)

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

/includes/classes/main.php  
  1. function wccm_woocommerce_delivery_notes_compat_pro( $fields, $order ) { 
  2.  
  3. $new_fields = array(); 
  4.  
  5. $shipping = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ); 
  6. $billing = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode', 'email', 'phone' ); 
  7.  
  8. $names = array( 'billing', 'shipping' ); 
  9. $inc = 3; 
  10. foreach( $names as $name ) { 
  11.  
  12. $array = ($name == 'billing') ? $billing : $shipping; 
  13.  
  14. $options = get_option( 'wccs_settings'.$inc.'' ); 
  15.  
  16. foreach ( $options[''.$name.'_buttons'] as $btn ) : 
  17.  
  18.  
  19. if ( !in_array( $btn['cow'], $array ) ) { 
  20.  
  21. if( get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ) && (($btn['type'] !== 'multiselect') || ($btn['type'] !== 'multicheckbox')) && $btn['type'] !== 'wooccmupload' && ($btn['type'] !== 'heading') ) { 
  22. $new_fields['_'.$name.'_'.$btn['cow'].''] = array(  
  23. 'label' => ''.wpml_string_wccm_pro($btn['label']).'',  
  24. 'value' => get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ) 
  25. ); 
  26.  
  27. if( get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true ) && (($btn['type'] == 'multiselect') || ($btn['type'] == 'multicheckbox')) && $btn['type'] !== 'wooccmupload' && ($btn['type'] !== 'heading')) { 
  28. $new_fields['_'.$name.'_'.$btn['cow'].'']['label'] = ''.wpml_string_wccm_pro($btn['label']).''; 
  29. $new_fields['_'.$name.'_'.$btn['cow'].'']['value'] = ''; 
  30. $strings = unserialize(get_post_meta( $order->id , '_'.$name.'_'.$btn['cow'].'', true));  
  31. $iww = 0; 
  32.  
  33. foreach( $strings as $key ) { 
  34. if ( $iww == count($strings) - 1) { 
  35. $new_fields['_'.$name.'_'.$btn['cow'].'']['value'] .= $key; 
  36. } else { 
  37. $new_fields['_'.$name.'_'.$btn['cow'].'']['value'] .= $key.', '; 
  38.  
  39. $iww++; 
  40. }elseif( $btn['type'] == 'wooccmupload' ) { 
  41. $info = explode("||", get_post_meta( $order->id, '_'.$name.'_'.$btn['cow'].'', true )); 
  42. $new_fields['_'.$name.'_'.$btn['cow'].''] = array(  
  43. 'label' => ''.wpml_string_wccm_pro($btn['force_title2']).'',  
  44. 'value' => $info[0] 
  45. ); 
  46.  
  47. endforeach; 
  48. $inc--; 
  49.  
  50.  
  51. $options = get_option( 'wccs_settings' ); 
  52.  
  53. foreach ( $options['buttons'] as $btn ) : 
  54.  
  55. if( get_post_meta( $order->id, ''.$btn['cow'].'', true ) && (($btn['type'] !== 'multiselect') || ($btn['type'] !== 'multicheckbox')) && $btn['type'] !== 'wooccmupload' && ($btn['type'] !== 'heading') ) { 
  56. $new_fields[''.$btn['cow'].''] = array(  
  57. 'label' => ''.wpml_string_wccm_pro($btn['label']).'',  
  58. 'value' => get_post_meta( $order->id, ''.$btn['cow'].'', true ) 
  59. ); 
  60.  
  61. if( get_post_meta( $order->id, ''.$btn['cow'].'', true ) && (($btn['type'] == 'multiselect') || ($btn['type'] == 'multicheckbox')) && $btn['type'] !== 'wooccmupload' && ($btn['type'] !== 'heading')) { 
  62. $new_fields[''.$btn['cow'].'']['label'] = ''.wpml_string_wccm_pro($btn['label']).''; 
  63. $new_fields[''.$btn['cow'].'']['value'] = ''; 
  64. $strings = unserialize(get_post_meta( $order->id , ''.$btn['cow'].'', true));  
  65. $iww = 0; 
  66.  
  67. foreach( $strings as $key ) { 
  68. if ( $iww == count($strings) - 1) { 
  69. $new_fields[''.$btn['cow'].'']['value'] .= $key; 
  70. } else { 
  71. $new_fields[''.$btn['cow'].'']['value'] .= $key.', '; 
  72.  
  73. $iww++; 
  74.  
  75. if( $btn['type'] == 'wooccmupload' ) { 
  76. $info = get_post_meta( $order->id, ''.$btn['cow'].'', true ); 
  77. $new_fields[''.$btn['cow'].''] = array(  
  78. 'label' => ''.wpml_string_wccm_pro($btn['force_title2']).'',  
  79. 'value' => $info[0] 
  80. ); 
  81. endforeach; 
  82.  
  83.  
  84. return array_merge( $fields, $new_fields );