WooCommerce Checkout Manager - Version 4.4.2

Version Description

  • Fix: woocommerce checkout remove field based on categories
Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WooCommerce Checkout Manager
Version 4.4.2
Comparing to
See all releases

Code changes from version 4.4.1 to 4.4.2

includes/templates/functions/billing_functions.php CHANGED
@@ -2,367 +2,369 @@
2
  /**
3
  * WooCommerce Checkout Manager
4
  */
5
-
6
  // Exit if accessed directly
7
- if ( !defined( 'ABSPATH' ) ) exit;
 
8
 
9
  function wooccm_billing_hide_required() {
10
 
11
- global $woocommerce;
12
 
13
- $options = get_option( 'wccs_settings3' );
14
 
15
- $billing = array(
16
- 'address_1',
17
- 'address_2',
18
- 'city',
19
- 'state',
20
- 'postcode'
21
- );
22
 
23
- if( !empty( $options['billing_buttons'] ) ) {
24
- echo '
25
  <style>
26
  ';
27
- foreach( $options['billing_buttons'] as $btn ) {
28
- if( in_array($btn['cow'], $billing) && empty($btn['checkbox']) ) {
29
- echo '
30
- p#billing_'.$btn['cow'].'_field .required{
31
  display:none;
32
  }';
33
- }
34
- }
35
- echo '
36
  </style>';
37
- }
38
-
39
  }
40
 
41
  function wooccm_billing_scripts() {
42
 
43
- global $woocommerce;
44
 
45
- $options = get_option( 'wccs_settings3' );
46
 
47
- $saved = WC()->session->get( 'wooccm_retain', array() );
48
 
49
- // Check if we have any buttons
50
- if( empty($options['billing_buttons']) )
51
- return;
52
 
53
- foreach( $options['billing_buttons'] as $btn ) {
54
 
55
- if( $btn['type'] == 'datepicker' ) {
56
- echo '
57
  <script type="text/javascript">
58
  jQuery(document).ready(function() {
59
  var today = new Date();
60
  if( jQuery.isFunction(jQuery.fn.datepicker) ) {
61
- jQuery("input#billing_'.$btn['cow'].'").datepicker({
62
  ';
63
- // Default date format
64
- if( empty($btn['format_date']) )
65
- $btn['format_date'] = apply_filters( 'wooccm_datepicker_default_date_format', 'dd-mm-yy' );
66
- if( !empty($btn['format_date']) ) {
67
- echo 'dateFormat : "'.str_replace( ' ', '', $btn['format_date'] ).'",';
68
- }
69
- if( !empty($btn['single_yy']) ) {
70
- echo 'minDate: new Date( '.$btn['single_yy'].', '.$btn['single_mm'].' - 1, '.$btn['single_dd'].'),';
71
- }
72
- if( !empty($btn['min_before']) ) {
73
- echo 'minDate: '.$btn['min_before'].',';
74
- }
75
- if( !empty($btn['single_max_yy']) ) {
76
- echo 'maxDate: new Date( '.$btn['single_max_yy'].', '.$btn['single_max_mm'].' - 1, '.$btn['single_max_dd'].'),';
77
- }
78
- if( !empty($btn['max_after']) ) {
79
- echo 'maxDate: '.$btn['max_after'].',';
80
- }
81
- if( !empty($btn['days_disabler']) ) {
82
- echo 'beforeShowDay: function(date) { var day = date.getDay(); return [(';
83
- if( !empty($btn['days_disabler0']) ) {
84
- echo 'day == 0';
85
- } else { echo 'day == "x"'; }
86
- if( !empty($btn['days_disabler1']) ) {
87
- echo ' || day == 1';
88
- }
89
- if( !empty($btn['days_disabler2']) ) {
90
- echo ' || day == 2';
91
- }
92
- if( !empty($btn['days_disabler3']) ) {
93
- echo ' || day == 3';
94
- }
95
- if( !empty($btn['days_disabler4']) ) {
96
- echo ' || day == 4';
97
- }
98
- if( !empty($btn['days_disabler5']) ) {
99
- echo ' || day == 5';
100
- }
101
- if( !empty($btn['days_disabler6']) ) {
102
- echo '|| day == 6';
103
- }
104
- echo ')]; }';
105
- }
106
- do_action( 'wooccm_js_datepicker_billing_args', $btn );
107
- echo '
 
 
108
  });
109
  }
110
  });
111
  </script>
112
  ';
113
- }
114
 
115
- if( $btn['type'] == 'time' ) {
116
- $args = '
117
  showPeriod: true,';
118
- if( !empty($btn['start_hour']) ) {
119
- $args .= '
120
- hours: { starts: '.$btn['start_hour'].', ends: '.$btn['end_hour'].' },';
121
- }
122
- if( !empty($btn['interval_min']) ) {
123
- $args .= '
124
- minutes: {interval: '.$btn['interval_min'].', manual: ['.$btn['manual_min'].'] },';
125
- }
126
- $args .= '
127
  showLeadingZero: true';
128
- $args = apply_filters( 'wooccm_timepicker_jquery_args', $args, $btn );
129
- echo '
130
  <!-- Billing section: TimePicker -->
131
  <script type="text/javascript">
132
  jQuery(document).ready(function() {
133
  if( jQuery.isFunction(jQuery.fn.timepicker) ) {
134
- jQuery("#billing_'.$btn['cow'].'_field input#billing_'.$btn['cow'].'").timepicker({
135
  ';
136
- echo $args;
137
- echo '
138
  });
139
  }
140
  });
141
  </script>
142
  ';
143
- }
144
 
145
- if ( $btn['type'] == 'password' ) {
146
- echo '
147
  <script type="text/javascript">
148
  jQuery(document).ready(function() {
149
- jQuery("p#billing_'.$btn['cow'].'_field").css("display");
150
  });
151
  </script>
152
  ';
153
- }
154
-
155
- if( $btn['type'] == 'colorpicker' ) {
156
- switch( $btn['colorpickertype'] ) {
157
-
158
- case 'farbtastic':
159
- ?>
160
- <script type="text/javascript">
161
- jQuery(document).ready(function($) {
162
- jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide();
163
- if( jQuery.isFunction(jQuery.fn.farbtastic) ) {
164
- jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').farbtastic("#billing_<?php echo $btn['cow']; ?>_colorpicker");
165
- jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function(){jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()});
166
- }
167
- });
168
- </script>
169
- <?php
170
- break;
171
-
172
- case 'iris':
173
- ?>
174
- <script type="text/javascript">
175
- jQuery(document).ready(function($) {
176
-
177
- $( '#<?php echo $btn['cow']; ?>_colorpicker' ).css( 'color', '#fff' );
178
- $( '#<?php echo $btn['cow']; ?>_colorpicker' ).css( 'background', '<?php echo $btn['colorpickerd']; ?>' );
179
-
180
- var options = {
181
- wccmclass: "billing_<?php echo $btn['cow']; ?>_colorpickerdiv",
182
- palettes: true,
183
- color: "",
184
- hide: false,
185
- change: function(event,ui){
186
- $( '#billing_<?php echo $btn['cow']; ?>_colorpicker' ).css( 'color', '#000' );
187
- $( '#billing_<?php echo $btn['cow']; ?>_colorpicker' ).css( 'background', ui.color.toString());
188
- }
189
- };
190
-
191
- jQuery('#billing_<?php echo $btn['cow']; ?>_colorpicker').iris( options );
192
- jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide();
193
- jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function(){jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()});
194
-
195
- });
196
- </script>
197
- <?php
198
- break;
199
-
200
- }
201
- }
 
 
 
202
 
203
  // ============================== radio button & checkbox ===========================================
204
 
205
- if( ( $btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm' ) && !empty( $btn['tax_remove'] ) ) {
206
- ?>
207
- <script type="text/javascript">
208
- jQuery(document).ready(function($) {
209
-
210
- <?php if( !empty($saved['wooccm_tax_save_method']) ) { ?>
211
- jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true);
212
- <?php } ?>
213
-
214
- jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function() {
215
-
216
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
217
-
218
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
219
- data = {
220
- action: 'remove_tax_wccm',
221
- tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val()
222
- };
223
-
224
- jQuery.post(ajaxurl, data, function(response) {
225
- $( 'body' ).trigger( 'update_checkout' );
226
- jQuery('form.checkout').unblock();
227
- });
228
-
229
- });
230
- });
231
- </script>
232
- <?php
233
- }
234
-
235
- if( ( $btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm' ) && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && !empty( $btn['add_amount_field'] ) ) {
236
- ?>
237
- <script type="text/javascript">
238
- jQuery(document).ready(function($) {
239
-
240
- <?php if( !empty($saved['wooccm_addamount453user']) ) { ?>
241
- jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true);
242
- <?php } ?>
243
- jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function() {
244
-
245
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
246
-
247
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
248
- data = {
249
- action: 'remove_tax_wccm',
250
- add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val()
251
- };
252
-
253
- jQuery.post(ajaxurl, data, function(response) {
254
- $( 'body' ).trigger( 'update_checkout' );
255
- jQuery('form.checkout').unblock();
256
- });
257
-
258
- });
259
- });
260
- </script>
261
- <?php
262
- }
263
 
264
  // =========================================== select options =========================================
265
 
266
- if( $btn['type'] == 'wooccmselect' && !empty( $btn['tax_remove'] ) ) {
267
- ?>
268
- <script type="text/javascript">
269
- jQuery(document).ready(function($) {
270
-
271
- <?php if( !empty($saved['wooccm_tax_save_method']) ) { ?>
272
- jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val( '<?php echo $saved['wooccm_tax_save_method']; ?>' );
273
- <?php } ?>
274
- jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function() {
275
-
276
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
277
-
278
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
279
- data = {
280
- action: 'remove_tax_wccm',
281
- tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()
282
- };
283
-
284
- jQuery.post(ajaxurl, data, function(response) {
285
- $( 'body' ).trigger( 'update_checkout' );
286
- jQuery('form.checkout').unblock();
287
- });
288
-
289
- });
290
- });
291
- </script>
292
- <?php
293
- }
294
-
295
- if( $btn['type'] == 'wooccmselect' && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && !empty( $btn['add_amount_field'] ) ) {
296
- ?>
297
- <script type="text/javascript">
298
- jQuery(document).ready(function($) {
299
-
300
- <?php if( !empty( $saved['wooccm_addamount453user'] ) ) { ?>
301
- jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val( '<?php echo $saved['wooccm_addamount453user']; ?>' );
302
- <?php } ?>
303
-
304
- jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function() {
305
-
306
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
307
-
308
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
309
- data = {
310
- action: 'remove_tax_wccm',
311
- add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()
312
- };
313
-
314
- jQuery.post(ajaxurl, data, function(response) {
315
- $( 'body' ).trigger( 'update_checkout' );
316
- jQuery('form.checkout').unblock();
317
- });
318
-
319
- });
320
- });
321
- </script>
322
- <?php
323
- }
324
 
325
  // =========================================== add apply button ==========================================
326
 
327
- if( $btn['type'] == 'text' && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && empty( $btn['add_amount_field'] ) ) {
328
- ?>
329
- <script type="text/javascript">
330
- jQuery(document).ready(function() {
331
- jQuery( "#billing_<?php echo $btn['cow']; ?>_field" ).append( '<span id="billing_<?php echo $btn['cow']; ?>_applynow"><?php _e('Apply','woocommerce-checkout-manager'); ?></span>' );
332
- });
333
 
334
- jQuery(document).ready(function($) {
335
 
336
- <?php if( !empty($saved['wooccm_addamount453userf']) ) { ?>
337
- jQuery('input#billing_<?php echo $btn['cow']; ?>').val( '<?php echo $saved['wooccm_addamount453userf']; ?>' );
338
- <?php } ?>
339
 
340
- jQuery('#billing_<?php echo $btn['cow']; ?>_field #billing_<?php echo $btn['cow']; ?>_applynow').click(function() {
341
 
342
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
343
 
344
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
345
- data = {
346
- action: 'remove_tax_wccm',
347
- add_amount_faj: jQuery('input#billing_<?php echo $btn['cow']; ?>').val()
348
- };
349
 
350
- jQuery.post(ajaxurl, data, function(response) {
351
- $( 'body' ).trigger( 'update_checkout' );
352
- jQuery('form.checkout').unblock();
353
- });
354
 
355
- });
356
 
357
- });
358
- </script>
359
- <?php
360
- }
361
 
362
  // =====================================================
363
-
364
- }
365
-
366
  }
367
 
368
  // --------------------------------------------------------
@@ -371,24 +373,24 @@ jQuery(document).ready(function($) {
371
 
372
  function wooccm_billing_override_this() {
373
 
374
- global $woocommerce;
375
 
376
- $options = get_option( 'wccs_settings3' );
377
 
378
- $options['billing_buttons'] = ( isset( $options['billing_buttons'] ) ? $options['billing_buttons'] : array() );
379
 
380
- // Check if there are any buttons
381
- if( count( $options['billing_buttons'] ) == 0 )
382
- return;
383
 
384
- $i = 0;
385
 
386
- // css sub-parent hide
387
- foreach( $options['billing_buttons'] as $btn ) {
388
- if( $btn['type'] == 'text' && !empty( $btn['add_amount'] ) && !empty( $btn['fee_name'] ) && empty( $btn['add_amount_field'] ) ) {
389
- echo '
390
  <style type="text/css">
391
- #billing_'.$btn['cow'].'_applynow {
392
  background: -webkit-gradient(linear,left top,left bottom,from(#ad74a2),to(#96588a));
393
  background: -webkit-linear-gradient(#ad74a2,#96588a);
394
  background: -moz-linear-gradient(center top,#ad74a2 0,#96588a 100%);
@@ -402,445 +404,430 @@ function wooccm_billing_override_this() {
402
  cursor: pointer;
403
  position: relative;
404
  }
405
- #billing_'.$btn['cow'].'_applynow:active {
406
  top: 1px;
407
  }
408
  </style>';
409
- }
410
- if( !empty( $btn['conditional_tie'] ) && empty( $btn['conditional_parent'] ) && !empty( $btn['conditional_parent_use'] ) ) {
411
- echo '
412
  <style type="text/css">
413
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field.'.$btn['conditional_tie'].',
414
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field.'.$btn['conditional_tie'].',
415
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field.'.$btn['conditional_tie'].' {
416
  display: none;
417
  }
418
  </style>';
419
- }
420
- }
421
 
422
  // ====================== CHECKBOX =============================
423
  // script when clicked show
424
  // =============================================================
425
- ?>
426
- <!-- Billing section: Checkbox -->
427
- <script type="text/javascript">
428
- jQuery(document).ready(function($){
429
- <?php
430
- foreach( $options['billing_buttons'] as $btn ) {
431
- if( $btn['type'] == 'checkbox_wccm' ) {
432
-
433
- if( !empty( $btn['conditional_parent'] ) && !empty( $btn['conditional_parent_use'] ) && !empty( $btn['chosen_valt'] ) ) {
434
- ?>
435
-
436
- jQuery("#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]").click(function(){
437
-
438
- <?php
439
- foreach( $options['billing_buttons'] as $btn3 ) {
440
- if( empty( $btn3['conditional_parent'] ) && !empty( $btn3['conditional_parent_use'] ) && !empty( $btn3['conditional_tie'] ) ) {
441
- ?>
442
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() === '<?php echo $btn3['chosen_valt']; ?>' ) {
443
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show( "slow" );
444
- }
445
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() !== '<?php echo $btn3['chosen_valt']; ?>' ) {
446
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide( "slow" );
447
-
448
- <?php if( !empty( $btn2['fee_name'] ) && !empty( $btn2['add_amount'] ) ) { ?>
449
-
450
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
451
-
452
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
453
- data = {
454
- action: 'remove_tax_wccm',
455
- empty_check_add: 'none'
456
- };
457
-
458
- jQuery.post(ajaxurl, data, function(response) {
459
- $( 'body' ).trigger( 'update_checkout' );
460
- jQuery('form.checkout').unblock();
461
- });
462
-
463
- <?php } ?>
464
-
465
- }
466
-
467
- <?php
468
- }
469
- }
470
- ?>
471
-
472
- });
473
-
474
- <?php
475
- }
476
- }
477
- }
478
- ?>
479
- });
480
- </script>
481
- <?php
482
-
483
  // ================================ END!!! =====================================
484
  // =============================================================================
485
-
486
  // ====================== SELECT OPTIONS =============================
487
  // script when clicked show
488
  // =============================================================
489
- ?>
490
- <!-- Billing section: Select options -->
491
- <script type="text/javascript">
492
- jQuery(document).ready(function($){
493
-
494
- <?php
495
- foreach( $options['billing_buttons'] as $btn ) {
496
- if( $btn['type'] == 'wooccmselect' ) {
497
-
498
- if( !empty( $btn['conditional_parent'] ) && !empty( $btn['conditional_parent_use'] ) && !empty( $btn['chosen_valt'] ) ) {
499
- ?>
500
-
501
- jQuery("#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> select").change(function(){
502
-
503
- <?php
504
- foreach( $options['billing_buttons'] as $btn3 ) {
505
- if( empty( $btn3['conditional_parent'] ) && !empty( $btn3['conditional_parent_use'] ) && !empty( $btn3['conditional_tie'] ) ) {
506
- ?>
507
-
508
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie'] . ' #billing_' . $btn['cow']; ?> option:selected').val() === '<?php echo $btn3['chosen_valt']; ?>' ) {
509
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show( "slow" );
510
- }
511
-
512
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie'] . ' #billing_' . $btn['cow']; ?> option:selected').val() !== '<?php echo $btn3['chosen_valt']; ?>' ) {
513
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide( "slow" );
514
-
515
- <?php if( !empty( $btn2['fee_name'] ) && !empty( $btn2['add_amount'] ) ) { ?>
516
-
517
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
518
-
519
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
520
- data = {
521
- action: 'remove_tax_wccm',
522
- empty_check_add: 'none'
523
- };
524
-
525
- jQuery.post(ajaxurl, data, function(response) {
526
- $( 'body' ).trigger( 'update_checkout' );
527
- jQuery('form.checkout').unblock();
528
- });
529
-
530
- <?php } ?>
531
- }
532
- <?php
533
- }
534
- }
535
- ?>
536
- });
537
- <?php
538
- }
539
- }
540
- }
541
- ?>
542
- });
543
- </script>
544
-
545
- <?php
546
-
547
  // ================================ END!!! =====================================
548
  // =============================================================================
549
-
550
  // ====================== RADIO BUTTON =============================
551
  // script when clicked show
552
  // =============================================================
 
 
 
 
553
 
554
- ?>
555
- <!-- Billing section: Radio buttons -->
556
- <script type="text/javascript">
557
- jQuery(document).ready(function($){
558
-
559
- <?php
560
- foreach( $options['billing_buttons'] as $btn ) {
561
- if( $btn['type'] == 'wooccmradio' ) {
562
-
563
- if( !empty( $btn['conditional_parent'] ) && !empty( $btn['conditional_parent_use'] ) && !empty( $btn['chosen_valt'] ) ) {
564
- ?>
565
 
566
- jQuery("#billing_<?php echo ''.$btn['cow'].'_field.'.$btn['conditional_tie']; ?> input").click(function(){
 
567
 
568
- <?php
569
- foreach( $options['billing_buttons'] as $btn3 ) {
570
- if( empty( $btn3['conditional_parent'] ) && !empty( $btn3['conditional_parent_use'] ) && !empty( $btn3['conditional_tie'] ) ) {
571
- ?>
572
 
573
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() === '<?php echo $btn3['chosen_valt']; ?>' ) {
574
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show( "slow" );
575
- }
 
576
 
577
- if(jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() !== '<?php echo $btn3['chosen_valt']; ?>' ) {
578
- jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide( "slow" );
 
579
 
580
- <?php if( !empty( $btn2['fee_name'] ) && !empty( $btn2['add_amount'] ) ) { ?>
 
581
 
582
- $( 'form.checkout' ).block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
583
 
584
- var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
585
- data = {
586
- action: 'remove_tax_wccm',
587
- empty_check_add: 'none'
588
- };
589
 
590
- jQuery.post(ajaxurl, data, function(response) {
591
- $( 'body' ).trigger( 'update_checkout' );
592
- jQuery('form.checkout').unblock();
593
- });
 
594
 
595
- <?php } ?>
 
 
 
596
 
597
- }
598
 
599
- <?php
600
- }
601
- }
602
- ?>
603
 
604
- });
605
- <?php
606
- }
607
- }
608
- }
609
- ?>
610
- });
611
- </script>
612
 
613
- <?php
 
 
 
 
 
 
 
614
 
 
615
  // ================================ END!!! =====================================
616
  // =============================================================================
617
-
618
  // ----------------------------- CLEAR ---------------------------------
619
  // ---------------------------------------------------------------------
620
  // ---------------------------------------------------------------------
621
 
622
- $categoryarraycm = array();
623
- $productsarraycm = array();
624
 
625
- foreach( $options['billing_buttons'] as $btn ) {
626
- foreach( $woocommerce->cart->cart_contents as $key => $values ) {
627
 
628
- $multiproductsx = ( isset( $btn['single_p'] ) ? $btn['single_p'] : '' );
629
- $show_field_single = ( isset( $btn['single_px'] ) ? $btn['single_px'] : '' );
630
- $multiproductsx_cat = ( isset( $btn['single_p_cat'] ) ? $btn['single_p_cat'] : '' );
631
- $show_field_single_cat = ( isset( $btn['single_px_cat'] ) ? $btn['single_px_cat'] : '' );
632
 
633
- $productsarraycm[] = $values['product_id'];
634
 
635
- // Products
636
- // hide field
 
 
637
 
638
- // without more
639
- if( !empty( $btn['single_p'] ) && empty( $btn['more_content'] ) ) {
640
 
641
- $multiarrayproductsx = explode( ',', $multiproductsx );
642
-
643
- if( in_array( $values['product_id'], $multiarrayproductsx ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
644
- echo '
645
  <style type="text/css">
646
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
647
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
648
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
649
  display: none;
650
  }
651
  </style>';
652
- }
653
- }
654
 
655
- // show field without more
656
- if( !empty( $btn['single_px'] ) && empty( $btn['more_content'] ) ) {
657
 
658
- $show_field_array = explode( '||', $show_field_single );
659
 
660
- if( in_array( $values['product_id'], $show_field_array ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
661
- echo '
662
  <style type="text/css">
663
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
664
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
665
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
666
  display: inline-block;
667
  }
668
  </style>';
669
- }
670
 
671
- if( !in_array( $values['product_id'], $show_field_array ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
672
- echo '
673
  <style type="text/css">
674
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
675
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
676
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
677
  display: none;
678
  }
679
  </style>';
680
- }
681
- }
682
 
683
- // Category
684
- // hide field
685
- $terms = get_the_terms( $values['product_id'], 'product_cat' );
686
- if( !empty($terms) ) {
687
- foreach( $terms as $term ) {
688
 
689
- $categoryarraycm[] = $term->slug;
690
 
691
- // without more
692
 
693
- if( !empty( $btn['single_p_cat'] ) && empty( $btn['more_content'] ) ) {
694
 
695
- $multiarrayproductsx_cat = explode( ',', $multiproductsx_cat );
696
 
697
- if( in_array( $term->slug, $multiarrayproductsx_cat ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
698
- echo '
699
  <style type="text/css">
700
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
701
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
702
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
703
  display: none;
704
  }
705
  </style>';
706
- }
707
- }
708
 
709
- // show field without more
710
- if( !empty( $btn['single_px_cat'] ) && empty( $btn['more_content'] ) ) {
711
 
712
- $show_field_array_cat = explode('||',$show_field_single_cat);
713
 
714
- if( in_array( $term->slug, $show_field_array_cat ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
715
- echo '
716
  <style type="text/css">
717
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
718
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
719
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
720
  display: inline-block;
721
  }
722
  </style>';
723
- }
724
 
725
- if( !in_array( $term->slug, $show_field_array_cat ) && ( count( $woocommerce->cart->cart_contents ) < 2 ) ) {
726
- echo '
727
  <style type="text/css">
728
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
729
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
730
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
731
  display: none;
732
  }
733
  </style>';
734
- }
735
- }
736
-
737
- }
738
- }
739
- }
740
- // end cart
741
-
742
  // ===========================================================================================
 
 
 
 
743
 
744
- // Products
745
- // hide field
746
-
747
- // with more
748
- if( !empty( $btn['single_p'] ) && !empty( $btn['more_content'] ) ) {
749
 
750
- $multiarrayproductsx = explode( ',', $multiproductsx );
751
-
752
- if( array_intersect( $productsarraycm, $multiarrayproductsx ) ) {
753
- echo '
754
  <style type="text/css">
755
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
756
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
757
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
758
  display: none;
759
  }
760
  </style>';
761
- }
762
- }
763
 
764
- // show field with more
765
- if( !empty( $btn['single_px'] ) && !empty( $btn['more_content'] ) ) {
766
 
767
- $show_field_array = explode( '||', $show_field_single );
768
 
769
- if( array_intersect( $productsarraycm, $show_field_array ) ) {
770
- echo '
771
  <style type="text/css">
772
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
773
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
774
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
775
  display: inline-block;
776
  }
777
  </style>';
778
- }
779
 
780
- if( !array_intersect( $productsarraycm, $show_field_array ) ) {
781
- echo '
782
  <style type="text/css">
783
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
784
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
785
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
786
  display: none;
787
  }
788
  </style>';
789
- }
790
- }
791
-
792
- // Category
793
- // hide field
794
 
795
- // with more
796
- if( !empty( $btn['single_p_cat'] ) && !empty( $btn['more_content'] ) ) {
 
 
797
 
798
- $multiarrayproductsx_cat = explode( ',', $multiproductsx_cat );
799
 
800
- if( array_intersect( $categoryarraycm, $multiarrayproductsx_cat ) ) {
801
- echo '
802
  <style type="text/css">
803
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
804
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
805
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
806
  display: none;
807
  }
808
  </style>';
809
- }
810
- }
811
 
812
- // show field with more
813
- if( !empty( $btn['single_px_cat'] ) && !empty( $btn['more_content'] ) ) {
814
 
815
- $show_field_array_cat = explode( '||', $show_field_single_cat );
816
 
817
- if( array_intersect( $categoryarraycm, $show_field_array_cat ) ) {
818
- echo '
819
  <style type="text/css">
820
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
821
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
822
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
823
  display: inline-block;
824
  }
825
  </style>';
826
- }
827
 
828
- if( !array_intersect( $categoryarraycm, $show_field_array_cat ) ) {
829
- echo '
830
  <style type="text/css">
831
- .woocommerce form #customer_details #billing_'.$btn['cow'].'_field,
832
- .woocommerce-page form #customer_details #billing_'.$btn['cow'].'_field,
833
- .woocommerce form.checkout #billing_'.$btn['cow'].'_field {
834
  display: none;
835
  }
836
  </style>';
837
- }
838
- }
839
-
840
- $categoryarraycm = array();
841
- $productsarraycm = array();
842
-
843
- } // btn cut
844
 
 
 
 
845
  }
846
  ?>
2
  /**
3
  * WooCommerce Checkout Manager
4
  */
 
5
  // Exit if accessed directly
6
+ if (!defined('ABSPATH'))
7
+ exit;
8
 
9
  function wooccm_billing_hide_required() {
10
 
11
+ global $woocommerce;
12
 
13
+ $options = get_option('wccs_settings3');
14
 
15
+ $billing = array(
16
+ 'address_1',
17
+ 'address_2',
18
+ 'city',
19
+ 'state',
20
+ 'postcode'
21
+ );
22
 
23
+ if (!empty($options['billing_buttons'])) {
24
+ echo '
25
  <style>
26
  ';
27
+ foreach ($options['billing_buttons'] as $btn) {
28
+ if (in_array($btn['cow'], $billing) && empty($btn['checkbox'])) {
29
+ echo '
30
+ p#billing_' . $btn['cow'] . '_field .required{
31
  display:none;
32
  }';
33
+ }
34
+ }
35
+ echo '
36
  </style>';
37
+ }
 
38
  }
39
 
40
  function wooccm_billing_scripts() {
41
 
42
+ global $woocommerce;
43
 
44
+ $options = get_option('wccs_settings3');
45
 
46
+ $saved = WC()->session->get('wooccm_retain', array());
47
 
48
+ // Check if we have any buttons
49
+ if (empty($options['billing_buttons']))
50
+ return;
51
 
52
+ foreach ($options['billing_buttons'] as $btn) {
53
 
54
+ if ($btn['type'] == 'datepicker') {
55
+ echo '
56
  <script type="text/javascript">
57
  jQuery(document).ready(function() {
58
  var today = new Date();
59
  if( jQuery.isFunction(jQuery.fn.datepicker) ) {
60
+ jQuery("input#billing_' . $btn['cow'] . '").datepicker({
61
  ';
62
+ // Default date format
63
+ if (empty($btn['format_date']))
64
+ $btn['format_date'] = apply_filters('wooccm_datepicker_default_date_format', 'dd-mm-yy');
65
+ if (!empty($btn['format_date'])) {
66
+ echo 'dateFormat : "' . str_replace(' ', '', $btn['format_date']) . '",';
67
+ }
68
+ if (!empty($btn['single_yy'])) {
69
+ echo 'minDate: new Date( ' . $btn['single_yy'] . ', ' . $btn['single_mm'] . ' - 1, ' . $btn['single_dd'] . '),';
70
+ }
71
+ if (!empty($btn['min_before'])) {
72
+ echo 'minDate: ' . $btn['min_before'] . ',';
73
+ }
74
+ if (!empty($btn['single_max_yy'])) {
75
+ echo 'maxDate: new Date( ' . $btn['single_max_yy'] . ', ' . $btn['single_max_mm'] . ' - 1, ' . $btn['single_max_dd'] . '),';
76
+ }
77
+ if (!empty($btn['max_after'])) {
78
+ echo 'maxDate: ' . $btn['max_after'] . ',';
79
+ }
80
+ if (!empty($btn['days_disabler'])) {
81
+ echo 'beforeShowDay: function(date) { var day = date.getDay(); return [(';
82
+ if (!empty($btn['days_disabler0'])) {
83
+ echo 'day == 0';
84
+ } else {
85
+ echo 'day == "x"';
86
+ }
87
+ if (!empty($btn['days_disabler1'])) {
88
+ echo ' || day == 1';
89
+ }
90
+ if (!empty($btn['days_disabler2'])) {
91
+ echo ' || day == 2';
92
+ }
93
+ if (!empty($btn['days_disabler3'])) {
94
+ echo ' || day == 3';
95
+ }
96
+ if (!empty($btn['days_disabler4'])) {
97
+ echo ' || day == 4';
98
+ }
99
+ if (!empty($btn['days_disabler5'])) {
100
+ echo ' || day == 5';
101
+ }
102
+ if (!empty($btn['days_disabler6'])) {
103
+ echo '|| day == 6';
104
+ }
105
+ echo ')]; }';
106
+ }
107
+ do_action('wooccm_js_datepicker_billing_args', $btn);
108
+ echo '
109
  });
110
  }
111
  });
112
  </script>
113
  ';
114
+ }
115
 
116
+ if ($btn['type'] == 'time') {
117
+ $args = '
118
  showPeriod: true,';
119
+ if (!empty($btn['start_hour'])) {
120
+ $args .= '
121
+ hours: { starts: ' . $btn['start_hour'] . ', ends: ' . $btn['end_hour'] . ' },';
122
+ }
123
+ if (!empty($btn['interval_min'])) {
124
+ $args .= '
125
+ minutes: {interval: ' . $btn['interval_min'] . ', manual: [' . $btn['manual_min'] . '] },';
126
+ }
127
+ $args .= '
128
  showLeadingZero: true';
129
+ $args = apply_filters('wooccm_timepicker_jquery_args', $args, $btn);
130
+ echo '
131
  <!-- Billing section: TimePicker -->
132
  <script type="text/javascript">
133
  jQuery(document).ready(function() {
134
  if( jQuery.isFunction(jQuery.fn.timepicker) ) {
135
+ jQuery("#billing_' . $btn['cow'] . '_field input#billing_' . $btn['cow'] . '").timepicker({
136
  ';
137
+ echo $args;
138
+ echo '
139
  });
140
  }
141
  });
142
  </script>
143
  ';
144
+ }
145
 
146
+ if ($btn['type'] == 'password') {
147
+ echo '
148
  <script type="text/javascript">
149
  jQuery(document).ready(function() {
150
+ jQuery("p#billing_' . $btn['cow'] . '_field").css("display");
151
  });
152
  </script>
153
  ';
154
+ }
155
+
156
+ if ($btn['type'] == 'colorpicker') {
157
+ switch ($btn['colorpickertype']) {
158
+
159
+ case 'farbtastic':
160
+ ?>
161
+ <script type="text/javascript">
162
+ jQuery(document).ready(function ($) {
163
+ jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide();
164
+ if (jQuery.isFunction(jQuery.fn.farbtastic)) {
165
+ jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').farbtastic("#billing_<?php echo $btn['cow']; ?>_colorpicker");
166
+ jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function () {
167
+ jQuery('#billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()
168
+ });
169
+ }
170
+ });
171
+ </script>
172
+ <?php
173
+ break;
174
+
175
+ case 'iris':
176
+ ?>
177
+ <script type="text/javascript">
178
+ jQuery(document).ready(function ($) {
179
+
180
+ $('#<?php echo $btn['cow']; ?>_colorpicker').css('color', '#fff');
181
+ $('#<?php echo $btn['cow']; ?>_colorpicker').css('background', '<?php echo $btn['colorpickerd']; ?>');
182
+
183
+ var options = {
184
+ wccmclass: "billing_<?php echo $btn['cow']; ?>_colorpickerdiv",
185
+ palettes: true,
186
+ color: "",
187
+ hide: false,
188
+ change: function (event, ui) {
189
+ $('#billing_<?php echo $btn['cow']; ?>_colorpicker').css('color', '#000');
190
+ $('#billing_<?php echo $btn['cow']; ?>_colorpicker').css('background', ui.color.toString());
191
+ }
192
+ };
193
+
194
+ jQuery('#billing_<?php echo $btn['cow']; ?>_colorpicker').iris(options);
195
+ jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').hide();
196
+ jQuery("#billing_<?php echo $btn['cow']; ?>_colorpicker").click(function () {
197
+ jQuery('.billing_<?php echo $btn['cow']; ?>_colorpickerdiv').slideToggle()
198
+ });
199
+
200
+ });
201
+ </script>
202
+ <?php
203
+ break;
204
+ }
205
+ }
206
 
207
  // ============================== radio button & checkbox ===========================================
208
 
209
+ if (( $btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm' ) && !empty($btn['tax_remove'])) {
210
+ ?>
211
+ <script type="text/javascript">
212
+ jQuery(document).ready(function ($) {
213
+
214
+ <?php if (!empty($saved['wooccm_tax_save_method'])) { ?>
215
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true);
216
+ <?php } ?>
217
+
218
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function () {
219
+
220
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
221
+
222
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
223
+ data = {
224
+ action: 'remove_tax_wccm',
225
+ tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val()
226
+ };
227
+
228
+ jQuery.post(ajaxurl, data, function (response) {
229
+ $('body').trigger('update_checkout');
230
+ jQuery('form.checkout').unblock();
231
+ });
232
+
233
+ });
234
+ });
235
+ </script>
236
+ <?php
237
+ }
238
+
239
+ if (( $btn['type'] == 'wooccmradio' || $btn['type'] == 'checkbox_wccm' ) && !empty($btn['add_amount']) && !empty($btn['fee_name']) && !empty($btn['add_amount_field'])) {
240
+ ?>
241
+ <script type="text/javascript">
242
+ jQuery(document).ready(function ($) {
243
+
244
+ <?php if (!empty($saved['wooccm_addamount453user'])) { ?>
245
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]').prop("checked", true);
246
+ <?php } ?>
247
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field input').click(function () {
248
+
249
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
250
+
251
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
252
+ data = {
253
+ action: 'remove_tax_wccm',
254
+ add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?>_field input[name=billing_<?php echo $btn['cow']; ?>]:checked').val()
255
+ };
256
+
257
+ jQuery.post(ajaxurl, data, function (response) {
258
+ $('body').trigger('update_checkout');
259
+ jQuery('form.checkout').unblock();
260
+ });
261
+
262
+ });
263
+ });
264
+ </script>
265
+ <?php
266
+ }
267
 
268
  // =========================================== select options =========================================
269
 
270
+ if ($btn['type'] == 'wooccmselect' && !empty($btn['tax_remove'])) {
271
+ ?>
272
+ <script type="text/javascript">
273
+ jQuery(document).ready(function ($) {
274
+
275
+ <?php if (!empty($saved['wooccm_tax_save_method'])) { ?>
276
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val('<?php echo $saved['wooccm_tax_save_method']; ?>');
277
+ <?php } ?>
278
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function () {
279
+
280
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
281
+
282
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
283
+ data = {
284
+ action: 'remove_tax_wccm',
285
+ tax_remove_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()
286
+ };
287
+
288
+ jQuery.post(ajaxurl, data, function (response) {
289
+ $('body').trigger('update_checkout');
290
+ jQuery('form.checkout').unblock();
291
+ });
292
+
293
+ });
294
+ });
295
+ </script>
296
+ <?php
297
+ }
298
+
299
+ if ($btn['type'] == 'wooccmselect' && !empty($btn['add_amount']) && !empty($btn['fee_name']) && !empty($btn['add_amount_field'])) {
300
+ ?>
301
+ <script type="text/javascript">
302
+ jQuery(document).ready(function ($) {
303
+
304
+ <?php if (!empty($saved['wooccm_addamount453user'])) { ?>
305
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field select').val('<?php echo $saved['wooccm_addamount453user']; ?>');
306
+ <?php } ?>
307
+
308
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field select').change(function () {
309
+
310
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
311
+
312
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
313
+ data = {
314
+ action: 'remove_tax_wccm',
315
+ add_amount_aj: jQuery('#billing_<?php echo $btn['cow']; ?> option:selected').val()
316
+ };
317
+
318
+ jQuery.post(ajaxurl, data, function (response) {
319
+ $('body').trigger('update_checkout');
320
+ jQuery('form.checkout').unblock();
321
+ });
322
+
323
+ });
324
+ });
325
+ </script>
326
+ <?php
327
+ }
328
 
329
  // =========================================== add apply button ==========================================
330
 
331
+ if ($btn['type'] == 'text' && !empty($btn['add_amount']) && !empty($btn['fee_name']) && empty($btn['add_amount_field'])) {
332
+ ?>
333
+ <script type="text/javascript">
334
+ jQuery(document).ready(function () {
335
+ jQuery("#billing_<?php echo $btn['cow']; ?>_field").append('<span id="billing_<?php echo $btn['cow']; ?>_applynow"><?php _e('Apply', 'woocommerce-checkout-manager'); ?></span>');
336
+ });
337
 
338
+ jQuery(document).ready(function ($) {
339
 
340
+ <?php if (!empty($saved['wooccm_addamount453userf'])) { ?>
341
+ jQuery('input#billing_<?php echo $btn['cow']; ?>').val('<?php echo $saved['wooccm_addamount453userf']; ?>');
342
+ <?php } ?>
343
 
344
+ jQuery('#billing_<?php echo $btn['cow']; ?>_field #billing_<?php echo $btn['cow']; ?>_applynow').click(function () {
345
 
346
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
347
 
348
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
349
+ data = {
350
+ action: 'remove_tax_wccm',
351
+ add_amount_faj: jQuery('input#billing_<?php echo $btn['cow']; ?>').val()
352
+ };
353
 
354
+ jQuery.post(ajaxurl, data, function (response) {
355
+ $('body').trigger('update_checkout');
356
+ jQuery('form.checkout').unblock();
357
+ });
358
 
359
+ });
360
 
361
+ });
362
+ </script>
363
+ <?php
364
+ }
365
 
366
  // =====================================================
367
+ }
 
 
368
  }
369
 
370
  // --------------------------------------------------------
373
 
374
  function wooccm_billing_override_this() {
375
 
376
+ global $woocommerce;
377
 
378
+ $options = get_option('wccs_settings3');
379
 
380
+ $options['billing_buttons'] = ( isset($options['billing_buttons']) ? $options['billing_buttons'] : array() );
381
 
382
+ // Check if there are any buttons
383
+ if (count($options['billing_buttons']) == 0)
384
+ return;
385
 
386
+ $i = 0;
387
 
388
+ // css sub-parent hide
389
+ foreach ($options['billing_buttons'] as $btn) {
390
+ if ($btn['type'] == 'text' && !empty($btn['add_amount']) && !empty($btn['fee_name']) && empty($btn['add_amount_field'])) {
391
+ echo '
392
  <style type="text/css">
393
+ #billing_' . $btn['cow'] . '_applynow {
394
  background: -webkit-gradient(linear,left top,left bottom,from(#ad74a2),to(#96588a));
395
  background: -webkit-linear-gradient(#ad74a2,#96588a);
396
  background: -moz-linear-gradient(center top,#ad74a2 0,#96588a 100%);
404
  cursor: pointer;
405
  position: relative;
406
  }
407
+ #billing_' . $btn['cow'] . '_applynow:active {
408
  top: 1px;
409
  }
410
  </style>';
411
+ }
412
+ if (!empty($btn['conditional_tie']) && empty($btn['conditional_parent']) && !empty($btn['conditional_parent_use'])) {
413
+ echo '
414
  <style type="text/css">
415
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field.' . $btn['conditional_tie'] . ',
416
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field.' . $btn['conditional_tie'] . ',
417
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field.' . $btn['conditional_tie'] . ' {
418
  display: none;
419
  }
420
  </style>';
421
+ }
422
+ }
423
 
424
  // ====================== CHECKBOX =============================
425
  // script when clicked show
426
  // =============================================================
427
+ ?>
428
+ <!-- Billing section: Checkbox -->
429
+ <script type="text/javascript">
430
+ jQuery(document).ready(function ($) {
431
+ <?php
432
+ foreach ($options['billing_buttons'] as $btn) {
433
+ if ($btn['type'] == 'checkbox_wccm') {
434
+
435
+ if (!empty($btn['conditional_parent']) && !empty($btn['conditional_parent_use']) && !empty($btn['chosen_valt'])) {
436
+ ?>
437
+
438
+ jQuery("#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]").click(function () {
439
+
440
+ <?php
441
+ foreach ($options['billing_buttons'] as $btn3) {
442
+ if (empty($btn3['conditional_parent']) && !empty($btn3['conditional_parent_use']) && !empty($btn3['conditional_tie'])) {
443
+ ?>
444
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() === '<?php echo $btn3['chosen_valt']; ?>') {
445
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show("slow");
446
+ }
447
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() !== '<?php echo $btn3['chosen_valt']; ?>') {
448
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide("slow");
449
+
450
+ <?php if (!empty($btn2['fee_name']) && !empty($btn2['add_amount'])) { ?>
451
+
452
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
453
+
454
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
455
+ data = {
456
+ action: 'remove_tax_wccm',
457
+ empty_check_add: 'none'
458
+ };
459
+
460
+ jQuery.post(ajaxurl, data, function (response) {
461
+ $('body').trigger('update_checkout');
462
+ jQuery('form.checkout').unblock();
463
+ });
464
+
465
+ <?php } ?>
466
+
467
+ }
468
+
469
+ <?php
470
+ }
471
+ }
472
+ ?>
473
+
474
+ });
475
+
476
+ <?php
477
+ }
478
+ }
479
+ }
480
+ ?>
481
+ });
482
+ </script>
483
+ <?php
 
484
  // ================================ END!!! =====================================
485
  // =============================================================================
 
486
  // ====================== SELECT OPTIONS =============================
487
  // script when clicked show
488
  // =============================================================
489
+ ?>
490
+ <!-- Billing section: Select options -->
491
+ <script type="text/javascript">
492
+ jQuery(document).ready(function ($) {
493
+
494
+ <?php
495
+ foreach ($options['billing_buttons'] as $btn) {
496
+ if ($btn['type'] == 'wooccmselect') {
497
+
498
+ if (!empty($btn['conditional_parent']) && !empty($btn['conditional_parent_use']) && !empty($btn['chosen_valt'])) {
499
+ ?>
500
+
501
+ jQuery("#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> select").change(function () {
502
+
503
+ <?php
504
+ foreach ($options['billing_buttons'] as $btn3) {
505
+ if (empty($btn3['conditional_parent']) && !empty($btn3['conditional_parent_use']) && !empty($btn3['conditional_tie'])) {
506
+ ?>
507
+
508
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie'] . ' #billing_' . $btn['cow']; ?> option:selected').val() === '<?php echo $btn3['chosen_valt']; ?>') {
509
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show("slow");
510
+ }
511
+
512
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie'] . ' #billing_' . $btn['cow']; ?> option:selected').val() !== '<?php echo $btn3['chosen_valt']; ?>') {
513
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide("slow");
514
+
515
+ <?php if (!empty($btn2['fee_name']) && !empty($btn2['add_amount'])) { ?>
516
+
517
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
518
+
519
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
520
+ data = {
521
+ action: 'remove_tax_wccm',
522
+ empty_check_add: 'none'
523
+ };
524
+
525
+ jQuery.post(ajaxurl, data, function (response) {
526
+ $('body').trigger('update_checkout');
527
+ jQuery('form.checkout').unblock();
528
+ });
529
+
530
+ <?php } ?>
531
+ }
532
+ <?php
533
+ }
534
+ }
535
+ ?>
536
+ });
537
+ <?php
538
+ }
539
+ }
540
+ }
541
+ ?>
542
+ });
543
+ </script>
544
+
545
+ <?php
 
546
  // ================================ END!!! =====================================
547
  // =============================================================================
 
548
  // ====================== RADIO BUTTON =============================
549
  // script when clicked show
550
  // =============================================================
551
+ ?>
552
+ <!-- Billing section: Radio buttons -->
553
+ <script type="text/javascript">
554
+ jQuery(document).ready(function ($) {
555
 
556
+ <?php
557
+ foreach ($options['billing_buttons'] as $btn) {
558
+ if ($btn['type'] == 'wooccmradio') {
 
 
 
 
 
 
 
 
559
 
560
+ if (!empty($btn['conditional_parent']) && !empty($btn['conditional_parent_use']) && !empty($btn['chosen_valt'])) {
561
+ ?>
562
 
563
+ jQuery("#billing_<?php echo '' . $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input").click(function () {
 
 
 
564
 
565
+ <?php
566
+ foreach ($options['billing_buttons'] as $btn3) {
567
+ if (empty($btn3['conditional_parent']) && !empty($btn3['conditional_parent_use']) && !empty($btn3['conditional_tie'])) {
568
+ ?>
569
 
570
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() === '<?php echo $btn3['chosen_valt']; ?>') {
571
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").show("slow");
572
+ }
573
 
574
+ if (jQuery('#billing_<?php echo $btn['cow'] . '_field.' . $btn['conditional_tie']; ?> input[name=billing_<?php echo $btn['cow']; ?>]:checked').val() !== '<?php echo $btn3['chosen_valt']; ?>') {
575
+ jQuery("#billing_<?php echo $btn3['cow'] . '_field.' . $btn['conditional_tie']; ?>").hide("slow");
576
 
577
+ <?php if (!empty($btn2['fee_name']) && !empty($btn2['add_amount'])) { ?>
578
 
579
+ $('form.checkout').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_get_script_data.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
 
 
 
 
580
 
581
+ var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
582
+ data = {
583
+ action: 'remove_tax_wccm',
584
+ empty_check_add: 'none'
585
+ };
586
 
587
+ jQuery.post(ajaxurl, data, function (response) {
588
+ $('body').trigger('update_checkout');
589
+ jQuery('form.checkout').unblock();
590
+ });
591
 
592
+ <?php } ?>
593
 
594
+ }
 
 
 
595
 
596
+ <?php
597
+ }
598
+ }
599
+ ?>
 
 
 
 
600
 
601
+ });
602
+ <?php
603
+ }
604
+ }
605
+ }
606
+ ?>
607
+ });
608
+ </script>
609
 
610
+ <?php
611
  // ================================ END!!! =====================================
612
  // =============================================================================
 
613
  // ----------------------------- CLEAR ---------------------------------
614
  // ---------------------------------------------------------------------
615
  // ---------------------------------------------------------------------
616
 
617
+ $categoryarraycm = array();
618
+ $productsarraycm = array();
619
 
620
+ foreach ($options['billing_buttons'] as $btn) {
621
+ foreach ($woocommerce->cart->cart_contents as $key => $values) {
622
 
623
+ $multiproductsx = ( isset($btn['single_p']) ? $btn['single_p'] : '' );
624
+ $show_field_single = ( isset($btn['single_px']) ? $btn['single_px'] : '' );
625
+ $multiproductsx_cat = ( isset($btn['single_p_cat']) ? $btn['single_p_cat'] : '' );
626
+ $show_field_single_cat = ( isset($btn['single_px_cat']) ? $btn['single_px_cat'] : '' );
627
 
628
+ $productsarraycm[] = $values['product_id'];
629
 
630
+ // Products
631
+ // hide field
632
+ // without more
633
+ if (!empty($btn['single_p']) && empty($btn['more_content'])) {
634
 
635
+ $multiarrayproductsx = explode(',', $multiproductsx);
 
636
 
637
+ if (in_array($values['product_id'], $multiarrayproductsx) && ( count($woocommerce->cart->cart_contents) < 2 )) {
638
+ echo '
 
 
639
  <style type="text/css">
640
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
641
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
642
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
643
  display: none;
644
  }
645
  </style>';
646
+ }
647
+ }
648
 
649
+ // show field without more
650
+ if (!empty($btn['single_px']) && empty($btn['more_content'])) {
651
 
652
+ $show_field_array = explode('||', $show_field_single);
653
 
654
+ if (in_array($values['product_id'], $show_field_array) && ( count($woocommerce->cart->cart_contents) < 2 )) {
655
+ echo '
656
  <style type="text/css">
657
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
658
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
659
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
660
  display: inline-block;
661
  }
662
  </style>';
663
+ }
664
 
665
+ if (!in_array($values['product_id'], $show_field_array) && ( count($woocommerce->cart->cart_contents) < 2 )) {
666
+ echo '
667
  <style type="text/css">
668
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
669
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
670
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
671
  display: none;
672
  }
673
  </style>';
674
+ }
675
+ }
676
 
677
+ // Category
678
+ // hide field
679
+ /*$terms = get_the_terms($values['product_id'], 'product_cat');
680
+ if (!empty($terms)) {
681
+ foreach ($terms as $term) {
682
 
683
+ $categoryarraycm[] = $term->slug;
684
 
685
+ // without more
686
 
687
+ if (!empty($btn['single_p_cat']) && empty($btn['more_content'])) {
688
 
689
+ $multiarrayproductsx_cat = explode(',', $multiproductsx_cat);
690
 
691
+ if (in_array($term->slug, $multiarrayproductsx_cat) && ( count($woocommerce->cart->cart_contents) < 2 )) {
692
+ echo '
693
  <style type="text/css">
694
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
695
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
696
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
697
  display: none;
698
  }
699
  </style>';
700
+ }
701
+ }
702
 
703
+ // show field without more
704
+ /*if (!empty($btn['single_px_cat']) && empty($btn['more_content'])) {
705
 
706
+ $show_field_array_cat = explode('||', $show_field_single_cat);
707
 
708
+ if (in_array($term->slug, $show_field_array_cat) && ( count($woocommerce->cart->cart_contents) < 2 )) {
709
+ echo '
710
  <style type="text/css">
711
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
712
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
713
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
714
  display: inline-block;
715
  }
716
  </style>';
717
+ }
718
 
719
+ if (!in_array($term->slug, $show_field_array_cat) && ( count($woocommerce->cart->cart_contents) < 2 )) {
720
+ echo '
721
  <style type="text/css">
722
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
723
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
724
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
725
  display: none;
726
  }
727
  </style>';
728
+ }
729
+ }
730
+ }
731
+ }*/
732
+ }
733
+ // end cart
 
 
734
  // ===========================================================================================
735
+ // Products
736
+ // hide field
737
+ // with more
738
+ if (!empty($btn['single_p']) && !empty($btn['more_content'])) {
739
 
740
+ $multiarrayproductsx = explode(',', $multiproductsx);
 
 
 
 
741
 
742
+ if (array_intersect($productsarraycm, $multiarrayproductsx)) {
743
+ echo '
 
 
744
  <style type="text/css">
745
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
746
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
747
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
748
  display: none;
749
  }
750
  </style>';
751
+ }
752
+ }
753
 
754
+ // show field with more
755
+ if (!empty($btn['single_px']) && !empty($btn['more_content'])) {
756
 
757
+ $show_field_array = explode('||', $show_field_single);
758
 
759
+ if (array_intersect($productsarraycm, $show_field_array)) {
760
+ echo '
761
  <style type="text/css">
762
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
763
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
764
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
765
  display: inline-block;
766
  }
767
  </style>';
768
+ }
769
 
770
+ if (!array_intersect($productsarraycm, $show_field_array)) {
771
+ echo '
772
  <style type="text/css">
773
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
774
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
775
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
776
  display: none;
777
  }
778
  </style>';
779
+ }
780
+ }
 
 
 
781
 
782
+ // Category
783
+ // hide field
784
+ // with more
785
+ /*if (!empty($btn['single_p_cat']) && !empty($btn['more_content'])) {
786
 
787
+ $multiarrayproductsx_cat = explode(',', $multiproductsx_cat);
788
 
789
+ if (array_intersect($categoryarraycm, $multiarrayproductsx_cat)) {
790
+ echo '
791
  <style type="text/css">
792
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
793
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
794
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
795
  display: none;
796
  }
797
  </style>';
798
+ }
799
+ }
800
 
801
+ // show field with more
802
+ if (!empty($btn['single_px_cat']) && !empty($btn['more_content'])) {
803
 
804
+ $show_field_array_cat = explode('||', $show_field_single_cat);
805
 
806
+ if (array_intersect($categoryarraycm, $show_field_array_cat)) {
807
+ echo '
808
  <style type="text/css">
809
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
810
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
811
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
812
  display: inline-block;
813
  }
814
  </style>';
815
+ }
816
 
817
+ if (!array_intersect($categoryarraycm, $show_field_array_cat)) {
818
+ echo '
819
  <style type="text/css">
820
+ .woocommerce form #customer_details #billing_' . $btn['cow'] . '_field,
821
+ .woocommerce-page form #customer_details #billing_' . $btn['cow'] . '_field,
822
+ .woocommerce form.checkout #billing_' . $btn['cow'] . '_field {
823
  display: none;
824
  }
825
  </style>';
826
+ }
827
+ }*/
 
 
 
 
 
828
 
829
+ $categoryarraycm = array();
830
+ $productsarraycm = array();
831
+ } // btn cut
832
  }
833
  ?>
new/fields_handler.php CHANGED
@@ -7,31 +7,86 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
7
  protected static $instance;
8
  protected static $i = 0;
9
 
10
- /* function field_user_roles($field, $key, $args, $value) {
11
 
12
- global $current_user;
13
 
14
- $user_roles = $current_user->roles;
15
 
16
- $user_role = array_shift($user_roles);
17
 
18
- if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
 
19
 
20
- $rolekeys = explode('||', $args['role_options']);
21
 
22
- $rolekeys2 = explode('||', $args['role_options2']);
23
 
24
- if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
25
- return;
26
- }
27
 
28
- if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
29
- return;
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  return $field;
34
- } */
35
 
36
  function remove_checkout_fields($fields) {
37
 
@@ -45,6 +100,7 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
45
 
46
  foreach ($type as $id => $field) {
47
 
 
48
  // Remove disabled
49
  // -------------------------------------------------------------------
50
  if (!empty($field['disabled'])) {
@@ -112,6 +168,9 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
112
 
113
  function init() {
114
 
 
 
 
115
  // Remove fields
116
  // -----------------------------------------------------------------------
117
  add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
7
  protected static $instance;
8
  protected static $i = 0;
9
 
10
+ function remove_by_category($field, $key) {
11
 
12
+ if (empty($field['disabled'])) {
13
 
14
+ if (count($cart_contents = WC()->cart->get_cart_contents())) {
15
 
16
+ $categoryarraycm = array();
17
 
18
+ $multiproductsx_cat = ( isset($field['single_p_cat']) ? $field['single_p_cat'] : '' );
19
+ $show_field_single_cat = ( isset($field['single_px_cat']) ? $field['single_px_cat'] : '' );
20
 
21
+ $show_field_array_cat = explode('||', $show_field_single_cat);
22
 
23
+ $multiarrayproductsx_cat = explode(',', $multiproductsx_cat);
24
 
25
+ foreach ($cart_contents as $key => $values) {
 
 
26
 
27
+ // hide field
28
+ // -----------------------------------------------------------------
29
+ if (!empty($terms = get_the_terms($values['product_id'], 'product_cat'))) {
30
+
31
+ foreach ($terms as $term) {
32
+
33
+ $categoryarraycm[] = $term->slug;
34
+
35
+ // hide field without more
36
+ // -------------------------------------------------------------
37
+ if (!empty($field['single_p_cat']) && empty($field['more_content'])) {
38
+
39
+ if (in_array($term->slug, $multiarrayproductsx_cat) && ( count($cart_contents) < 2 )) {
40
+ $field['disabled'] = true;
41
+ }
42
+ }
43
+
44
+ // show field without more
45
+ // -------------------------------------------------------------
46
+ if (!empty($field['single_px_cat']) && empty($field['more_content'])) {
47
+
48
+ if (in_array($term->slug, $show_field_array_cat) && ( count($cart_contents) < 2 )) {
49
+ $field['disabled'] = false;
50
+ }
51
+
52
+ if (!in_array($term->slug, $show_field_array_cat) && ( count($cart_contents) < 2 )) {
53
+ $field['disabled'] = true;
54
+ }
55
+ }
56
+ }
57
+
58
+ // hide field with more
59
+ // ---------------------------------------------------------------
60
+ if (!empty($btn['single_p_cat']) && !empty($btn['more_content'])) {
61
+
62
+ //$multiarrayproductsx_cat = explode(',', $multiproductsx_cat);
63
+
64
+ if (array_intersect($categoryarraycm, $multiarrayproductsx_cat)) {
65
+ $field['disabled'] = true;
66
+ }
67
+ }
68
+
69
+ // show field with more
70
+ // ---------------------------------------------------------------
71
+ if (!empty($btn['single_px_cat']) && !empty($btn['more_content'])) {
72
+
73
+ //$show_field_array_cat = explode('||', $show_field_single_cat);
74
+
75
+ if (array_intersect($categoryarraycm, $show_field_array_cat)) {
76
+ $field['disabled'] = false;
77
+ }
78
+
79
+ if (!array_intersect($categoryarraycm, $show_field_array_cat)) {
80
+ $field['disabled'] = true;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
  }
87
 
88
  return $field;
89
+ }
90
 
91
  function remove_checkout_fields($fields) {
92
 
100
 
101
  foreach ($type as $id => $field) {
102
 
103
+ //var_dump($field);
104
  // Remove disabled
105
  // -------------------------------------------------------------------
106
  if (!empty($field['disabled'])) {
168
 
169
  function init() {
170
 
171
+ // Remove by category
172
+ add_filter('wooccm_checkout_field_filter', array($this, 'remove_by_category'), 10, 2);
173
+
174
  // Remove fields
175
  // -----------------------------------------------------------------------
176
  add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
new/fields_register.php CHANGED
@@ -32,6 +32,8 @@ if (!class_exists('WOOCCM_Fields_Register')) {
32
  'country'
33
  );
34
 
 
 
35
  $fields[$key] = wp_parse_args($custom_field, (array) @$fields[$key]);
36
 
37
  // Priority
@@ -161,7 +163,7 @@ if (!class_exists('WOOCCM_Fields_Register')) {
161
 
162
  //error_log(json_encode($fields[$key]));
163
 
164
- return $fields[$key];
165
  }
166
 
167
  function add_checkout_fields_filter($fields, $name, $key, $prefix = '') {
32
  'country'
33
  );
34
 
35
+ //var_dump($fields[$key]);
36
+
37
  $fields[$key] = wp_parse_args($custom_field, (array) @$fields[$key]);
38
 
39
  // Priority
163
 
164
  //error_log(json_encode($fields[$key]));
165
 
166
+ return apply_filters('wooccm_checkout_field_filter', $fields[$key], $key);
167
  }
168
 
169
  function add_checkout_fields_filter($fields, $name, $key, $prefix = '') {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/
4
  Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
5
  Requires at least: 3.0
6
  Tested up to: 5.2.3
7
- Stable tag: 4.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -137,6 +137,9 @@ Example:
137
 
138
  == Changelog ==
139
 
 
 
 
140
  = 4.4.1 =
141
  * Fix: Undefined variable: custom_fields
142
  * Fix: woocommerce checkout country required when is removed
4
  Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
5
  Requires at least: 3.0
6
  Tested up to: 5.2.3
7
+ Stable tag: 4.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
137
 
138
  == Changelog ==
139
 
140
+ = 4.4.2 =
141
+ * Fix: woocommerce checkout remove field based on categories
142
+
143
  = 4.4.1 =
144
  * Fix: Undefined variable: custom_fields
145
  * Fix: woocommerce checkout country required when is removed
woocommerce-checkout-manager.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: WooCommerce Checkout Manager
4
  * Description: Manages WooCommerce Checkout, the advanced way.
5
- * Version: 4.4.1
6
  * Author: QuadLayers
7
  * Author URI: https://www.quadlayers.com
8
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
@@ -16,7 +16,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
16
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
17
  }
18
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
19
- define('WOOCCM_PLUGIN_VERSION', '4.4.1');
20
  }
21
  if (!defined('WOOCCM_PLUGIN_FILE')) {
22
  define('WOOCCM_PLUGIN_FILE', __FILE__);
2
  /**
3
  * Plugin Name: WooCommerce Checkout Manager
4
  * Description: Manages WooCommerce Checkout, the advanced way.
5
+ * Version: 4.4.2
6
  * Author: QuadLayers
7
  * Author URI: https://www.quadlayers.com
8
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
16
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
17
  }
18
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
19
+ define('WOOCCM_PLUGIN_VERSION', '4.4.2');
20
  }
21
  if (!defined('WOOCCM_PLUGIN_FILE')) {
22
  define('WOOCCM_PLUGIN_FILE', __FILE__);