billing_scripts_enhanced

The WooCommerce Checkout Manager billing scripts enhanced function.

Description

billing_scripts_enhanced(); 

Usage

  1. if ( !function_exists( 'billing_scripts_enhanced' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-checkout-manager/includes/templates/functions/billing_functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = billing_scripts_enhanced(); 
  7.  

Defined (1)

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

/includes/templates/functions/billing_functions.php  
  1. function billing_scripts_enhanced() { 
  2. global $woocommerce; 
  3. $options = get_option( 'wccs_settings3' ); 
  4.  
  5. $saved = WC()->session->get('wooccm_retain', array() ); 
  6.  
  7.  
  8. if( !empty($options['billing_buttons']) ) { 
  9. foreach ( $options['billing_buttons'] as $btn ) : 
  10.  
  11.  
  12. if ( $btn['type'] == 'datepicker' ) { 
  13. echo '<script type="text/javascript">jQuery(document).ready(function() { var today = new Date(); jQuery("input#billing_'.$btn['cow'].'").datepicker({'; 
  14. if ( empty($btn['format_date']) ) { 
  15. echo 'dateFormat : "dd-mm-yy", ';  
  16. if ( !empty($btn['format_date']) ) { 
  17. echo 'dateFormat : "'.str_replace( ' ', '', $btn['format_date'] ).'", ';  
  18. if ( !empty($btn['single_yy']) ) { 
  19. echo 'minDate: new Date( '.$btn['single_yy'].', '.$btn['single_mm'].' - 1, '.$btn['single_dd'].'), '; 
  20. if ( !empty($btn['min_before']) ) { 
  21. echo 'minDate: '.$btn['min_before'].', '; 
  22. if ( !empty($btn['single_max_yy']) ) { 
  23. echo 'maxDate: new Date( '.$btn['single_max_yy'].', '.$btn['single_max_mm'].' - 1, '.$btn['single_max_dd'].'), '; 
  24. if ( !empty($btn['max_after']) ) { 
  25. echo 'maxDate: '.$btn['max_after'].', '; 
  26. if ( !empty($btn['days_disabler']) ) { 
  27. echo 'beforeShowDay: function(date) { var day = date.getDay(); return [('; 
  28.  
  29. if ( !empty($btn['days_disabler0']) ) { 
  30. echo 'day == 0'; 
  31. } else { echo 'day == "x"'; } 
  32. if ( !empty($btn['days_disabler1']) ) { 
  33. echo ' || day == 1'; 
  34. if ( !empty($btn['days_disabler2']) ) { 
  35. echo ' || day == 2'; 
  36. if ( !empty($btn['days_disabler3']) ) { 
  37. echo ' || day == 3'; 
  38. if ( !empty($btn['days_disabler4']) ) { 
  39. echo ' || day == 4'; 
  40. if ( !empty($btn['days_disabler5']) ) { 
  41. echo ' || day == 5'; 
  42. if ( !empty($btn['days_disabler6']) ) { 
  43. echo '|| day == 6'; 
  44.  
  45. echo ')]; }'; 
  46. echo '}); }); </script>'; 
  47. }  
  48.  
  49.  
  50. if ( $btn['type'] == 'time' ) { 
  51. echo '<script type="text/javascript">jQuery(document).ready(function() { jQuery("#billing_'.$btn['cow'].'_field input#billing_'.$btn['cow'].'").timepicker({ showPeriod: true, '; 
  52.  
  53. if ( !empty($btn['start_hour']) ) { 
  54. echo 'hours: { starts: '.$btn['start_hour'].', ends: '.$btn['end_hour'].' }, '; 
  55. if ( !empty($btn['interval_min']) ) { 
  56. echo 'minutes: {interval: '.$btn['interval_min'].', manual: ['.$btn['manual_min'].'] }, '; 
  57.  
  58. echo 'showLeadingZero: true }); }); </script>'; 
  59.  
  60.  
  61. if ( $btn['type'] == 'password' ) { 
  62. echo '<script type="text/javascript">jQuery(document).ready(function() { jQuery("p#billing_'.$btn['cow'].'_field").css("display"); }); </script>'; 
  63.  
  64.  
  65.  
  66. if ( $btn['type'] == 'colorpicker' && $btn['colorpickertype'] == 'farbtastic' ) { ?> 
  67. <script type="text/javascript"> 
  68. jQuery(document).ready(function($) { 
  69. jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide(); 
  70. jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').farbtastic("#billing_<?php echo $btn['cow']; ?>_colorpicker"); 
  71. jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function() {jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()}); 
  72.  
  73. }); 
  74. </script> 
  75. <?php } 
  76.  
  77. if ( $btn['type'] == 'colorpicker' && $btn['colorpickertype'] == 'iris' ) { ?> 
  78. <script type="text/javascript"> 
  79. jQuery(document).ready(function($) { 
  80.  
  81. $( '#<?php echo $btn['cow']; ?>_colorpicker' ).css( 'color', '#fff' ); 
  82. $( '#<?php echo $btn['cow']; ?>_colorpicker' ).css( 'background', '<?php echo $btn['colorpickerd']; ?>' ); 
  83.  
  84. var options = { 
  85. wccmclass: "billing_<?php echo $btn['cow']; ?>_colorpickerdiv",  
  86. palettes: true,  
  87. color: "",  
  88. hide: false,  
  89. change: function(event, ui) { 
  90. $( '#billing_<?php echo $btn['cow']; ?>_colorpicker' ).css( 'color', '#000' ); 
  91. $( '#billing_<?php echo $btn['cow']; ?>_colorpicker' ).css( 'background', ui.color.toString()); 
  92. }; 
  93.  
  94.  
  95. jQuery('#billing_<?php echo $btn['cow']; ?>_colorpicker').iris( options ); 
  96.  
  97. jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide(); 
  98. jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function() {jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()}); 
  99. }); 
  100. </script> 
  101. <?php } 
  102.  
  103.  
  104.  
  105. // ============================== radio button & checkbox =========================================== 
  106. if ( ($btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm') && !empty( $btn['tax_remove'] ) ) { ?> 
  107. <script type="text/javascript"> 
  108. jQuery(document).ready(function($) { 
  109.  
  110. <?php if( !empty($saved['wooccm_tax_save_method']) ) { ?>  
  111. jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true); 
  112. <?php } ?> 
  113.  
  114. jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function() { 
  115.  
  116. $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 
  117.  
  118.  
  119. var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>'; 
  120. data = { 
  121. action: 'remove_tax_wccm',  
  122. tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val()  
  123. }; 
  124.  
  125. jQuery.post(ajaxurl, data, function(response) { 
  126. $( 'body' ).trigger( 'update_checkout' ); 
  127. jQuery('form.checkout').unblock();  
  128. }); 
  129.  
  130. }); }); 
  131. </script> 
  132. <?php } 
  133.  
  134.  
  135.  
  136. if ( ($btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm') && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && !empty( $btn['add_amount_field'] ) ) { ?> 
  137. <script type="text/javascript"> 
  138. jQuery(document).ready(function($) { 
  139.  
  140. <?php if( !empty($saved['wooccm_addamount453user']) ) { ?>  
  141. jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true); 
  142. <?php } ?> 
  143.  
  144. jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function() { 
  145.  
  146. $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 
  147.  
  148. var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>'; 
  149. data = { 
  150. action: 'remove_tax_wccm',  
  151. add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() 
  152. }; 
  153.  
  154. jQuery.post(ajaxurl, data, function(response) { 
  155. $( 'body' ).trigger( 'update_checkout' ); 
  156. jQuery('form.checkout').unblock(); 
  157. }); 
  158.  
  159. }); }); 
  160. </script> 
  161. <?php } 
  162.  
  163.  
  164.  
  165.  
  166.  
  167. // =========================================== select options ========================================= 
  168. if ( ($btn['type'] == 'wooccmselect') && !empty( $btn['tax_remove'] ) ) { ?> 
  169. <script type="text/javascript"> 
  170. jQuery(document).ready(function($) { 
  171.  
  172. <?php if( !empty($saved['wooccm_tax_save_method']) ) { ?>  
  173. jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val( '<?php echo $saved['wooccm_tax_save_method']; ?>' ); 
  174. <?php } ?> 
  175. jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function() { 
  176.  
  177. $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 
  178.  
  179. var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>'; 
  180. data = { 
  181. action: 'remove_tax_wccm',  
  182. tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()  
  183.  
  184. }; 
  185.  
  186. jQuery.post(ajaxurl, data, function(response) { 
  187. $( 'body' ).trigger( 'update_checkout' ); 
  188. jQuery('form.checkout').unblock();  
  189. }); 
  190.  
  191. }); }); 
  192. </script> 
  193. <?php } 
  194.  
  195.  
  196.  
  197. if ( ($btn['type'] == 'wooccmselect') && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && !empty( $btn['add_amount_field'] ) ) { ?> 
  198. <script type="text/javascript"> 
  199. jQuery(document).ready(function($) { 
  200.  
  201. <?php if( !empty($saved['wooccm_addamount453user']) ) { ?>  
  202. jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val( '<?php echo $saved['wooccm_addamount453user']; ?>' ); 
  203. <?php } ?> 
  204.  
  205. jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function() { 
  206.  
  207. $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 
  208.  
  209.  
  210. var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>'; 
  211. data = { 
  212. action: 'remove_tax_wccm',  
  213. add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()  
  214. }; 
  215.  
  216. jQuery.post(ajaxurl, data, function(response) { 
  217. $( 'body' ).trigger( 'update_checkout' ); 
  218. jQuery('form.checkout').unblock();  
  219. }); 
  220.  
  221. }); }); 
  222. </script> 
  223. <?php } 
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. // =========================================== add apply button ========================================== 
  231.  
  232. if ( ($btn['type'] == 'text') && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && empty( $btn['add_amount_field'] ) ) { ?> 
  233. <script type="text/javascript"> 
  234. jQuery(document).ready(function() { 
  235. jQuery( "#billing_<?php echo $btn['cow']; ?>_field" ).append( '<span id="billing_<?php echo $btn['cow']; ?>_applynow"><?php _e('Apply', 'woocommerce-checkout-manager-pro'); ?></span>' ); 
  236. }); 
  237.  
  238. jQuery(document).ready(function($) { 
  239.  
  240. <?php if( !empty($saved['wooccm_addamount453userf']) ) { ?>  
  241. jQuery('input#billing_<?php echo $btn['cow']; ?>').val( '<?php echo $saved['wooccm_addamount453userf']; ?>' ); 
  242. <?php } ?> 
  243.  
  244. jQuery('#billing_<?php echo $btn['cow']; ?>_field #billing_<?php echo $btn['cow']; ?>_applynow').click(function() { 
  245.  
  246. $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 
  247.  
  248. var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>'; 
  249. data = { 
  250. action: 'remove_tax_wccm',  
  251. add_amount_faj: jQuery('input#billing_<?php echo $btn['cow']; ?>').val()  
  252. }; 
  253.  
  254. jQuery.post(ajaxurl, data, function(response) { 
  255. $( 'body' ).trigger( 'update_checkout' ); 
  256. jQuery('form.checkout').unblock();  
  257. }); 
  258.  
  259. }); }); 
  260. </script> 
  261. <?php } 
  262.  
  263.  
  264.  
  265.  
  266. // ===================================================== 
  267.  
  268. if ( $btn['type'] == 'checkbox_wccm' ) { ?> 
  269. <script type="text/javascript"> 
  270. jQuery(document).ready(function() { 
  271. jQuery('#billing_<?php echo $btn['cow']; ?>_checkbox').change(function() { 
  272. if(jQuery(this).is(':checked')) { 
  273. jQuery("#billing_<?php echo $btn['cow']; ?>_checkboxhiddenfield").prop("disabled", true); 
  274. }else{ 
  275. jQuery("#billing_<?php echo $btn['cow']; ?>_checkboxhiddenfield").prop("disabled", false); 
  276. }); 
  277. }); 
  278. </script> 
  279. <?php } 
  280. endforeach;