WooCommerce Checkout Manager - Version 4.5.1

Version Description

  • Fix: woocommerce first additional field delete in admin
  • Fix: woocommerce billing field disable
  • Fix: woocommerce shipping field disable
  • Fix: woocommerce additional field disable
Download this release

Release Info

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

Code changes from version 4.5.0 to 4.5.1

assets/js/wooccm-modal.js CHANGED
@@ -36,7 +36,11 @@
36
  'click .media-modal-prev': 'edit',
37
  'click .media-modal-next': 'edit',
38
  //'click .media-modal-tab': 'tab',
39
- 'change .media-modal-change': 'change',
 
 
 
 
40
  'submit .media-modal-form': 'save',
41
  },
42
  templates: {},
@@ -94,7 +98,7 @@
94
  },
95
  success: function (response) {
96
  if (response.success) {
97
- console.log(response.data);
98
  //console.log(this.model.attributes);
99
  modal.model.set(response.data);
100
  modal.render();
@@ -170,10 +174,16 @@
170
  name = $field.attr('name'),
171
  value = $field.val();
172
 
 
 
 
 
 
 
173
  this.model.attributes[name] = value;
174
  this.model.changed[name] = value;
175
 
176
- this.render();
177
  },
178
  close: function (e) {
179
  e.preventDefault();
@@ -186,17 +196,21 @@
186
  e.preventDefault();
187
 
188
  var modal = this,
189
- $form = $(e.target),
190
  $modal = modal.$el.find('#wooccm_modal'),
191
  $details = $modal.find('.attachment-details');
192
 
 
 
 
 
193
  $.ajax({
194
  url: wooccm_admin.ajax_url,
195
  data: {
196
  action: 'wooccm_save_field',
197
  nonce: wooccm_admin.nonce,
198
- field_id: this.model.attributes.id,
199
- field_data: $form.serializeArrayAll()
200
  },
201
  dataType: 'json',
202
  type: 'POST',
@@ -214,14 +228,17 @@
214
  },
215
  success: function (response) {
216
  if (response.success) {
 
217
 
218
  if (response.data.id != modal.model.attributes.id) {
219
  location.reload();
220
- //modal.model.set(response.data);
221
- //modal.render();
222
- //$('table.form-table').trigger('wooccm-panel-reload');
223
  }
224
 
 
 
 
 
225
  } else {
226
  alert(response.data);
227
  }
36
  'click .media-modal-prev': 'edit',
37
  'click .media-modal-next': 'edit',
38
  //'click .media-modal-tab': 'tab',
39
+ 'change input': 'change',
40
+ 'change textarea': 'change',
41
+ 'change select': 'change',
42
+ //render before change and update model
43
+ 'change .media-modal-change': 'render',
44
  'submit .media-modal-form': 'save',
45
  },
46
  templates: {},
98
  },
99
  success: function (response) {
100
  if (response.success) {
101
+ //console.log(response.data);
102
  //console.log(this.model.attributes);
103
  modal.model.set(response.data);
104
  modal.render();
174
  name = $field.attr('name'),
175
  value = $field.val();
176
 
177
+ if (e.target.type === 'checkbox') {
178
+ value = $field.prop('checked') === true ? 1 : 0;
179
+ }
180
+
181
+ //alert(value);
182
+
183
  this.model.attributes[name] = value;
184
  this.model.changed[name] = value;
185
 
186
+ //this.render();
187
  },
188
  close: function (e) {
189
  e.preventDefault();
196
  e.preventDefault();
197
 
198
  var modal = this,
199
+ //$form = $(e.target),
200
  $modal = modal.$el.find('#wooccm_modal'),
201
  $details = $modal.find('.attachment-details');
202
 
203
+ //console.log($form.serializeArrayAll());
204
+ //console.log($form.serialize());
205
+ //console.log(modal.model.attributes);
206
+
207
  $.ajax({
208
  url: wooccm_admin.ajax_url,
209
  data: {
210
  action: 'wooccm_save_field',
211
  nonce: wooccm_admin.nonce,
212
+ field_id: modal.model.attributes.id,
213
+ field_data: modal.model.attributes//$form.serializeArrayAll()
214
  },
215
  dataType: 'json',
216
  type: 'POST',
228
  },
229
  success: function (response) {
230
  if (response.success) {
231
+ //console.log(response.data);
232
 
233
  if (response.data.id != modal.model.attributes.id) {
234
  location.reload();
235
+ return;
 
 
236
  }
237
 
238
+ //re-render dont load select2 saved options
239
+ //modal.model.set(response.data);
240
+ //modal.render();
241
+
242
  } else {
243
  alert(response.data);
244
  }
assets/js/wooccm-modal.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){var g=0,b;var d=function(j){return j.is(".processing")||j.parents(".processing").length};var c=function(j){if(!d(j)){j.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var f=function(j){j.removeClass("processing").unblock()};var h=Backbone.Model.extend({defaults:wooccm_admin.field.args});var i=Backbone.View.extend({events:{"click .media-modal-backdrop":"close","click .media-modal-close":"close","click .media-modal-prev":"edit","click .media-modal-next":"edit","change .media-modal-change":"change","submit .media-modal-form":"save",},templates:{},initialize:function(){_.bindAll(this,"open","edit","change","load","render","close","save");this.init();this.open()},init:function(){this.templates.window=wp.template("wooccm-modal-window")},render:function(){var k=this;var j=this.$el.find("ul.wc-tabs li.active a").attr("href");k.$el.html(k.templates.window(k.model.attributes));_.delay(function(){k.$el.trigger("wooccm-enhanced-select");k.$el.trigger("wooccm-tab-panels",j);k.$el.trigger("init_tooltips")},100)},load:function(){var j=this;if(j.model.attributes.id==undefined){j.render();return}e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_load_field",nonce:wooccm_admin.nonce,field_id:this.model.attributes.id},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(k){if(k.success){console.log(k.data);j.model.set(k.data);j.render()}else{alert(k.data)}}})},edit:function(n){n.preventDefault();var l=this,m=e(n.target),k=parseInt(e(".wc_gateways tr[data-field_id]").length-1),j=parseInt(l.model.get("id"));g++;if(b){clearTimeout(b)}b=setTimeout(function(){if(m.hasClass("media-modal-next")){j=Math.min(j+g,k)}else{j=Math.max(j-g,0)}l.model.set({id:j});g=0;l.load()},300)},open:function(j){this.load();e("body").addClass("modal-open").append(this.$el)},change:function(m){m.preventDefault();var k=e(m.target),j=k.attr("name"),l=k.val();this.model.attributes[j]=l;this.model.changed[j]=l;this.render()},close:function(j){j.preventDefault();this.undelegateEvents();e(document).off("focusin");e("body").removeClass("modal-open");this.remove()},save:function(n){n.preventDefault();var m=this,k=e(n.target),l=m.$el.find("#wooccm_modal"),j=l.find(".attachment-details");e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_save_field",nonce:wooccm_admin.nonce,field_id:this.model.attributes.id,field_data:k.serializeArrayAll()},dataType:"json",type:"POST",beforeSend:function(){j.addClass("save-waiting");c(l)},complete:function(){j.addClass("save-complete");j.removeClass("save-waiting");f(l)},error:function(){alert("Error!")},success:function(o){if(o.success){if(o.data.id!=m.model.attributes.id){location.reload()}}else{alert(o.data)}}});return false}});var a=Backbone.View.extend({initialize:function(m){var l=e(m.target),k=l.closest("[data-field_id]").data("field_id");var j=new h();j.set({id:k});new i({model:j})},});e("#wooccm_billing_settings_add, #wooccm_shipping_settings_add, #wooccm_additional_settings_add").on("click",function(j){j.preventDefault();new a(j)});e(".wooccm_billing_settings_edit, .wooccm_shipping_settings_edit, .wooccm_additional_settings_edit").on("click",function(j){j.preventDefault();new a(j)});e(".wooccm_billing_settings_delete, .wooccm_shipping_settings_delete, .wooccm_additional_settings_delete").on("click",function(m){m.preventDefault();var l=e(m.target),k=l.closest("[data-field_id]"),j=k.data("field_id");var n=confirm(wooccm_admin.message.remove);if(!n){return false}e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_delete_field",nonce:wooccm_admin.nonce,field_id:j,},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(o){if(o.success){k.remove()}else{alert(o.data)}}});return false})})(jQuery);
1
+ (function(e){var g=0,b;var d=function(j){return j.is(".processing")||j.parents(".processing").length};var c=function(j){if(!d(j)){j.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var f=function(j){j.removeClass("processing").unblock()};var h=Backbone.Model.extend({defaults:wooccm_admin.field.args});var i=Backbone.View.extend({events:{"click .media-modal-backdrop":"close","click .media-modal-close":"close","click .media-modal-prev":"edit","click .media-modal-next":"edit","change input":"change","change textarea":"change","change select":"change","change .media-modal-change":"render","submit .media-modal-form":"save",},templates:{},initialize:function(){_.bindAll(this,"open","edit","change","load","render","close","save");this.init();this.open()},init:function(){this.templates.window=wp.template("wooccm-modal-window")},render:function(){var k=this;var j=this.$el.find("ul.wc-tabs li.active a").attr("href");k.$el.html(k.templates.window(k.model.attributes));_.delay(function(){k.$el.trigger("wooccm-enhanced-select");k.$el.trigger("wooccm-tab-panels",j);k.$el.trigger("init_tooltips")},100)},load:function(){var j=this;if(j.model.attributes.id==undefined){j.render();return}e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_load_field",nonce:wooccm_admin.nonce,field_id:this.model.attributes.id},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(k){if(k.success){j.model.set(k.data);j.render()}else{alert(k.data)}}})},edit:function(n){n.preventDefault();var l=this,m=e(n.target),k=parseInt(e(".wc_gateways tr[data-field_id]").length-1),j=parseInt(l.model.get("id"));g++;if(b){clearTimeout(b)}b=setTimeout(function(){if(m.hasClass("media-modal-next")){j=Math.min(j+g,k)}else{j=Math.max(j-g,0)}l.model.set({id:j});g=0;l.load()},300)},open:function(j){this.load();e("body").addClass("modal-open").append(this.$el)},change:function(m){m.preventDefault();var k=e(m.target),j=k.attr("name"),l=k.val();if(m.target.type==="checkbox"){l=k.prop("checked")===true?1:0}this.model.attributes[j]=l;this.model.changed[j]=l},close:function(j){j.preventDefault();this.undelegateEvents();e(document).off("focusin");e("body").removeClass("modal-open");this.remove()},save:function(m){m.preventDefault();var l=this,k=l.$el.find("#wooccm_modal"),j=k.find(".attachment-details");e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_save_field",nonce:wooccm_admin.nonce,field_id:l.model.attributes.id,field_data:l.model.attributes},dataType:"json",type:"POST",beforeSend:function(){j.addClass("save-waiting");c(k)},complete:function(){j.addClass("save-complete");j.removeClass("save-waiting");f(k)},error:function(){alert("Error!")},success:function(n){if(n.success){if(n.data.id!=l.model.attributes.id){location.reload();return}}else{alert(n.data)}}});return false}});var a=Backbone.View.extend({initialize:function(m){var l=e(m.target),k=l.closest("[data-field_id]").data("field_id");var j=new h();j.set({id:k});new i({model:j})},});e("#wooccm_billing_settings_add, #wooccm_shipping_settings_add, #wooccm_additional_settings_add").on("click",function(j){j.preventDefault();new a(j)});e(".wooccm_billing_settings_edit, .wooccm_shipping_settings_edit, .wooccm_additional_settings_edit").on("click",function(j){j.preventDefault();new a(j)});e(".wooccm_billing_settings_delete, .wooccm_shipping_settings_delete, .wooccm_additional_settings_delete").on("click",function(m){m.preventDefault();var l=e(m.target),k=l.closest("[data-field_id]"),j=k.data("field_id");var n=confirm(wooccm_admin.message.remove);if(!n){return false}e.ajax({url:wooccm_admin.ajax_url,data:{action:"wooccm_delete_field",nonce:wooccm_admin.nonce,field_id:j,},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(o){if(o.success){k.remove()}else{alert(o.data)}}});return false})})(jQuery);
changelog.txt DELETED
@@ -1,25 +0,0 @@
1
- Fifteen ( 15 ) fields types included: Text Input, Text Area, Password, Radio Button, Check Box, Select Options, Date Picker, Time Picker, Color Picker, Heading, Multi-Select, Multi-Checkbox, Country, State, File Picker.
2
-
3
- Compatible with WPML, WooCommerce Print Invoice & Delivery Note, Store Exporter Deluxe, WooCommerce Order/Customer CSV Export.
4
-
5
- Sort Orders by Field Name.
6
- Export Orders by Field Name.
7
-
8
- Create fields to remove tax
9
- Create fields to add additional amount
10
- Display Payment Method and Shipping Method used by customer.
11
- Disable any added field from Checkout details page and Order Receipt.
12
-
13
- DatePicker: Change the default format (dd-mm-yy), Set Minimum Date and Maximum Date, Disable days in the week (Sun – Sat).
14
- TimePicker: Includes restriction of both start and end hours, set the minutes interval and manually input labels.
15
- Display Order Time.
16
-
17
- Re-position the added fields: Before Shipping Form, After Shipping Form, Before Billing Form, After Billing Form or After Order Notes
18
-
19
- = 4.4.0 Beta =
20
- * Improvement: woocommerce order upload rebuilt
21
- * Improvement: woocommerce checkout upload rebuilt
22
- * Improvement: woocommerce order admin upload rebuilt
23
- * Improvement: woocommerce register fields rebuilt
24
- * Improvement: woocommerce register fields rebuilt
25
- * Fix: woocommerce checkout additional fields required
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
new/controller/class-field-controller.php CHANGED
@@ -148,7 +148,7 @@ class WOOCCM_Field_Controller {
148
 
149
  $field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
150
 
151
- if ($field = self::get_modal_field($field_id)) {
152
  wp_send_json_success($field);
153
  }
154
 
@@ -351,11 +351,12 @@ class WOOCCM_Field_Controller {
351
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/register.php' );
352
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/additional.php' );
353
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/display.php' );
 
354
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/conditional.php' );
355
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/handler.php' );
356
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/filters.php' );
357
 
358
- //$this->field = new WOOCCM_Field();
359
  $this->billing = new WOOCCM_Field_Billing();
360
  $this->shipping = new WOOCCM_Field_Shipping();
361
  $this->additional = new WOOCCM_Field_Additional();
148
 
149
  $field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
150
 
151
+ if ($field = $this->get_modal_field($field_id)) {
152
  wp_send_json_success($field);
153
  }
154
 
351
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/register.php' );
352
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/additional.php' );
353
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/display.php' );
354
+ //include_once( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/additional_display.php' );
355
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/conditional.php' );
356
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/handler.php' );
357
  include_once( WOOCCM_PLUGIN_DIR . 'new/view/frontend/fields/filters.php' );
358
 
359
+ //$this->field = new WOOCCM_Field();
360
  $this->billing = new WOOCCM_Field_Billing();
361
  $this->shipping = new WOOCCM_Field_Shipping();
362
  $this->additional = new WOOCCM_Field_Additional();
new/model/class-wooccm-field-additional.php CHANGED
@@ -4,14 +4,9 @@ if (!class_exists('WOOCCM_Field_Additional')) {
4
 
5
  class WOOCCM_Field_Additional extends WOOCCM_Field_Compatibility {
6
 
7
- const PREFIX = 'additional';
8
- const OPTION_NAME = 'wccs_settings';
9
-
10
- public $default = array();
11
-
12
- public function get_defaults() {
13
- return $this->default;
14
- }
15
 
16
  }
 
17
  }
4
 
5
  class WOOCCM_Field_Additional extends WOOCCM_Field_Compatibility {
6
 
7
+ protected $prefix = 'additional';
8
+ protected $option_name = 'wccs_settings';
 
 
 
 
 
 
9
 
10
  }
11
+
12
  }
new/model/class-wooccm-field-billing.php CHANGED
@@ -4,10 +4,9 @@ if (!class_exists('WOOCCM_Field_Billing')) {
4
 
5
  class WOOCCM_Field_Billing extends WOOCCM_Field_Compatibility {
6
 
7
- const PREFIX = 'billing';
8
- const OPTION_NAME = 'wccs_settings3';
9
-
10
- public $default = array(
11
  'country',
12
  'first_name',
13
  'last_name',
@@ -21,9 +20,6 @@ if (!class_exists('WOOCCM_Field_Billing')) {
21
  'phone'
22
  );
23
 
24
- public function get_defaults() {
25
- return $this->default;
26
- }
27
-
28
  }
 
29
  }
4
 
5
  class WOOCCM_Field_Billing extends WOOCCM_Field_Compatibility {
6
 
7
+ protected $prefix = 'billing';
8
+ protected $option_name = 'wccs_settings3';
9
+ protected $defaults = array(
 
10
  'country',
11
  'first_name',
12
  'last_name',
20
  'phone'
21
  );
22
 
 
 
 
 
23
  }
24
+
25
  }
new/model/class-wooccm-field-old.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  class WOOCCM_Field_Compatibility extends WOOCCM_Field {
4
 
5
- const PREFIX = '';
6
- const OPTION_NAME = '';
7
-
8
  private $old_to_old_types = array(
9
  'heading' => 'heading',
10
  'text' => 'wooccmtext',
@@ -151,11 +151,11 @@ class WOOCCM_Field_Compatibility extends WOOCCM_Field {
151
 
152
  $fields = array();
153
 
154
- if (static::PREFIX) {
155
 
156
- foreach (WC()->countries->get_address_fields('', static::PREFIX) as $key => $field) {
157
 
158
- $field['name'] = str_replace(static::PREFIX, '', $key);
159
 
160
  $fields[] = $field;
161
  }
@@ -202,7 +202,7 @@ class WOOCCM_Field_Compatibility extends WOOCCM_Field {
202
 
203
  function array_to_string($value) {
204
 
205
- if (!empty($value) && is_array($value)) {
206
  if (count($value)) {
207
  $value = implode('||', $value);
208
  } else {
@@ -273,7 +273,7 @@ class WOOCCM_Field_Compatibility extends WOOCCM_Field {
273
  }
274
 
275
  if (!isset($field['key'])) {
276
- $field['key'] = $this->get_key(static::PREFIX, $field['name']);
277
  }
278
 
279
  if ($field['type'] == 'colorpicker' && !empty($field['colorpickerd'])) {
@@ -432,10 +432,17 @@ class WOOCCM_Field_Compatibility extends WOOCCM_Field {
432
 
433
  public function update_fields($fields) {
434
 
435
- if (is_array($fields) && array_key_exists('name', $fields[0])) {
 
 
436
 
437
  // save in old format
438
  foreach ($fields as $field_id => $field) {
 
 
 
 
 
439
  $fields[$field_id] = $this->old_panel_compatibility($field_id, $field);
440
  }
441
 
@@ -522,17 +529,17 @@ class WOOCCM_Field_Compatibility extends WOOCCM_Field {
522
 
523
  protected function update_option($fields) {
524
 
525
- $options = get_option(static::OPTION_NAME, array());
526
 
527
  // Additional compatibility with 4.x
528
  // ---------------------------------------------------------------------
529
- if (static::OPTION_NAME == 'wccs_settings') {
530
  $options['buttons'] = $fields;
531
  } else {
532
- $options[static::PREFIX . '_buttons'] = $fields;
533
  }
534
 
535
- update_option(static::OPTION_NAME, $options);
536
 
537
  return true;
538
  }
2
 
3
  class WOOCCM_Field_Compatibility extends WOOCCM_Field {
4
 
5
+ protected $prefix = '';
6
+ protected $option_name = '';
7
+ protected $defaults = array();
8
  private $old_to_old_types = array(
9
  'heading' => 'heading',
10
  'text' => 'wooccmtext',
151
 
152
  $fields = array();
153
 
154
+ if ($this->prefix) {
155
 
156
+ foreach (WC()->countries->get_address_fields('', $this->prefix) as $key => $field) {
157
 
158
+ $field['name'] = str_replace($this->prefix, '', $key);
159
 
160
  $fields[] = $field;
161
  }
202
 
203
  function array_to_string($value) {
204
 
205
+ if (is_array($value)) {
206
  if (count($value)) {
207
  $value = implode('||', $value);
208
  } else {
273
  }
274
 
275
  if (!isset($field['key'])) {
276
+ $field['key'] = $this->get_key($this->prefix, $field['name']);
277
  }
278
 
279
  if ($field['type'] == 'colorpicker' && !empty($field['colorpickerd'])) {
432
 
433
  public function update_fields($fields) {
434
 
435
+ //error_log(json_encode($fields));
436
+
437
+ if (is_array($fields)) {
438
 
439
  // save in old format
440
  foreach ($fields as $field_id => $field) {
441
+
442
+ if (!array_key_exists('name', $field)) {
443
+ return false;
444
+ }
445
+
446
  $fields[$field_id] = $this->old_panel_compatibility($field_id, $field);
447
  }
448
 
529
 
530
  protected function update_option($fields) {
531
 
532
+ $options = get_option($this->option_name, array());
533
 
534
  // Additional compatibility with 4.x
535
  // ---------------------------------------------------------------------
536
+ if ($this->option_name == 'wccs_settings') {
537
  $options['buttons'] = $fields;
538
  } else {
539
+ $options[$this->prefix . '_buttons'] = $fields;
540
  }
541
 
542
+ update_option($this->option_name, $options);
543
 
544
  return true;
545
  }
new/model/class-wooccm-field-shipping.php CHANGED
@@ -4,10 +4,9 @@ if (!class_exists('WOOCCM_Field_Shipping')) {
4
 
5
  class WOOCCM_Field_Shipping extends WOOCCM_Field_Compatibility {
6
 
7
- const PREFIX = 'shipping';
8
- const OPTION_NAME = 'wccs_settings2';
9
-
10
- public $default = array(
11
  'country',
12
  'first_name',
13
  'last_name',
@@ -19,9 +18,6 @@ if (!class_exists('WOOCCM_Field_Shipping')) {
19
  'postcode',
20
  );
21
 
22
- public function get_defaults() {
23
- return $this->default;
24
- }
25
-
26
  }
 
27
  }
4
 
5
  class WOOCCM_Field_Shipping extends WOOCCM_Field_Compatibility {
6
 
7
+ protected $prefix = 'shipping';
8
+ protected $option_name = 'wccs_settings2';
9
+ protected $defaults = array(
 
10
  'country',
11
  'first_name',
12
  'last_name',
18
  'postcode',
19
  );
20
 
 
 
 
 
21
  }
22
+
23
  }
new/model/class-wooccm-field.php CHANGED
@@ -2,13 +2,9 @@
2
 
3
  class WOOCCM_Field {
4
 
5
- const PREFIX = '';
6
- const OPTION_NAME = '';
7
-
8
- function __construct() {
9
- $this->prefix = static::PREFIX;
10
- $this->option_name = static::OPTION_NAME;
11
- }
12
 
13
  protected function order_fields($a, $b) {
14
 
@@ -142,4 +138,8 @@ class WOOCCM_Field {
142
  );
143
  }
144
 
 
 
 
 
145
  }
2
 
3
  class WOOCCM_Field {
4
 
5
+ protected $prefix = '';
6
+ protected $option_name = '';
7
+ protected $defaults = array();
 
 
 
 
8
 
9
  protected function order_fields($a, $b) {
10
 
138
  );
139
  }
140
 
141
+ public function get_defaults() {
142
+ return $this->defaults;
143
+ }
144
+
145
  }
new/view/backend/pages/modals/parts/panel-display.php CHANGED
@@ -25,14 +25,14 @@
25
  <div class="options_group">
26
  <p class="form-field">
27
  <label><?php esc_html_e('More', 'woocommerce-checkout-manager'); ?></label>
28
- <input <# if ( data.more_product == 'true' ) { #>checked<# } #> type="checkbox" name="more_product" value="true">
29
  <span class="description"><?php esc_html_e('Apply conditions event it there is more than one product', 'woocommerce-checkout-manager'); ?></span>
30
  </p>
31
  </div>
32
 
33
  <div class="options_group">
34
  <p class="form-field">
35
- <label><?php esc_html_e('Hide for products', 'woocommerce-checkout-manager'); ?></label>
36
  <select class="wooccm-product-search" name="show_product" data-placeholder="<?php esc_attr_e('Filter by product', 'woocommerce-checkout-manager'); ?>" data-selected="{{data.show_product}}" data-allow_clear="true" multiple="multiple">
37
  <# _.each(data.show_product_selected, function(title, id){ #>
38
  <option value="{{id}}" selected="selected">{{title}}</option>
@@ -40,7 +40,7 @@
40
  </select>
41
  </p>
42
  <p class="form-field">
43
- <label><?php esc_html_e('Show for products', 'woocommerce-checkout-manager'); ?></label>
44
  <select class="wooccm-product-search" name="hide_product" data-placeholder="<?php esc_attr_e('Filter by product', 'woocommerce-checkout-manager'); ?>" data-selected="{{data.hide_product}}" data-allow_clear="true" multiple="multiple">
45
  <# _.each(data.hide_product_selected, function(title, id){ #>
46
  <option value="{{id}}" selected="selected">{{title}}</option>
25
  <div class="options_group">
26
  <p class="form-field">
27
  <label><?php esc_html_e('More', 'woocommerce-checkout-manager'); ?></label>
28
+ <input <# if ( data.more_product == 1 ) { #>checked<# } #> type="checkbox" name="more_product" value="1">
29
  <span class="description"><?php esc_html_e('Apply conditions event it there is more than one product', 'woocommerce-checkout-manager'); ?></span>
30
  </p>
31
  </div>
32
 
33
  <div class="options_group">
34
  <p class="form-field">
35
+ <label><?php esc_html_e('Show for products', 'woocommerce-checkout-manager'); ?></label>
36
  <select class="wooccm-product-search" name="show_product" data-placeholder="<?php esc_attr_e('Filter by product', 'woocommerce-checkout-manager'); ?>" data-selected="{{data.show_product}}" data-allow_clear="true" multiple="multiple">
37
  <# _.each(data.show_product_selected, function(title, id){ #>
38
  <option value="{{id}}" selected="selected">{{title}}</option>
40
  </select>
41
  </p>
42
  <p class="form-field">
43
+ <label><?php esc_html_e('Hide for products', 'woocommerce-checkout-manager'); ?></label>
44
  <select class="wooccm-product-search" name="hide_product" data-placeholder="<?php esc_attr_e('Filter by product', 'woocommerce-checkout-manager'); ?>" data-selected="{{data.hide_product}}" data-allow_clear="true" multiple="multiple">
45
  <# _.each(data.hide_product_selected, function(title, id){ #>
46
  <option value="{{id}}" selected="selected">{{title}}</option>
new/view/frontend/fields/additional.php CHANGED
@@ -20,50 +20,41 @@ if (!class_exists('WOOCCM_Fields_Additional')) {
20
  return false;
21
  }
22
 
23
- function add_checkout_fields_required($fields, $name, $key, $prefix = '') {
24
-
25
- if ($options = get_option($name)) {
26
 
27
- if (array_key_exists($key, $options)) {
28
 
29
- if ($custom_fields = $options[$key]) {
30
 
31
- foreach ($custom_fields as $id => $custom_field) {
32
 
33
- $key = sprintf("%s%s", $prefix, $custom_field['cow']);
34
 
35
- $custom_field = $this->add_checkout_field_filter($key, $custom_fields, $custom_field);
36
 
37
- if (!empty($custom_field['required']) && !empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
38
 
39
- if (empty($_POST[$custom_field['cow']])) {
40
- $message = sprintf(__('%s is a required field.', 'woocommerce-checkout-manager'), '<strong>' . wooccm_wpml_string($custom_field['label']) . '</strong>');
41
- wc_add_notice($message, 'error');
42
- }
43
  }
44
  }
45
  }
46
  }
47
  }
48
-
49
- return $fields;
50
- }
51
-
52
- function add_checkout_additional_required($fields) {
53
- return $this->add_checkout_fields_required($fields, 'wccs_settings', 'buttons');
54
  }
55
 
56
  function add_checkout_additional_fields($checkout) {
57
 
58
- if ($options = get_option('wccs_settings')) {
59
 
60
- if (array_key_exists('buttons', $options)) {
61
 
62
- if ($buttons = $options['buttons']) {
63
 
64
- foreach ($buttons as $key => $custom_field) {
65
- woocommerce_form_field($custom_field['cow'], $this->add_checkout_field_filter($key, $custom_field, $custom_field, 'additional_'), $checkout->get_value($custom_field['cow']));
66
- }
67
  }
68
  }
69
  }
20
  return false;
21
  }
22
 
23
+ function add_checkout_additional_required($fields) {
 
 
24
 
25
+ if ($fields = WOOCCM()->field->additional->get_fields('old')) {
26
 
27
+ foreach ($fields as $field_id => $field) {
28
 
29
+ if (!empty($field['cow']) && empty($field['deny_checkout'])) {
30
 
31
+ //$key = sprintf("%s_%s", $prefix, $field['cow']);
32
 
33
+ $field = $this->add_checkout_field_filter($fields, $field, 'additional');
34
 
35
+ if (!empty($field['required']) && !empty($field['cow']) && empty($field['deny_checkout']) && empty($field['disabled'])) {
36
 
37
+ if (empty($_POST[$field['cow']])) {
38
+ $message = sprintf(__('%s is a required field.', 'woocommerce-checkout-manager'), '<strong>' . wooccm_wpml_string($field['label']) . '</strong>');
39
+ wc_add_notice($message, 'error');
 
40
  }
41
  }
42
  }
43
  }
44
  }
 
 
 
 
 
 
45
  }
46
 
47
  function add_checkout_additional_fields($checkout) {
48
 
49
+ if ($fields = WOOCCM()->field->additional->get_fields('old')) {
50
 
51
+ foreach ($fields as $field_id => $field) {
52
 
53
+ $field = $this->add_checkout_field_filter($field, $field, 'additional');
54
 
55
+ if (!empty($field['cow']) && empty($field['deny_checkout']) && empty($field['disabled'])) {
56
+
57
+ woocommerce_form_field($field['cow'], $field, $checkout->get_value($field['cow']));
58
  }
59
  }
60
  }
new/view/frontend/fields/display.php CHANGED
@@ -10,24 +10,27 @@ if (!class_exists('WOOCCM_Fields_Display')) {
10
 
11
  global $current_user;
12
 
13
- $user_roles = $current_user->roles;
14
 
15
- $user_role = array_shift($user_roles);
16
-
17
- if (/* !empty($field['user_role']) && */(!empty($field['role_options']) || !empty($field['role_options2']))) {
18
-
19
- $rolekeys = explode('||', $field['role_options']);
20
-
21
- $rolekeys2 = explode('||', $field['role_options2']);
22
 
23
- //error_log(json_encode($rolekeys));
24
 
25
- if (!empty($field['role_options']) && !in_array($user_role, $rolekeys)) {
26
  $field['disabled'] = true;
 
 
27
  }
 
 
 
 
 
28
 
29
- if (!empty($field['role_options2']) && in_array($user_role, $rolekeys2)) {
30
  $field['disabled'] = true;
 
 
31
  }
32
  }
33
 
@@ -66,10 +69,10 @@ if (!class_exists('WOOCCM_Fields_Display')) {
66
  // show field
67
  // -----------------------------------------------------------------
68
  if (!empty($field['single_px_cat'])) {
69
- if (array_intersect($product_cats, $show_cats_array)) {
70
- $field['disabled'] = false;
71
- } else {
72
  $field['disabled'] = true;
 
 
73
  }
74
  }
75
  }
@@ -89,11 +92,10 @@ if (!class_exists('WOOCCM_Fields_Display')) {
89
  // show field
90
  // ---------------------------------------------------------------
91
  if (!empty($field['single_px_cat'])) {
92
- if (array_intersect($product_cats, $show_cats_array)) {
93
- $field['disabled'] = false;
94
- } else {
95
- //error_log('disabled 4');
96
  $field['disabled'] = true;
 
 
97
  }
98
  }
99
  }
@@ -122,6 +124,7 @@ if (!class_exists('WOOCCM_Fields_Display')) {
122
  // -----------------------------------------------------------------
123
  if (!empty($field['single_p'])) {
124
  if (array_intersect($product_ids, $hide_ids_array)) {
 
125
  $field['disabled'] = true;
126
  }
127
  }
@@ -129,10 +132,12 @@ if (!class_exists('WOOCCM_Fields_Display')) {
129
  // show field
130
  // -----------------------------------------------------------------
131
  if (!empty($field['single_px'])) {
132
- if (array_intersect($product_ids, $show_ids_array)) {
133
- $field['disabled'] = false;
134
- } else {
135
  $field['disabled'] = true;
 
 
 
136
  }
137
  }
138
  }
@@ -145,6 +150,7 @@ if (!class_exists('WOOCCM_Fields_Display')) {
145
  // -------------------------------------------------------------
146
  if (!empty($field['single_p'])) {
147
  if (array_intersect($product_ids, $hide_ids_array)) {
 
148
  $field['disabled'] = true;
149
  }
150
  }
@@ -152,11 +158,12 @@ if (!class_exists('WOOCCM_Fields_Display')) {
152
  // show field
153
  // ---------------------------------------------------------------
154
  if (!empty($field['single_px'])) {
155
- if (array_intersect($product_ids, $show_ids_array)) {
156
- $field['disabled'] = false;
157
- } else {
158
- //error_log('disabled 4');
159
  $field['disabled'] = true;
 
 
 
160
  }
161
  }
162
  }
@@ -170,10 +177,8 @@ if (!class_exists('WOOCCM_Fields_Display')) {
170
 
171
  // Remove by product
172
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_product'), 10, 2);
173
-
174
  // Remove by category
175
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_category'), 10, 2);
176
-
177
  // Remove by role
178
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_role'), 10, 2);
179
  }
10
 
11
  global $current_user;
12
 
13
+ $user_roles = (array) $current_user->roles;
14
 
15
+ if (!empty($field['role_option2'])) {
 
 
 
 
 
 
16
 
17
+ $rolekeys2 = explode('||', $field['role_option2']);
18
 
19
+ if (array_intersect($user_roles, $rolekeys2)) {
20
  $field['disabled'] = true;
21
+ } else {
22
+ $field['disabled'] = false;
23
  }
24
+ }
25
+
26
+ if (!empty($field['role_option'])) {
27
+
28
+ $rolekeys = explode('||', $field['role_option']);
29
 
30
+ if (!array_intersect($user_roles, $rolekeys)) {
31
  $field['disabled'] = true;
32
+ } else {
33
+ $field['disabled'] = false;
34
  }
35
  }
36
 
69
  // show field
70
  // -----------------------------------------------------------------
71
  if (!empty($field['single_px_cat'])) {
72
+ if (!array_intersect($product_cats, $show_cats_array)) {
 
 
73
  $field['disabled'] = true;
74
+ } else {
75
+ $field['disabled'] = false;
76
  }
77
  }
78
  }
92
  // show field
93
  // ---------------------------------------------------------------
94
  if (!empty($field['single_px_cat'])) {
95
+ if (!array_intersect($product_cats, $show_cats_array)) {
 
 
 
96
  $field['disabled'] = true;
97
+ } else {
98
+ $field['disabled'] = false;
99
  }
100
  }
101
  }
124
  // -----------------------------------------------------------------
125
  if (!empty($field['single_p'])) {
126
  if (array_intersect($product_ids, $hide_ids_array)) {
127
+ //error_log('more_content:empty, hide on, hidden');
128
  $field['disabled'] = true;
129
  }
130
  }
132
  // show field
133
  // -----------------------------------------------------------------
134
  if (!empty($field['single_px'])) {
135
+ if (!array_intersect($product_ids, $show_ids_array)) {
136
+ //error_log('more_content:empty, show on, hidden');
 
137
  $field['disabled'] = true;
138
+ } else {
139
+ //error_log('more_content:empty, show on, show');
140
+ $field['disabled'] = false;
141
  }
142
  }
143
  }
150
  // -------------------------------------------------------------
151
  if (!empty($field['single_p'])) {
152
  if (array_intersect($product_ids, $hide_ids_array)) {
153
+ //error_log('more_content:true, hide on, hidden');
154
  $field['disabled'] = true;
155
  }
156
  }
158
  // show field
159
  // ---------------------------------------------------------------
160
  if (!empty($field['single_px'])) {
161
+ if (!array_intersect($product_ids, $show_ids_array)) {
162
+ //error_log('more_content:true, show on, hidden');
 
 
163
  $field['disabled'] = true;
164
+ } else {
165
+ //error_log('more_content:true, show on, show');
166
+ $field['disabled'] = false;
167
  }
168
  }
169
  }
177
 
178
  // Remove by product
179
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_product'), 10, 2);
 
180
  // Remove by category
181
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_category'), 10, 2);
 
182
  // Remove by role
183
  add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_role'), 10, 2);
184
  }
new/view/frontend/fields/register.php CHANGED
@@ -6,15 +6,16 @@ if (!class_exists('WOOCCM_Fields_Register')) {
6
 
7
  protected static $instance;
8
 
9
- function add_checkout_field_filter($key, $fields, $custom_field, $prefix = '') {
10
 
 
11
 
12
  $fields[$key] = wp_parse_args($custom_field, (array) @$fields[$key]);
13
 
14
  // Conditonal
15
  // -----------------------------------------------------------------------
16
 
17
- $fields[$key]['conditional_tie'] = sprintf("%s%s_field", $prefix, @$fields[$key]['conditional_tie']);
18
 
19
  // Class
20
  // -----------------------------------------------------------------------
@@ -141,48 +142,70 @@ if (!class_exists('WOOCCM_Fields_Register')) {
141
  return apply_filters('wooccm_checkout_field_filter', $fields[$key], $key);
142
  }
143
 
144
- function add_checkout_fields_filter($fields, $name, $key, $prefix = '') {
145
-
146
- if ($options = get_option($name)) {
147
-
148
- if (array_key_exists($key, $options)) {
149
-
150
- if ($custom_fields = $options[$key]) {
151
-
152
- foreach ($custom_fields as $id => $custom_field) {
153
-
154
- if (!empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
155
-
156
- $key = sprintf("%s%s", $prefix, $custom_field['cow']);
157
-
158
- // Remove disabled fields
159
- //if (!empty($custom_field['disabled'])) {
160
- //unset($fields[$key]);
161
- //} else {
162
- $fields[$key] = $this->add_checkout_field_filter($key, $fields, $custom_field, $prefix);
163
- //}
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
167
  }
168
-
169
- // Resort the fields by order
170
- $fields[] = uasort($fields, 'wooccm_sort_fields');
171
-
172
- if ($fields[0]) {
173
- unset($fields[0]);
174
- }
175
  }
176
 
177
  return $fields;
178
  }
179
 
180
  function add_checkout_shipping_fields($fields) {
181
- return $this->add_checkout_fields_filter($fields, 'wccs_settings2', 'shipping_buttons', 'shipping_');
182
  }
183
 
184
  function add_checkout_billing_fields($fields) {
185
- return $this->add_checkout_fields_filter($fields, 'wccs_settings3', 'billing_buttons', 'billing_');
 
 
 
 
186
  }
187
 
188
  function init() {
@@ -194,6 +217,10 @@ if (!class_exists('WOOCCM_Fields_Register')) {
194
  // Shipping fields
195
  // -----------------------------------------------------------------------
196
  add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
 
 
 
 
197
  }
198
 
199
  public static function instance() {
6
 
7
  protected static $instance;
8
 
9
+ function add_checkout_field_filter($fields, $custom_field, $prefix = '') {
10
 
11
+ $key = sprintf("%s_%s", $prefix, $custom_field['cow']);
12
 
13
  $fields[$key] = wp_parse_args($custom_field, (array) @$fields[$key]);
14
 
15
  // Conditonal
16
  // -----------------------------------------------------------------------
17
 
18
+ $fields[$key]['conditional_tie'] = sprintf("%s_%s_field", $prefix, @$fields[$key]['conditional_tie']);
19
 
20
  // Class
21
  // -----------------------------------------------------------------------
142
  return apply_filters('wooccm_checkout_field_filter', $fields[$key], $key);
143
  }
144
 
145
+ // function add_checkout_fields_filter($fields, $name, $key, $prefix = '') {
146
+ //
147
+ // if ($options = get_option($name)) {
148
+ //
149
+ // if (array_key_exists($key, $options)) {
150
+ //
151
+ // if ($custom_fields = $options[$key]) {
152
+ //
153
+ // foreach ($custom_fields as $id => $custom_field) {
154
+ //
155
+ // if (!empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
156
+ //
157
+ // $key = sprintf("%s%s", $prefix, $custom_field['cow']);
158
+ //
159
+ // // Remove disabled fields
160
+ // //if (!empty($custom_field['disabled'])) {
161
+ // //unset($fields[$key]);
162
+ // //} else {
163
+ // $fields[$key] = $this->add_checkout_field_filter($fields, $custom_field, $prefix);
164
+ // //}
165
+ // }
166
+ // }
167
+ // }
168
+ // }
169
+ //
170
+ //// Resort the fields by order
171
+ // $fields[] = uasort($fields, 'wooccm_sort_fields');
172
+ //
173
+ // if ($fields[0]) {
174
+ // unset($fields[0]);
175
+ // }
176
+ // }
177
+ //
178
+ // return $fields;
179
+ // }
180
+
181
+ function add_checkout_fields_filter($fields, $prefix = '') {
182
+
183
+ if ($fields = WOOCCM()->field->$prefix->get_fields('old')) {
184
+
185
+ foreach ($fields as $field_id => $field) {
186
+
187
+ if (!empty($field['cow']) && empty($field['deny_checkout'])) {
188
+
189
+ $key = sprintf("%s_%s", $prefix, $field['cow']);
190
+
191
+ $fields[$key] = $this->add_checkout_field_filter($fields, $field, $prefix);
192
  }
193
  }
 
 
 
 
 
 
 
194
  }
195
 
196
  return $fields;
197
  }
198
 
199
  function add_checkout_shipping_fields($fields) {
200
+ return $this->add_checkout_fields_filter($fields, 'shipping');
201
  }
202
 
203
  function add_checkout_billing_fields($fields) {
204
+ return $this->add_checkout_fields_filter($fields, 'billing');
205
+ }
206
+
207
+ function add_checkout_additional_fields($fields) {
208
+ return $this->add_checkout_fields_filter($fields, 'additional');
209
  }
210
 
211
  function init() {
217
  // Shipping fields
218
  // -----------------------------------------------------------------------
219
  add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
220
+
221
+ // Additional fields
222
+ // -----------------------------------------------------------------------
223
+ add_filter('wooccm_additional_fields', array($this, 'add_checkout_additional_fields'));
224
  }
225
 
226
  public static function instance() {
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.5.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -137,6 +137,12 @@ Example:
137
 
138
  == Changelog ==
139
 
 
 
 
 
 
 
140
  = 4.5.0 =
141
  * Improvement: new woocommerce checkout billing fields admin panel
142
  * Improvement: new woocommerce checkout shipping fields admin panel
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.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
137
 
138
  == Changelog ==
139
 
140
+ = 4.5.1 =
141
+ * Fix: woocommerce first additional field delete in admin
142
+ * Fix: woocommerce billing field disable
143
+ * Fix: woocommerce shipping field disable
144
+ * Fix: woocommerce additional field disable
145
+
146
  = 4.5.0 =
147
  * Improvement: new woocommerce checkout billing fields admin panel
148
  * Improvement: new woocommerce checkout shipping fields admin panel
woocommerce-checkout-manager.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Plugin Name: WooCommerce Checkout Manager
5
  * Description: Manages WooCommerce Checkout, the advanced way.
6
- * Version: 4.5.0
7
  * Author: QuadLayers
8
  * Author URI: https://www.quadlayers.com
9
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
@@ -17,7 +17,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
17
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
18
  }
19
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
20
- define('WOOCCM_PLUGIN_VERSION', '4.5.0');
21
  }
22
  if (!defined('WOOCCM_PLUGIN_FILE')) {
23
  define('WOOCCM_PLUGIN_FILE', __FILE__);
3
  /**
4
  * Plugin Name: WooCommerce Checkout Manager
5
  * Description: Manages WooCommerce Checkout, the advanced way.
6
+ * Version: 4.5.1
7
  * Author: QuadLayers
8
  * Author URI: https://www.quadlayers.com
9
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
17
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
18
  }
19
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
20
+ define('WOOCCM_PLUGIN_VERSION', '4.5.1');
21
  }
22
  if (!defined('WOOCCM_PLUGIN_FILE')) {
23
  define('WOOCCM_PLUGIN_FILE', __FILE__);