wooccm_remove_notices_conditional

The WooCommerce Checkout Manager wooccm remove notices conditional function.

Description

wooccm_remove_notices_conditional( $posted ); 

Parameters (1)

0. $posted
The posted.

Usage

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

Defined (1)

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

/includes/classes/main.php  
  1. function wooccm_remove_notices_conditional( $posted ) { 
  2. $notice = WC()->session->get( 'wc_notices' ); 
  3.  
  4. $shipping = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ); 
  5. $billing = array( 'country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode', 'email', 'phone' ); 
  6.  
  7. $names = array( 'billing', 'shipping' ); 
  8. $inc = 3; 
  9.  
  10. foreach( $names as $name ) { 
  11.  
  12. $array = ($name == 'billing') ? $billing : $shipping; 
  13.  
  14. $options2 = get_option( 'wccs_settings'.$inc.'' ); 
  15.  
  16. foreach ( $options2[''.$name.'_buttons'] as $btn ) : 
  17.  
  18. if( !empty($btn['chosen_valt']) && !empty($btn['conditional_parent_use']) && !empty($btn['conditional_tie']) && $btn['type'] !== 'changename' && ($btn['type'] !== 'heading') && !empty($btn['conditional_parent']) ) { 
  19.  
  20. if( !empty($_POST[$btn['cow']]) ) { 
  21.  
  22. foreach( $options['buttons'] as $btn2 ) { 
  23. if( !empty($btn2['chosen_valt']) && !empty($btn2['conditional_parent_use']) && !empty($btn2['conditional_tie']) && $btn2['type'] !== 'changename' && ($btn2['type'] !== 'heading') && empty($btn2['conditional_parent']) ) { 
  24.  
  25.  
  26. if( $_POST[''.$btn['cow'].''] != $btn2['chosen_valt'] ) { 
  27. if( empty($_POST[''.$btn2['cow'].'']) ) { 
  28. foreach( $notice[error] as $position => $value ) { 
  29. if( strip_tags($value) == ''.wpml_string_wccm_pro($btn2['label']).' is a required field.' ) { 
  30. unset($notice[error][$position]); 
  31. }  
  32. } else { 
  33. foreach( $notice[error] as $position => $value ) { 
  34. if( strip_tags($value) == ''.wpml_string_wccm_pro($btn2['label']).' is a required field.' ) { 
  35. unset($notice[error][$position]); 
  36.  
  37. endforeach; 
  38. $inc--; 
  39.  
  40. $options = get_option( 'wccs_settings' ); 
  41. global $woocommerce; 
  42.  
  43. foreach( $options['buttons'] as $btn ) { 
  44. if( !empty($btn['chosen_valt']) && !empty($btn['conditional_parent_use']) && !empty($btn['conditional_tie']) && $btn['type'] !== 'changename' && ($btn['type'] !== 'heading') && !empty($btn['conditional_parent']) ) { 
  45.  
  46. if( !empty($_POST[$btn['cow']]) ) { 
  47.  
  48. foreach( $options['buttons'] as $btn2 ) { 
  49. if( !empty($btn2['chosen_valt']) && !empty($btn2['conditional_parent_use']) && !empty($btn2['conditional_tie']) && $btn2['type'] !== 'changename' && ($btn2['type'] !== 'heading') && empty($btn2['conditional_parent']) ) { 
  50.  
  51.  
  52. if( $_POST[''.$btn['cow'].''] != $btn2['chosen_valt'] ) { 
  53. if( empty($_POST[''.$btn2['cow'].'']) ) { 
  54. foreach( $notice[error] as $position => $value ) { 
  55. if( strip_tags($value) == ''.wpml_string_wccm_pro($btn2['label']).' is a required field.' ) { 
  56. unset($notice[error][$position]); 
  57. }  
  58. } else { 
  59. foreach( $notice[error] as $position => $value ) { 
  60. if( strip_tags($value) == ''.wpml_string_wccm_pro($btn2['label']).' is a required field.' ) { 
  61. unset($notice[error][$position]); 
  62.  
  63. WC()->session->set( 'wc_notices', $notice );