WooCommerce Checkout Field Editor (Manager) Pro - Version 1.4.4

Version Description

  • Fixed the issue for showing red asterisk for optional address fields when overridng with locale.
  • New settings to manage locale overrides.
  • New filter to disable class override with locale.
  • WooCommerce compatible version updated.
Download this release

Release Info

Developer ThemeHigh
Plugin Icon 128x128 WooCommerce Checkout Field Editor (Manager) Pro
Version 1.4.4
Comparing to
See all releases

Code changes from version 1.4.3 to 1.4.4

assets/css/thwcfd-admin.css CHANGED
@@ -313,4 +313,185 @@ h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
313
 
314
  /*.select2-drop {
315
  z-index: 999999!important;
316
- }*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
  /*.select2-drop {
315
  z-index: 999999!important;
316
+ }*/
317
+
318
+
319
+
320
+ :root {
321
+ /*--primary-bg-color: #561849;
322
+ --primary-text-color: #561849;
323
+ --primary-border-color: #3b80ee;*/
324
+
325
+ --primary-bg-color: #007cba;
326
+ --primary-text-color: #0071a1;
327
+ --primary-border-color: #0071a1;
328
+
329
+ --primary-alt-bg-color: #f3f5f6;
330
+ --primary-alt-text-color: #0071a1;
331
+ --primary-alt-border-color: #0071a1;
332
+ }
333
+
334
+ /**************************************
335
+ ***** Button Styles - START ***********
336
+ ***************************************/
337
+ .thwcfd-wrap .btn{
338
+ display: inline-block;
339
+ background-image: none;
340
+ font-size: 14px;
341
+ font-weight: normal;
342
+ text-align: center;
343
+ vertical-align: middle;
344
+ white-space: nowrap;
345
+ cursor: pointer;
346
+ touch-action: manipulation;
347
+ line-height: 1;
348
+ border-width: 1px;
349
+ border-style: solid;
350
+ border-radius: 2px;
351
+ outline: 0;
352
+ margin: 0;
353
+ padding: 12px 20px;
354
+ box-sizing: border-box;
355
+ -webkit-appearance: none;
356
+ -webkit-box-sizing: border-box;
357
+ transition: .1s;
358
+ -webkit-transition: .1s;
359
+ -ms-user-select: none;
360
+ -moz-user-select: none;
361
+ -webkit-user-select: none;
362
+
363
+ color: var(--primary-alt-text-color);
364
+ background-color: var(--primary-alt-bg-color);
365
+ border-color: var(--primary-alt-border-color);
366
+ }
367
+ .thwcfd-wrap .btn:hover{
368
+ opacity: 0.9;
369
+ }
370
+ .thwcfd-wrap .btn-small{
371
+ font-size: 13px;
372
+ padding: 8px 10px;
373
+ border-radius: 2px;
374
+ }
375
+ .thwcfd-wrap .btn-tiny{
376
+ font-size: 13px;
377
+ padding: 5px 5px;
378
+ border-radius: 2px;
379
+ }
380
+
381
+ .thwcfd-wrap .btn-primary{
382
+ color: #fff;
383
+ background-color: var(--primary-bg-color);
384
+ border-color: var(--primary-border-color);
385
+ }
386
+ .thwcfd-wrap .btn-primary-alt{
387
+ color: var(--primary-alt-text-color);
388
+ background-color: var(--primary-alt-bg-color);
389
+ border-color: var(--primary-alt-border-color);
390
+ }
391
+ .thwcfd-wrap .btn-danger{
392
+ color: #fff;
393
+ background-color: #f44336;
394
+ border-color: #c3352b;
395
+ }
396
+
397
+ .thwcfd-wrap .btn:disabled,
398
+ .thwcfd-wrap .btn[disabled]{
399
+ color: #cbcbcb;
400
+ border-color: #cbcbcb;
401
+ background-color: #fcfcfc;
402
+ cursor: default;
403
+ }
404
+ /**************************************
405
+ ***** Button Styles - END *************
406
+ ***************************************/
407
+
408
+ /**************************************
409
+ ***** Help Tooltip - START ************
410
+ ***************************************/
411
+ .thwcfd_tooltip{
412
+ float:right;
413
+ display: inline;
414
+ position: relative;
415
+ font-size: 12px;
416
+ height: 100%;
417
+ }
418
+
419
+ .thwcfd_tooltip img{
420
+ padding: 0px;
421
+ vertical-align: middle;
422
+ cursor: help;
423
+ border: medium none;
424
+ height: 16px;
425
+ width: 16px;
426
+ }
427
+
428
+ .thwcfd_tooltip:hover:after{
429
+ background: #333;
430
+ background: rgba(0,0,0,1);
431
+ border-radius: 5px;
432
+ bottom: 26px;
433
+ color: #fff;
434
+ content: attr(title);
435
+ left: -100px;
436
+ padding: 10px 15px;
437
+ position: absolute;
438
+ z-index: 9998;
439
+ width: 350px;
440
+ }
441
+
442
+ .thwcfd_tooltip:hover:before{
443
+ border: solid;
444
+ border-color: #000 transparent;
445
+ border-width: 6px 6px 0 6px;
446
+ bottom: 20px;
447
+ content: "";
448
+ left: 50%;
449
+ position: absolute;
450
+ z-index: 9999;
451
+ }
452
+ /**************************************
453
+ ***** Help Tooltip - END **************
454
+ ***************************************/
455
+
456
+ /*****************************************************
457
+ ********* WEPO ADVANCE SETTINGS - START *************
458
+ *****************************************************/
459
+ .thwcfd-settings-table{
460
+ width: 100%;
461
+ }
462
+ .thwcfd-settings-table td{
463
+ padding: 5px 0px;
464
+ }
465
+ .thwcfd-settings-table td.section-title{
466
+ padding: 30px 0px 5px 0px;
467
+ text-align: left;
468
+ font-weight: bold;
469
+ text-transform: capitalize;
470
+ border-bottom: 1px dashed #cecece;
471
+ }
472
+ .thwcfd-settings-table td.label{
473
+ width: 22%;
474
+ text-align: left;
475
+ padding-right: 0;
476
+ font-weight: normal;
477
+ }
478
+ .thwcfd-settings-table td.tip{
479
+ width: 16px;
480
+ text-align: center;
481
+ padding: 0;
482
+ }
483
+ .thwcfd-settings-table td.field{
484
+ padding-left: 0;
485
+ }
486
+ .thwcfd-settings-table textarea {
487
+ width: 90%;
488
+ font-size: 0.9em;
489
+ }
490
+
491
+ .thwcfd-subtitle{
492
+ font-size:11px;
493
+ color:#666666;
494
+ }
495
+ /*****************************************************
496
+ ********* WEPO ADVANCE SETTINGS - END ***************
497
+ *****************************************************/
assets/css/thwcfd-public.css CHANGED
@@ -2,3 +2,7 @@
2
  display: inline-block;
3
  margin-right: 15px;
4
  }
 
 
 
 
2
  display: inline-block;
3
  margin-right: 15px;
4
  }
5
+
6
+ .thwcfd-optional .required{
7
+ display: none;
8
+ }
assets/js/thwcfd-checkout.js CHANGED
@@ -4,4 +4,67 @@ jQuery(document).ready(function($) {
4
  allowClear : true,
5
  placeholder: $(this).data('placeholder')
6
  }).addClass('enhanced');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  });
4
  allowClear : true,
5
  placeholder: $(this).data('placeholder')
6
  }).addClass('enhanced');
7
+
8
+ //Copied from WooCommerce address-i18n.js. Do not change
9
+ function field_is_required( field, is_required ) {
10
+ if ( is_required ) {
11
+ field.find( 'label .optional' ).remove();
12
+ field.addClass( 'validate-required' );
13
+
14
+ field_label_white_space_fix(field);
15
+
16
+ if ( field.find( 'label .required' ).length === 0 ) {
17
+ field.find( 'label' ).append(
18
+ '&nbsp;<abbr class="required" title="' +
19
+ wc_address_i18n_params.i18n_required_text +
20
+ '">*</abbr>'
21
+ );
22
+ }
23
+ } else {
24
+ field.find( 'label .required' ).remove();
25
+ field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' );
26
+
27
+ field_label_white_space_fix(field);
28
+
29
+ if ( field.find( 'label .optional' ).length === 0 ) {
30
+ field.find( 'label' ).append( '&nbsp;<span class="optional">(' + wc_address_i18n_params.i18n_optional_text + ')</span>' );
31
+ }
32
+ }
33
+ }
34
+
35
+ $( document.body ).bind( 'country_to_state_changing', function( event, country, wrapper ) {
36
+ if(thwcfd_public_var.is_override_required){
37
+ setTimeout(address_fields_required_validation_fix, 500);
38
+ }
39
+ });
40
+
41
+ function address_fields_required_validation_fix(){
42
+ var thisform = $('.woocommerce-checkout');
43
+ var locale_fields = $.parseJSON( wc_address_i18n_params.locale_fields );
44
+
45
+ if(locale_fields){
46
+ $.each( locale_fields, function( key, value ) {
47
+ var fids = value.split(',');
48
+
49
+ $.each( fids, function( index, fid ) {
50
+ var field = thisform.find( fid.trim() );
51
+
52
+ if(field.hasClass('thwcfd-required')){
53
+ field_is_required( field, true );
54
+ }else if(field.hasClass('thwcfd-optional')){
55
+ field_is_required( field, false );
56
+ }
57
+ });
58
+ });
59
+ }
60
+ }
61
+
62
+ //White space fix. Should be removed once fixed by WooCommerec.
63
+ function field_label_white_space_fix(field){
64
+ var label = field.find( 'label' ).html();
65
+ if(label){
66
+ label = label.replace(/(?:^(?:&nbsp;)+)|(?:(?:&nbsp;)+$)/g, '');
67
+ field.find( 'label' ).html( label.trim() );
68
+ }
69
+ }
70
  });
checkout-form-designer.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Checkout Field Editor for WooCommerce
4
  * Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
5
  * Author: ThemeHigh
6
- * Version: 1.4.3
7
  * Author URI: https://www.themehigh.com
8
  * Plugin URI: https://www.themehigh.com
9
  * Text Domain: woo-checkout-field-editor-pro
10
  * Domain Path: /languages
11
  * WC requires at least: 3.0.0
12
- * WC tested up to: 4.3.0
13
  */
14
 
15
  if(!defined( 'ABSPATH' )) exit;
@@ -25,7 +25,7 @@ if (!function_exists('is_woocommerce_active')){
25
  }
26
 
27
  if(is_woocommerce_active()) {
28
- define('THWCFD_VERSION', '1.4.3');
29
  !defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
30
  !defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
31
  !defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
3
  * Plugin Name: Checkout Field Editor for WooCommerce
4
  * Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
5
  * Author: ThemeHigh
6
+ * Version: 1.4.4
7
  * Author URI: https://www.themehigh.com
8
  * Plugin URI: https://www.themehigh.com
9
  * Text Domain: woo-checkout-field-editor-pro
10
  * Domain Path: /languages
11
  * WC requires at least: 3.0.0
12
+ * WC tested up to: 4.5.2
13
  */
14
 
15
  if(!defined( 'ABSPATH' )) exit;
25
  }
26
 
27
  if(is_woocommerce_active()) {
28
+ define('THWCFD_VERSION', '1.4.4');
29
  !defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
30
  !defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
31
  !defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
classes/class-thwcfd-checkout.php CHANGED
@@ -26,11 +26,15 @@ class THWCFD_Checkout {
26
  wp_register_script('thwcfd-checkout-script', THWCFD_ASSETS_URL.'js/thwcfd-checkout.js', $deps, THWCFD_VERSION, $in_footer);
27
  wp_enqueue_script('thwcfd-checkout-script');
28
  wp_enqueue_style('thwcfd-checkout-style', THWCFD_ASSETS_URL . 'css/thwcfd-public.css', THWCFD_VERSION);
 
 
 
 
 
29
  }
30
  }
31
 
32
  public function define_public_hooks(){
33
- $hp_default_address_fields = apply_filters('thwcfd_default_address_fields_priority', 1000);
34
  $hp_billing_fields = apply_filters('thwcfd_billing_fields_priority', 1000);
35
  $hp_shipping_fields = apply_filters('thwcfd_shipping_fields_priority', 1000);
36
  $hp_checkout_fields = apply_filters('thwcfd_checkout_fields_priority', 1000);
@@ -44,7 +48,6 @@ class THWCFD_Checkout {
44
  add_filter('woocommerce_billing_fields', array($this, 'billing_fields'), $hp_billing_fields, 2);
45
  add_filter('woocommerce_shipping_fields', array($this, 'shipping_fields'), $hp_shipping_fields, 2);
46
  add_filter('woocommerce_checkout_fields', array($this, 'checkout_fields'), $hp_checkout_fields);
47
- add_filter('woocommerce_default_address_fields' , array($this, 'default_address_fields'), $hp_default_address_fields);
48
 
49
  add_action('woocommerce_after_checkout_validation', array($this, 'checkout_fields_validation'), 10, 2);
50
  add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_update_order_meta'), 10, 2);
@@ -68,41 +71,74 @@ class THWCFD_Checkout {
68
  return $enabled > 0 ? true : false;
69
  }
70
  return true;
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  public function prepare_country_locale($fields) {
74
  if(is_array($fields)){
75
- $sname = apply_filters('thwcfd_address_field_override_with', 'billing');
76
- $address_fields = get_option('wc_fields_'.$sname);
77
 
78
- foreach($fields as $key => $props){
79
- $override_ph = apply_filters('thwcfd_address_field_override_placeholder', true);
80
- $override_label = apply_filters('thwcfd_address_field_override_label', true);
81
- $override_required = apply_filters('thwcfd_address_field_override_required', false);
82
- $override_priority = apply_filters('thwcfd_address_field_override_priority', true);
83
-
84
- if($override_ph && isset($props['placeholder'])){
85
- unset($fields[$key]['placeholder']);
86
- }
87
 
 
88
  if($override_label && isset($props['label'])){
89
  unset($fields[$key]['label']);
90
  }
91
 
92
- if($override_required && isset($props['required'])){
93
- $fkey = $sname.'_'.$key;
94
- if(is_array($address_fields) && isset($address_fields[$fkey])){
95
- $cf_props = $address_fields[$fkey];
96
- if(is_array($cf_props) && isset($cf_props['required'])){
97
- $fields[$key]['required'] = $cf_props['required'] ? true : false;
98
- }
99
- }
100
- //unset($fields[$key]['required']);
101
  }
102
 
103
  if($override_priority && isset($props['priority'])){
104
  unset($fields[$key]['priority']);
105
- //unset($fields[$key]['order']);
106
  }
107
  }
108
  }
@@ -110,9 +146,14 @@ class THWCFD_Checkout {
110
  }
111
 
112
  public function get_country_locale($locale) {
113
- if(is_array($locale)){
114
- foreach($locale as $country => $fields){
115
- $locale[$country] = $this->prepare_country_locale($fields);
 
 
 
 
 
116
  }
117
  }
118
  return $locale;
@@ -159,44 +200,31 @@ class THWCFD_Checkout {
159
  return $fields;
160
  }
161
 
162
- public function default_address_fields($fields) {
163
- $sname = apply_filters('thwcfd_address_field_override_with', 'billing');
164
-
165
- if($sname === 'billing' || $sname === 'shipping'){
166
- $address_fields = get_option('wc_fields_'.$sname);
167
-
168
- if(is_array($address_fields) && !empty($address_fields) && !empty($fields)){
169
- $override_required = apply_filters( 'thwcfd_address_field_override_required', true );
170
-
171
- foreach($fields as $name => $field) {
172
- $fname = $sname.'_'.$name;
173
-
174
- if(THWCFD_Utils::is_address_field($fname) && $override_required){
175
- $custom_field = isset($address_fields[$fname]) ? $address_fields[$fname] : false;
176
-
177
- if(THWCFD_Utils::is_enabled($custom_field)){
178
- $fields[$name]['required'] = isset($custom_field['required']) && $custom_field['required'] ? true : false;
179
- }
180
- }
181
- }
182
- }
183
- }
184
-
185
- return $fields;
186
- }
187
-
188
  public function prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
189
  if(is_array($fieldset) && !empty($fieldset)) {
190
  $locale = WC()->countries->get_country_locale();
191
 
192
  if(isset($locale[ $country ]) && is_array($locale[ $country ])) {
 
 
 
193
  foreach($locale[ $country ] as $key => $value){
194
  $fname = $sname.'_'.$key;
195
 
196
  if(is_array($value) && isset($fieldset[$fname])){
197
- if(isset($value['required'])){
198
  $fieldset[$fname]['required'] = $value['required'];
199
  }
 
 
 
 
 
 
 
 
 
 
200
  }
201
  }
202
  }
@@ -210,6 +238,8 @@ class THWCFD_Checkout {
210
 
211
  public function prepare_checkout_fields($fields, $original_fields) {
212
  if(is_array($fields) && !empty($fields)) {
 
 
213
  foreach($fields as $name => $field) {
214
  if(THWCFD_Utils::is_enabled($field)) {
215
  $new_field = false;
@@ -217,17 +247,35 @@ class THWCFD_Checkout {
217
 
218
  if($original_fields && isset($original_fields[$name]) && !$allow_override){
219
  $new_field = $original_fields[$name];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  $new_field['label'] = isset($field['label']) ? $field['label'] : '';
222
  $new_field['default'] = isset($field['default']) ? $field['default'] : '';
223
  $new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
224
- $new_field['class'] = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
225
  $new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
226
  $new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
227
-
228
- $new_field['required'] = isset($field['required']) ? $field['required'] : 0;
229
  $new_field['priority'] = isset($field['priority']) ? $field['priority'] : '';
230
-
231
  } else {
232
  $new_field = $field;
233
  }
@@ -352,15 +400,6 @@ class THWCFD_Checkout {
352
  }
353
  }
354
 
355
- /*private function maybe_skip_fieldset( $fieldset_key, $data ) {
356
- $ship_to_different_address = isset($data['ship_to_different_address']) ? $data['ship_to_different_address'] : false;
357
-
358
- if ( 'shipping' === $fieldset_key && ( ! $ship_to_different_address || ! WC()->cart->needs_shipping_address() ) ) {
359
- return true;
360
- }
361
- return false;
362
- }*/
363
-
364
  private function maybe_skip_fieldset( $fieldset_key, $data ) {
365
  $ship_to_different_address = isset($data['ship_to_different_address']) ? $data['ship_to_different_address'] : false;
366
  $ship_to_destination = get_option( 'woocommerce_ship_to_destination' );
26
  wp_register_script('thwcfd-checkout-script', THWCFD_ASSETS_URL.'js/thwcfd-checkout.js', $deps, THWCFD_VERSION, $in_footer);
27
  wp_enqueue_script('thwcfd-checkout-script');
28
  wp_enqueue_style('thwcfd-checkout-style', THWCFD_ASSETS_URL . 'css/thwcfd-public.css', THWCFD_VERSION);
29
+
30
+ $wcfd_var = array(
31
+ 'is_override_required' => $this->is_override_required_prop(),
32
+ );
33
+ wp_localize_script('thwcfd-checkout-script', 'thwcfd_public_var', $wcfd_var);
34
  }
35
  }
36
 
37
  public function define_public_hooks(){
 
38
  $hp_billing_fields = apply_filters('thwcfd_billing_fields_priority', 1000);
39
  $hp_shipping_fields = apply_filters('thwcfd_shipping_fields_priority', 1000);
40
  $hp_checkout_fields = apply_filters('thwcfd_checkout_fields_priority', 1000);
48
  add_filter('woocommerce_billing_fields', array($this, 'billing_fields'), $hp_billing_fields, 2);
49
  add_filter('woocommerce_shipping_fields', array($this, 'shipping_fields'), $hp_shipping_fields, 2);
50
  add_filter('woocommerce_checkout_fields', array($this, 'checkout_fields'), $hp_checkout_fields);
 
51
 
52
  add_action('woocommerce_after_checkout_validation', array($this, 'checkout_fields_validation'), 10, 2);
53
  add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_update_order_meta'), 10, 2);
71
  return $enabled > 0 ? true : false;
72
  }
73
  return true;
74
+ }
75
+
76
+ private function get_locale_override_value($key, $settings=false, $default=false){
77
+ $value = '';
78
+
79
+ if($settings){
80
+ $value = THWCFD_Utils::get_setting_value($settings, $key);
81
+ }else{
82
+ $value = THWCFD_Utils::get_settings($key);
83
+ }
84
+
85
+ return $value === 'undefined' ? $default : $value;
86
+ }
87
+
88
+ public function is_override_label($settings=false){
89
+ $override_label = $this->get_locale_override_value('enable_label_override', $settings, true);
90
+ $override_label = $override_label ? true : false;
91
+ return apply_filters('thwcfd_address_field_override_label', $override_label);
92
+ }
93
+
94
+ public function is_override_placeholder($settings=false){
95
+ $override_ph = $this->get_locale_override_value('enable_placeholder_override', $settings, true);
96
+ $override_ph = $override_ph ? true : false;
97
+ return apply_filters('thwcfd_address_field_override_placeholder', $override_ph);
98
+ }
99
+
100
+ public function is_override_class($settings=false){
101
+ $override_class = $this->get_locale_override_value('enable_class_override', $settings, false);
102
+ $override_class = $override_class ? true : false;
103
+ return apply_filters('thwcfd_address_field_override_class', $override_class);
104
+ }
105
+
106
+ public function is_override_priority($settings=false){
107
+ $override_priority = $this->get_locale_override_value('enable_priority_override', $settings, true);
108
+ $override_priority = $override_priority ? true : false;
109
+ return apply_filters('thwcfd_address_field_override_priority', $override_priority);
110
+ }
111
+
112
+ public function is_override_required_prop($settings=false){
113
+ $override_required = $this->get_locale_override_value('enable_required_override', $settings, false);
114
+ $override_required = $override_required ? true : false;
115
+ return apply_filters('thwcfd_address_field_override_required', $override_required);
116
+ }
117
 
118
  public function prepare_country_locale($fields) {
119
  if(is_array($fields)){
120
+ $settings = THWCFD_Utils::get_advanced_settings();
 
121
 
122
+ $override_label = $this->is_override_label($settings);
123
+ $override_ph = $this->is_override_placeholder($settings);
124
+ $override_class = $this->is_override_class($settings);
125
+ $override_priority = $this->is_override_priority($settings);
 
 
 
 
 
126
 
127
+ foreach($fields as $key => $props){
128
  if($override_label && isset($props['label'])){
129
  unset($fields[$key]['label']);
130
  }
131
 
132
+ if($override_ph && isset($props['placeholder'])){
133
+ unset($fields[$key]['placeholder']);
134
+ }
135
+
136
+ if($override_class && isset($props['class'])){
137
+ unset($fields[$key]['class']);
 
 
 
138
  }
139
 
140
  if($override_priority && isset($props['priority'])){
141
  unset($fields[$key]['priority']);
 
142
  }
143
  }
144
  }
146
  }
147
 
148
  public function get_country_locale($locale) {
149
+ $countries = array_merge( WC()->countries->get_allowed_countries(), WC()->countries->get_shipping_countries() );
150
+ $countries = array_keys($countries);
151
+
152
+ if(is_array($locale) && is_array($countries)){
153
+ foreach($countries as $country){
154
+ if(isset($locale[$country])){
155
+ $locale[$country] = $this->prepare_country_locale($locale[$country]);
156
+ }
157
  }
158
  }
159
  return $locale;
200
  return $fields;
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  public function prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
204
  if(is_array($fieldset) && !empty($fieldset)) {
205
  $locale = WC()->countries->get_country_locale();
206
 
207
  if(isset($locale[ $country ]) && is_array($locale[ $country ])) {
208
+ $override_required_prop = $this->is_override_required_prop();
209
+ $states = WC()->countries->get_states( $country );
210
+
211
  foreach($locale[ $country ] as $key => $value){
212
  $fname = $sname.'_'.$key;
213
 
214
  if(is_array($value) && isset($fieldset[$fname])){
215
+ if(!$override_required_prop && isset($value['required'])){
216
  $fieldset[$fname]['required'] = $value['required'];
217
  }
218
+
219
+ if($key === 'state'){
220
+ if(is_array($states) && empty($states)){
221
+ $fieldset[$fname]['hidden'] = true;
222
+ }
223
+ }else{
224
+ if(isset($value['hidden'])){
225
+ $fieldset[$fname]['hidden'] = $value['hidden'];
226
+ }
227
+ }
228
  }
229
  }
230
  }
238
 
239
  public function prepare_checkout_fields($fields, $original_fields) {
240
  if(is_array($fields) && !empty($fields)) {
241
+ $override_required_prop = $this->is_override_required_prop();
242
+
243
  foreach($fields as $name => $field) {
244
  if(THWCFD_Utils::is_enabled($field)) {
245
  $new_field = false;
247
 
248
  if($original_fields && isset($original_fields[$name]) && !$allow_override){
249
  $new_field = $original_fields[$name];
250
+
251
+ $class = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
252
+ $required = isset($field['required']) ? $field['required'] : 0;
253
+ $is_hidden = isset($field['hidden']) && $field['hidden'] ? true : false;
254
+
255
+ if($is_hidden){
256
+ $new_field['hidden'] = $field['hidden'];
257
+ $new_field['required'] = false;
258
+ }else{
259
+ if($override_required_prop){
260
+ $new_field['required'] = $required;
261
+ }
262
+ }
263
+
264
+ if($override_required_prop){
265
+ if($required){
266
+ $class[] = 'thwcfd-required';
267
+ }else{
268
+ $class[] = 'thwcfd-optional';
269
+ }
270
+ }
271
 
272
  $new_field['label'] = isset($field['label']) ? $field['label'] : '';
273
  $new_field['default'] = isset($field['default']) ? $field['default'] : '';
274
  $new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
275
+ $new_field['class'] = $class;
276
  $new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
277
  $new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
 
 
278
  $new_field['priority'] = isset($field['priority']) ? $field['priority'] : '';
 
279
  } else {
280
  $new_field = $field;
281
  }
400
  }
401
  }
402
 
 
 
 
 
 
 
 
 
 
403
  private function maybe_skip_fieldset( $fieldset_key, $data ) {
404
  $ship_to_different_address = isset($data['ship_to_different_address']) ? $data['ship_to_different_address'] : false;
405
  $ship_to_destination = get_option( 'woocommerce_ship_to_destination' );
classes/class-thwcfd-settings-advanced.php ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Woo Checkout Field Editor Settings Advanced
4
+ *
5
+ * @link https://themehigh.com
6
+ * @since 1.4.4
7
+ *
8
+ * @package woo-checkout-field-editor-pro
9
+ * @subpackage woo-checkout-field-editor-pro/classes
10
+ */
11
+
12
+ defined( 'ABSPATH' ) || exit;
13
+
14
+ if(!class_exists('THWCFD_Settings_Advanced')):
15
+
16
+ class THWCFD_Settings_Advanced {
17
+ protected static $_instance = null;
18
+ protected $tabs = '';
19
+
20
+ private $settings_fields = NULL;
21
+ private $cell_props = array();
22
+ private $cell_props_CB = array();
23
+ private $cell_props_TA = array();
24
+
25
+ public function __construct() {
26
+ $this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
27
+ $this->init_constants();
28
+ }
29
+
30
+ public static function instance() {
31
+ if(is_null(self::$_instance)){
32
+ self::$_instance = new self();
33
+ }
34
+ return self::$_instance;
35
+ }
36
+
37
+ public function init_constants(){
38
+ $this->cell_props = array(
39
+ 'label_cell_props' => 'class="label"',
40
+ 'input_cell_props' => 'class="field"',
41
+ 'input_width' => '260px',
42
+ 'label_cell_th' => true
43
+ );
44
+
45
+ $this->cell_props_TA = array(
46
+ 'label_cell_props' => 'class="label"',
47
+ 'input_cell_props' => 'class="field"',
48
+ 'rows' => 10,
49
+ 'cols' => 100,
50
+ );
51
+
52
+ $this->cell_props_CB = array(
53
+ 'label_props' => 'style="margin-right: 40px;"',
54
+ );
55
+
56
+ $this->settings_fields = $this->get_advanced_settings_fields();
57
+ }
58
+
59
+ public function get_advanced_settings_fields(){
60
+ return array(
61
+ 'enable_label_override' => array(
62
+ 'name'=>'enable_label_override', 'label'=>'Enable label override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
63
+ ),
64
+ 'enable_placeholder_override' => array(
65
+ 'name'=>'enable_placeholder_override', 'label'=>'Enable placeholder override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
66
+ ),
67
+ 'enable_class_override' => array(
68
+ 'name'=>'enable_class_override', 'label'=>'Enable class override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
69
+ ),
70
+ 'enable_priority_override' => array(
71
+ 'name'=>'enable_priority_override', 'label'=>'Enable priority override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
72
+ ),
73
+ 'enable_required_override' => array(
74
+ 'name'=>'enable_required_override', 'label'=>'Enable required validation override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
75
+ ),
76
+ );
77
+ }
78
+
79
+ public function render_page(){
80
+ $this->render_tabs();
81
+ $this->render_content();
82
+ }
83
+
84
+ public function save_advanced_settings($settings){
85
+ $result = update_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS, $settings);
86
+ return $result;
87
+ }
88
+
89
+ private function reset_settings(){
90
+ delete_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS);
91
+ $this->print_notices('Settings successfully reset.', 'updated', false);
92
+ }
93
+
94
+ private function save_settings(){
95
+ $settings = array();
96
+
97
+ foreach( $this->settings_fields as $name => $field ) {
98
+ $value = '';
99
+
100
+ if($field['type'] === 'checkbox'){
101
+ $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
102
+
103
+ }else if($field['type'] === 'multiselect_grouped'){
104
+ $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
105
+ $value = is_array($value) ? implode(',', wc_clean(wp_unslash($value))) : wc_clean(wp_unslash($value));
106
+
107
+ }else if($field['type'] === 'text' || $field['type'] === 'textarea'){
108
+ $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
109
+ $value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
110
+
111
+ }else{
112
+ $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
113
+ $value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
114
+ }
115
+
116
+ $settings[$name] = $value;
117
+ }
118
+
119
+ $result = $this->save_advanced_settings($settings);
120
+ if ($result == true) {
121
+ $this->print_notices('Your changes were saved.', 'updated', false);
122
+ } else {
123
+ $this->print_notices('Your changes were not saved due to an error (or you made none!).', 'error', false);
124
+ }
125
+ }
126
+
127
+ private function render_content(){
128
+ if(isset($_POST['reset_settings']))
129
+ $this->reset_settings();
130
+
131
+ if(isset($_POST['save_settings']))
132
+ $this->save_settings();
133
+
134
+ /*if(isset($_POST['save_plugin_settings']))
135
+ $result = $this->save_plugin_settings();*/
136
+
137
+ $this->render_plugin_settings();
138
+ //$this->render_import_export_settings();
139
+ }
140
+
141
+ private function render_plugin_settings(){
142
+ $settings = THWCFD_Utils::get_advanced_settings();
143
+ ?>
144
+ <div style="padding-left: 30px;">
145
+ <form id="advanced_settings_form" method="post" action="">
146
+ <table class="thwcfd-settings-table thpladmin-form-table">
147
+ <tbody>
148
+ <?php
149
+ $this->render_locale_override_settings($settings);
150
+ ?>
151
+ </tbody>
152
+ </table>
153
+ <p class="submit">
154
+ <input type="submit" name="save_settings" class="btn btn-small btn-primary" value="Save changes">
155
+ <input type="submit" name="reset_settings" class="btn btn-small" value="Reset to default"
156
+ onclick="return confirm('Are you sure you want to reset to default settings? all your changes will be deleted.');">
157
+ </p>
158
+ </form>
159
+ </div>
160
+ <?php
161
+ }
162
+
163
+ private function render_locale_override_settings($settings){
164
+ $this->render_form_elm_row_title('Locale override settings');
165
+ $this->render_form_elm_row_cb($this->settings_fields['enable_label_override'], $settings, true);
166
+ $this->render_form_elm_row_cb($this->settings_fields['enable_placeholder_override'], $settings, true);
167
+ $this->render_form_elm_row_cb($this->settings_fields['enable_class_override'], $settings, true);
168
+ $this->render_form_elm_row_cb($this->settings_fields['enable_priority_override'], $settings, true);
169
+ $this->render_form_elm_row_cb($this->settings_fields['enable_required_override'], $settings, true);
170
+ }
171
+
172
+ public function render_form_elm_row_title($title=''){
173
+ ?>
174
+ <tr>
175
+ <td colspan="3" class="section-title" ><?php echo $title; ?></td>
176
+ </tr>
177
+ <?php
178
+ }
179
+
180
+ private function render_form_elm_row_cb($field, $settings=false, $merge_cells=false){
181
+ $name = $field['name'];
182
+ if(is_array($settings) && isset($settings[$name])){
183
+ if($field['value'] === $settings[$name]){
184
+ $field['checked'] = 1;
185
+ }else{
186
+ $field['checked'] = 0;
187
+ }
188
+ }
189
+
190
+ if($merge_cells){
191
+ ?>
192
+ <tr>
193
+ <td colspan="3">
194
+ <?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
195
+ </td>
196
+ </tr>
197
+ <?php
198
+ }else{
199
+ ?>
200
+ <tr>
201
+ <td colspan="2"></td>
202
+ <td class="field">
203
+ <?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
204
+ </td>
205
+ </tr>
206
+ <?php
207
+ }
208
+ }
209
+
210
+ public function render_form_field_element($field, $atts = array(), $render_cell = true){
211
+ if($field && is_array($field)){
212
+ $args = shortcode_atts( array(
213
+ 'label_cell_props' => '',
214
+ 'input_cell_props' => '',
215
+ 'label_cell_colspan' => '',
216
+ 'input_cell_colspan' => '',
217
+ ), $atts );
218
+
219
+ $ftype = isset($field['type']) ? $field['type'] : 'text';
220
+ $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
221
+ $sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : '';
222
+ $tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : '';
223
+
224
+ $field_html = '';
225
+
226
+ if($ftype == 'text'){
227
+ $field_html = $this->render_form_field_element_inputtext($field, $atts);
228
+
229
+ }else if($ftype == 'textarea'){
230
+ $field_html = $this->render_form_field_element_textarea($field, $atts);
231
+
232
+ }else if($ftype == 'checkbox'){
233
+ $field_html = $this->render_form_field_element_checkbox($field, $atts, $render_cell);
234
+ $flabel = '&nbsp;';
235
+ }
236
+
237
+ if($render_cell){
238
+ $required_html = isset($field['required']) && $field['required'] ? '<abbr class="required" title="required">*</abbr>' : '';
239
+
240
+ $label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : '';
241
+ $input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : '';
242
+
243
+ ?>
244
+ <td <?php echo $label_cell_props ?> >
245
+ <?php echo $flabel; echo $required_html;
246
+ if($sub_label){
247
+ ?>
248
+ <br/><span class="thpladmin-subtitle"><?php echo $sub_label; ?></span>
249
+ <?php
250
+ }
251
+ ?>
252
+ </td>
253
+ <?php $this->render_form_fragment_tooltip($tooltip); ?>
254
+ <td <?php echo $input_cell_props ?> ><?php echo $field_html; ?></td>
255
+ <?php
256
+ }else{
257
+ echo $field_html;
258
+ }
259
+ }
260
+ }
261
+
262
+ private function prepare_form_field_props($field, $atts = array()){
263
+ $field_props = '';
264
+ $args = shortcode_atts( array(
265
+ 'input_width' => '',
266
+ 'input_name_prefix' => 'i_',
267
+ 'input_name_suffix' => '',
268
+ ), $atts );
269
+
270
+ $ftype = isset($field['type']) ? $field['type'] : 'text';
271
+
272
+ if($ftype == 'multiselect'){
273
+ $args['input_name_suffix'] = $args['input_name_suffix'].'[]';
274
+ }
275
+
276
+ $fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix'];
277
+ $fvalue = isset($field['value']) ? esc_html($field['value']) : '';
278
+
279
+ $input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : '';
280
+ $field_props = 'name="'. $fname .'" value="'. $fvalue .'" style="'. $input_width .'"';
281
+ $field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : '';
282
+ $field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : '';
283
+
284
+ return $field_props;
285
+ }
286
+
287
+ private function render_form_field_element_inputtext($field, $atts = array()){
288
+ $field_html = '';
289
+ if($field && is_array($field)){
290
+ $field_props = $this->prepare_form_field_props($field, $atts);
291
+ $field_html = '<input type="text" '. $field_props .' />';
292
+ }
293
+ return $field_html;
294
+ }
295
+
296
+ private function render_form_field_element_textarea($field, $atts = array()){
297
+ $field_html = '';
298
+ if($field && is_array($field)){
299
+ $args = shortcode_atts( array(
300
+ 'rows' => '5',
301
+ 'cols' => '100',
302
+ ), $atts );
303
+
304
+ $fvalue = isset($field['value']) ? $field['value'] : '';
305
+ $field_props = $this->prepare_form_field_props($field, $atts);
306
+ $field_html = '<textarea '. $field_props .' rows="'.$args['rows'].'" cols="'.$args['cols'].'" >'.$fvalue.'</textarea>';
307
+ }
308
+ return $field_html;
309
+ }
310
+
311
+ private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){
312
+ $field_html = '';
313
+ if($field && is_array($field)){
314
+ $args = shortcode_atts( array(
315
+ 'label_props' => '',
316
+ 'cell_props' => 3,
317
+ 'render_input_cell' => false,
318
+ ), $atts );
319
+
320
+ $fid = 'a_f'. $field['name'];
321
+ $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
322
+
323
+ $field_props = $this->prepare_form_field_props($field, $atts);
324
+ $field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : '';
325
+
326
+ $field_html = '<input type="checkbox" id="'. $fid .'" '. $field_props .' />';
327
+ $field_html .= '<label for="'. $fid .'" '. $args['label_props'] .' > '. $flabel .'</label>';
328
+ }
329
+ if(!$render_cell && $args['render_input_cell']){
330
+ return '<td '. $args['cell_props'] .' >'. $field_html .'</td>';
331
+ }else{
332
+ return $field_html;
333
+ }
334
+ }
335
+
336
+ public function render_form_fragment_tooltip($tooltip = false){
337
+ $tooltip_html = '';
338
+
339
+ if($tooltip){
340
+ //$tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thwcfd_tooltip"><img src="'. THWCFD_ASSETS_URL.'css/help.png" title=""/></a>';
341
+ }
342
+ ?>
343
+ <td style="width: 26px; padding:0px;"><?php echo $tooltip_html; ?></td>
344
+ <?php
345
+ }
346
+
347
+
348
+ public function print_notices($msg, $type='updated', $return=false){
349
+ $notice = '<div class="thwcfd-notice '. $type .'"><p>'. __($msg, 'woo-checkout-field-editor-pro') .'</p></div>';
350
+ if(!$return){
351
+ echo $notice;
352
+ }
353
+ return $notice;
354
+ }
355
+
356
+ /******* TABS & SECTIONS *******/
357
+ /*******************************/
358
+ public function get_current_tab(){
359
+ return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
360
+ }
361
+
362
+ public function render_tabs(){
363
+ $current_tab = $this->get_current_tab();
364
+
365
+ if(empty($this->tabs)){
366
+ return;
367
+ }
368
+
369
+ echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
370
+ foreach( $this->tabs as $id => $label ){
371
+ $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
372
+ $label = __($label, 'woo-checkout-field-editor-pro');
373
+ echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
374
+ }
375
+ echo '</h2>';
376
+ }
377
+
378
+ public function get_admin_url($tab = false, $section = false){
379
+ $url = 'admin.php?page=checkout_form_designer';
380
+ if($tab && !empty($tab)){
381
+ $url .= '&tab='. $tab;
382
+ }
383
+ if($section && !empty($section)){
384
+ $url .= '&section='. $section;
385
+ }
386
+ return admin_url($url);
387
+ }
388
+ }
389
+
390
+ endif;
classes/class-thwcfd-settings-general.php CHANGED
@@ -20,7 +20,7 @@ class THWCFD_Settings_General {
20
  protected $sections = '';
21
 
22
  public function __construct() {
23
- $this->tabs = array( 'fields' => 'Checkout Fields');
24
  $this->sections = array('billing' => 'Billing Fields', 'shipping' => 'Shipping Fields', 'additional' => 'Additional Fields');
25
  }
26
 
20
  protected $sections = '';
21
 
22
  public function __construct() {
23
+ $this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
24
  $this->sections = array('billing' => 'Billing Fields', 'shipping' => 'Shipping Fields', 'additional' => 'Additional Fields');
25
  }
26
 
classes/class-thwcfd-settings.php CHANGED
@@ -114,10 +114,16 @@ class THWCFD_Settings {
114
  $this->output_review_request_link();
115
 
116
  $tab = $this->get_current_tab();
117
- if($tab === 'fields'){
 
 
 
 
 
118
  $general_settings = THWCFD_Settings_General::instance();
119
  $general_settings->render_page();
120
  }
 
121
  }
122
 
123
  public function get_current_tab(){
114
  $this->output_review_request_link();
115
 
116
  $tab = $this->get_current_tab();
117
+
118
+ echo '<div class="thwcfd-wrap">';
119
+ if($tab === 'advanced_settings'){
120
+ $advanced_settings = THWCFD_Settings_Advanced::instance();
121
+ $advanced_settings->render_page();
122
+ }else{
123
  $general_settings = THWCFD_Settings_General::instance();
124
  $general_settings->render_page();
125
  }
126
+ echo '</div">';
127
  }
128
 
129
  public function get_current_tab(){
classes/class-thwcfd-utils.php CHANGED
@@ -14,6 +14,8 @@ defined( 'ABSPATH' ) || exit;
14
  if(!class_exists('THWCFD_Utils')):
15
 
16
  class THWCFD_Utils {
 
 
17
  public function __construct() {
18
 
19
  }
@@ -285,6 +287,33 @@ class THWCFD_Utils {
285
  return empty($value) && !is_numeric($value);
286
  }
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  /***********************************
289
  ----- i18n functions - START ------
290
  ***********************************/
@@ -309,6 +338,16 @@ class THWCFD_Utils {
309
  }
310
  echo $text;
311
  }
 
 
 
 
 
 
 
 
 
 
312
  }
313
 
314
  endif;
14
  if(!class_exists('THWCFD_Utils')):
15
 
16
  class THWCFD_Utils {
17
+ const OPTION_KEY_ADVANCED_SETTINGS = 'thwcfd_advanced_settings';
18
+
19
  public function __construct() {
20
 
21
  }
287
  return empty($value) && !is_numeric($value);
288
  }
289
 
290
+ /**************************************
291
+ ----- ADVANCED SETTINGS - START ------
292
+ **************************************/
293
+ public static function get_advanced_settings(){
294
+ $settings = get_option(self::OPTION_KEY_ADVANCED_SETTINGS);
295
+ $settings = apply_filters('thwcfd_advanced_settings', $settings);
296
+ return empty($settings) ? false : $settings;
297
+ }
298
+
299
+ public static function get_setting_value($settings, $key){
300
+ if(is_array($settings) && isset($settings[$key])){
301
+ return $settings[$key];
302
+ }
303
+ return 'undefined';
304
+ }
305
+
306
+ public static function get_settings($key){
307
+ $settings = self::get_advanced_settings();
308
+ if(is_array($settings) && isset($settings[$key])){
309
+ return $settings[$key];
310
+ }
311
+ return 'undefined';
312
+ }
313
+ /**************************************
314
+ ----- ADVANCED SETTINGS - END --------
315
+ **************************************/
316
+
317
  /***********************************
318
  ----- i18n functions - START ------
319
  ***********************************/
338
  }
339
  echo $text;
340
  }
341
+
342
+ public static function write_log ( $log ) {
343
+ if ( true === WP_DEBUG ) {
344
+ if ( is_array( $log ) || is_object( $log ) ) {
345
+ error_log( print_r( $log, true ) );
346
+ } else {
347
+ error_log( $log );
348
+ }
349
+ }
350
+ }
351
  }
352
 
353
  endif;
classes/class-thwcfd.php CHANGED
@@ -30,6 +30,7 @@ class THWCFD {
30
  require_once THWCFD_PATH . 'classes/class-thwcfd-utils.php';
31
  require_once THWCFD_PATH . 'classes/class-thwcfd-settings.php';
32
  require_once THWCFD_PATH . 'classes/class-thwcfd-settings-general.php';
 
33
  require_once THWCFD_PATH . 'classes/class-thwcfd-checkout.php';
34
  }
35
 
30
  require_once THWCFD_PATH . 'classes/class-thwcfd-utils.php';
31
  require_once THWCFD_PATH . 'classes/class-thwcfd-settings.php';
32
  require_once THWCFD_PATH . 'classes/class-thwcfd-settings-general.php';
33
+ require_once THWCFD_PATH . 'classes/class-thwcfd-settings-advanced.php';
34
  require_once THWCFD_PATH . 'classes/class-thwcfd-checkout.php';
35
  }
36
 
readme.txt CHANGED
@@ -3,8 +3,9 @@ Contributors: ThemeHigh
3
  Donate link: https://themehigh.com/
4
  Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
5
  Requires at least: 4.9
6
- Tested up to: 5.4
7
- Stable tag: 1.4.3
 
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -20,52 +21,53 @@ https://www.youtube.com/watch?v=_iKMe5lGIIM
20
  --------------------------------------------
21
 
22
  = Basic Version Features =
23
- * **Add new custom field(s).**
24
- Adding custom fields to the WooCommerce checkout page is a breeze now. You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
25
 
26
- * **Edit field(s).**
27
- You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
28
 
29
- * Available field types are
30
- * Input Text
31
- * Password
32
- * Email
33
- * Phone
34
- * Select
35
- * Textarea
36
- * Radio
37
 
38
- * **Display in Order Details page and Email.**
39
- You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are available in both the ‘New Field’ and ‘Edit Field’ forms.
 
 
 
 
 
40
 
41
- * **Remove field(s).**
42
- You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
43
 
44
- * **Enable/Disable field(s).**
45
- You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
46
 
47
- * **Change checkout fields order.**
48
- You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
49
 
50
- * **Reset to default field set.**
51
- You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
52
 
53
- = Premium Version Demos =
54
- Check out the premium version of Checkout Field Editor for WooCommerce - The best WooCommerce Checkout Manager Plugin which helps you to customize checkout fields displayed on your WooCommerce checkout page. Add custom fields to WooCommerce checkout page easily.
 
 
 
 
 
 
 
55
 
56
- --------------------------------------------
57
  [Live Demo - Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
58
  [Live Demo - Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
59
 
60
- [Buy Now!](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
61
- --------------------------------------------
62
 
63
- = Premium Version Features =
64
- * **17 field types are available:**
65
- In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
66
 
67
- Available field types:
68
- 1. Input Text
69
  2. Hidden
70
  3. Password
71
  4. Telephone
@@ -83,19 +85,20 @@ Check out the premium version of Checkout Field Editor for WooCommerce - The bes
83
  16. Heading – Display a heading/ title
84
  17. Label – Display a label/ text
85
 
86
- * **Conditional Fields:**
87
- Conditionally display fields & sections based on cart items and other field(s) values.
88
 
89
- * **Custom Validations:**
90
- Custom validator feature can be used to define custom validation rules using RegEx.
 
 
 
91
 
92
- * **Price Fields:**
93
- Add an extra cost to the cart total based on field selection.
94
 
95
- * **Add new section:**
96
- Add new section(s) in predefined positions in checkout page.
97
 
98
- Available positions:
99
  1. Before customer details
100
  2. After customer details
101
  3. Before billing form
@@ -111,16 +114,42 @@ Check out the premium version of Checkout Field Editor for WooCommerce - The bes
111
  13. Before submit button
112
  14. After submit button
113
 
114
- * **Edit section(s) properties:**
115
- Edit custom added section(s) label and display position.
116
 
117
- * **Delete section(s):**
118
- Delete custom added section(s).
119
 
120
  --------------------------------------------
121
- [Upgrade to Premium Now!](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
 
 
122
  --------------------------------------------
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  == Installation ==
125
  = Minimum Requirements =
126
  * WooCommerce 3.0 or greater
@@ -178,6 +207,12 @@ Yes. There is a button 'reset to default fields' to go back to the WooCommerce d
178
  8. Newly added field
179
 
180
  == Changelog ==
 
 
 
 
 
 
181
  = 1.4.3 =
182
  * Improved shipping fields section handling when 'Force shipping to the customer billing address' option is selected.
183
  * WooCommerce compatible version updated.
3
  Donate link: https://themehigh.com/
4
  Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
5
  Requires at least: 4.9
6
+ Tested up to: 5.5
7
+ Requires PHP: 5.6
8
+ Stable tag: 1.4.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
21
  --------------------------------------------
22
 
23
  = Basic Version Features =
24
+ = ☞ Add new custom field(s) =
25
+ Adding custom fields to the WooCommerce checkout page is a breeze now. You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
26
 
27
+ = ☞ Edit field(s) =
28
+ You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
29
 
30
+ Available field types are:
 
 
 
 
 
 
 
31
 
32
+ * Input Text
33
+ * Password
34
+ * Email
35
+ * Phone
36
+ * Select
37
+ * Textarea
38
+ * Radio
39
 
40
+ = Display in Order Details page and Email =
41
+ You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are available in both the ‘New Field’ and ‘Edit Field’ forms.
42
 
43
+ = ☞ Remove field(s) =
44
+ You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
45
 
46
+ = Enable/Disable field(s) =
47
+ You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
48
 
49
+ = Change checkout fields order =
50
+ You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
51
 
52
+ = Reset to default field set =
53
+ You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
54
+
55
+ == 💎💎 Premium Features ==
56
+ The premium version of [Checkout Field Editor for WooCommerce](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin offers a wide variety of advanced features that will help you to create the finest checkout page. It is equipped with all demanded options to customize your checkout page.
57
+
58
+ [Upgrade to Premium Now!](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
59
+
60
+ You can check out the demo for a more detailed overview of the features.
61
 
 
62
  [Live Demo - Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
63
  [Live Demo - Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
64
 
65
+ = ☞ 17 field types are available =
66
+ In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
67
 
68
+ Available field types:
 
 
69
 
70
+ 1. Input Text
 
71
  2. Hidden
72
  3. Password
73
  4. Telephone
85
  16. Heading – Display a heading/ title
86
  17. Label – Display a label/ text
87
 
88
+ = ☞ Conditional Fields =
89
+ Conditionally display fields & sections based on cart items and other field(s) values.
90
 
91
+ = ☞ Custom Validations =
92
+ Custom validator feature can be used to define custom validation rules using RegEx.
93
+
94
+ = ☞ Price Fields =
95
+ Add an extra cost to the cart total based on field selection.
96
 
97
+ = Add new section =
98
+ Add new section(s) in predefined positions in checkout page.
99
 
100
+ Available positions:
 
101
 
 
102
  1. Before customer details
103
  2. After customer details
104
  3. Before billing form
114
  13. Before submit button
115
  14. After submit button
116
 
117
+ = ☞ Edit section(s) properties =
118
+ Edit custom added section(s) label and display position.
119
 
120
+ = ☞ Delete section(s) =
121
+ Delete custom added section(s).
122
 
123
  --------------------------------------------
124
+ *For the complete list of features, Please visit [WooCommerce Checkout Field Editor (Checkout Manager)](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin's official page.*
125
+
126
+ Check how it works (Live Demo): 🔗 [Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) | 🔗 [Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
127
  --------------------------------------------
128
 
129
+ == Why ThemeHigh ==
130
+ Frequent updates are made to improve the plugin with a talented group of developers. Moreover, the dedicated support team will help you set up and customize your dream store with all available features and hooks.
131
+
132
+ 🏆 2 Million+ Customers
133
+ 🏆 Quickest Turn-around Support
134
+ 🏆 Most Lightweight Plugins
135
+
136
+ **See a few reviews below;**
137
+ > amitaugma (@amitaugma) ⭐⭐⭐⭐⭐
138
+ > The plugin functionally provides all the necessary tools to successfully build a clean checkout form with conditional and easy to use interface. On top of that, their support is amazing and would take the extra mile to help with any inquires. RECOMMENDED
139
+
140
+ > dragoso (@dragoso) ⭐⭐⭐⭐⭐
141
+ > Support is super speedy and the PRO plugin is totally awesome and works like a charm. Very happy with the purchase! Thank you guys!
142
+
143
+ > DCM (@bcreativos) ⭐⭐⭐⭐⭐
144
+ > Great complement in both versions: Free and paid. Excellent support. Thank you very much recommended 100%.
145
+
146
+ For more info on ThemeHigh and WooCommerce Checkout Field Editor plugin in specific, check out the following:
147
+
148
+ * The [Checkout Field Editor (Checkout Manager) for WooCommerce](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) premium plugin homepage.
149
+ * The [Knowledgebase](https://www.themehigh.com/doc/woocommerce-checkout-field-editor/?utm_source=wordpress&utm_medium=referral&utm_content=tracking).
150
+ * Other [WordPress Plugins](https://www.themehigh.com/plugins/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) by the ThemeHigh team.
151
+ * Follow ThemeHigh on [Facebook](https://www.facebook.com/ThemeHigh-319611541768603/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [LinkedIn](https://www.linkedin.com/company/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [Twitter](https://twitter.com/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) & [YouTube](https://www.youtube.com/channel/UC-_uMXaC_21j1Y2_nGjTyvg/?utm_source=wordpress&utm_medium=referral&utm_content=tracking).
152
+
153
  == Installation ==
154
  = Minimum Requirements =
155
  * WooCommerce 3.0 or greater
207
  8. Newly added field
208
 
209
  == Changelog ==
210
+ = 1.4.4 =
211
+ * Fixed the issue for showing red asterisk for optional address fields when overridng with locale.
212
+ * New settings to manage locale overrides.
213
+ * New filter to disable class override with locale.
214
+ * WooCommerce compatible version updated.
215
+
216
  = 1.4.3 =
217
  * Improved shipping fields section handling when 'Force shipping to the customer billing address' option is selected.
218
  * WooCommerce compatible version updated.