WooCommerce Checkout Manager - Version 4.4.8

Version Description

  • Improvement: backward compatibility with new panel
Download this release

Release Info

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

Code changes from version 4.4.6 to 4.4.8

Files changed (37) hide show
  1. assets/css/wooccm-admin.css +18 -0
  2. assets/css/wooccm-admin.css.map +1 -0
  3. assets/js/wooccm-admin.js +142 -40
  4. assets/js/wooccm-admin.min.js +1 -1
  5. assets/js/wooccm-checkout.js +62 -2
  6. assets/js/wooccm-checkout.min.js +1 -1
  7. assets/js/wooccm-modal.js +8 -0
  8. assets/js/wooccm-modal.min.js +1 -1
  9. assets/less/wooccm-admin.less +22 -0
  10. changelog.txt +25 -0
  11. includes/classes/field_filters.php +0 -966
  12. includes/templates/admin/woocheckout-additional-tbody.php +74 -74
  13. includes/templates/admin/woocheckout-additional-thead.php +2 -2
  14. includes/templates/admin/woocheckout-additional.php +39 -46
  15. includes/templates/admin/woocheckout-billing-tbody.php +72 -72
  16. includes/templates/admin/woocheckout-billing-thead.php +2 -2
  17. includes/templates/admin/woocheckout-billing.php +8 -26
  18. includes/templates/admin/woocheckout-shipping-tbody.php +72 -72
  19. includes/templates/admin/woocheckout-shipping-thead.php +2 -2
  20. includes/templates/admin/woocheckout-shipping.php +75 -81
  21. includes/templates/functions/billing_functions.php +1 -1
  22. new/admin.php +0 -273
  23. new/admin/meta-boxes/html-order-uploads.php +0 -61
  24. new/admin/pages/additional.php +0 -8
  25. new/admin/pages/advanced.php +0 -29
  26. new/admin/pages/billing.php +0 -646
  27. new/admin/pages/general.php +0 -133
  28. new/admin/pages/orders.php +0 -8
  29. new/admin/pages/shipping.php +0 -8
  30. new/checkout.php +0 -8
  31. new/fields_conditional.php +12 -14
  32. new/fields_filters.php +64 -75
  33. new/fields_handler.php +8 -4
  34. new/fields_init.php +311 -0
  35. new/fields_register.php +21 -15
  36. readme.txt +7 -1
  37. woocommerce-checkout-manager.php +9 -8
assets/css/wooccm-admin.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .woocommerce_options_panel .select2-container {
2
+ width: 80%!important;
3
+ line-height: 16px;
4
+ }
5
+ .woocommerce_options_panel .select2-container .select2-selection--multiple {
6
+ line-height: 16px;
7
+ min-height: 30px;
8
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
9
+ }
10
+ .woocommerce_options_panel .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
11
+ margin: 3px 3px 0 0;
12
+ }
13
+ .woocommerce_options_panel .select2-container--default.select2-container--focus .select2-selection--multiple {
14
+ border-color: #5b9dd9!important;
15
+ box-shadow: 0 0 2px rgba(30, 140, 190, 0.8) !important;
16
+ outline: 2px solid transparent!important;
17
+ }
18
+ /*# sourceMappingURL=wooccm-admin.css.map */
assets/css/wooccm-admin.css.map ADDED
@@ -0,0 +1 @@
 
1
+ {"version":3,"sources":["../less/wooccm-admin.less"],"names":[],"mappings":"AAAA,0BACE;EACE,oBAAA;EACA,iBAAA;;AAHJ,0BACE,mBAKE;EACE,iBAAA;EACA,gBAAA;EACA,+CAAA;;AATN,0BAaE,4BAA4B,6BAA6B,6BAA6B;EACpF,mBAAA;;AAdJ,0BAgBE,4BAA2B,yBAA0B;EACnD,+BAAA;EACA,2CAAA;EACA,wCAAA","file":"wooccm-admin.css"}
assets/js/wooccm-admin.js CHANGED
@@ -22,46 +22,148 @@
22
  return o;
23
  };
24
 
25
- /* Toggle gateway on/off.
26
- $('#wooccm_billing_settings_add').on('click', function () {
27
-
28
- var $button = $(this),
29
- $table = $('table#wooccm_billing_fields'),
30
- $tr = $table.find('tbody > tr'),
31
- $new = $tr.last().clone();
32
-
33
- // $table.find('tbody').append($new);
34
-
35
- var data = {
36
- action: 'wooccm_add_field',
37
- nonce: wooccm.nonce,
38
- //field_id: $tr.data('field_id')
39
- };
40
-
41
- $.ajax({
42
- url: woocommerce_admin.ajax_url,
43
- data: data,
44
- dataType: 'json',
45
- type: 'POST',
46
- success: function (response) {
47
-
48
- if (true === response.data) {
49
- //$toggle.removeClass('woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled');
50
- //$toggle.addClass('woocommerce-input-toggle--enabled');
51
- //$toggle.removeClass('woocommerce-input-toggle--loading');
52
- } else if (true !== response.data) {
53
- //$toggle.removeClass('woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled');
54
- //$toggle.addClass('woocommerce-input-toggle--disabled');
55
- //$toggle.removeClass('woocommerce-input-toggle--loading');
56
- } //else if ('needs_setup' === response.data) {
57
- //window.location.href = $link.attr('href');
58
- //}
59
- }
60
- });
61
- return false;
62
- });*/
63
-
64
- $('#wooccm_billing_fields').on('click', '.wooccm-field-toggle-enabled', function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  var $link = $(this),
67
  $tr = $link.closest('tr'),
22
  return o;
23
  };
24
 
25
+ function getEnhancedSelectFormatString() {
26
+ return {
27
+ 'language': {
28
+ errorLoading: function () {
29
+ // Workaround for https://github.com/select2/select2/issues/4355 instead of i18n_ajax_error.
30
+ return wc_enhanced_select_params.i18n_searching;
31
+ },
32
+ inputTooLong: function (args) {
33
+ var overChars = args.input.length - args.maximum;
34
+
35
+ if (1 === overChars) {
36
+ return wc_enhanced_select_params.i18n_input_too_long_1;
37
+ }
38
+
39
+ return wc_enhanced_select_params.i18n_input_too_long_n.replace('%qty%', overChars);
40
+ },
41
+ inputTooShort: function (args) {
42
+ var remainingChars = args.minimum - args.input.length;
43
+
44
+ if (1 === remainingChars) {
45
+ return wc_enhanced_select_params.i18n_input_too_short_1;
46
+ }
47
+
48
+ return wc_enhanced_select_params.i18n_input_too_short_n.replace('%qty%', remainingChars);
49
+ },
50
+ loadingMore: function () {
51
+ return wc_enhanced_select_params.i18n_load_more;
52
+ },
53
+ maximumSelected: function (args) {
54
+ if (args.maximum === 1) {
55
+ return wc_enhanced_select_params.i18n_selection_too_long_1;
56
+ }
57
+
58
+ return wc_enhanced_select_params.i18n_selection_too_long_n.replace('%qty%', args.maximum);
59
+ },
60
+ noResults: function () {
61
+ return wc_enhanced_select_params.i18n_no_matches;
62
+ },
63
+ searching: function () {
64
+ return wc_enhanced_select_params.i18n_searching;
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ $(document).on('wooccm-enhanced-select', function (e) {
71
+
72
+ $('.wooccm-enhanced-select').filter(':not(.enhanced)').each(function () {
73
+ var select2_args = $.extend({
74
+ minimumResultsForSearch: 10,
75
+ allowClear: $(this).data('allow_clear') ? true : false,
76
+ placeholder: $(this).data('placeholder')
77
+ }, getEnhancedSelectFormatString());
78
+
79
+ $(this).selectWoo(select2_args).addClass('enhanced');
80
+ });
81
+
82
+ $('.wooccm-product-search').filter(':not(.enhanced)').each(function () {
83
+
84
+ var select2_args = {
85
+ allowClear: $(this).data('allow_clear') ? true : false,
86
+ placeholder: $(this).data('placeholder'),
87
+ minimumInputLength: $(this).data('minimum_input_length') ? $(this).data('minimum_input_length') : '3',
88
+ escapeMarkup: function (m) {
89
+ return m;
90
+ },
91
+ ajax: {
92
+ url: wc_enhanced_select_params.ajax_url,
93
+ dataType: 'json',
94
+ delay: 250,
95
+ data: function (params) {
96
+ return {
97
+ term: params.term,
98
+ action: $(this).data('action') || 'wooccm_select_search_products',
99
+ security: wc_enhanced_select_params.search_products_nonce,
100
+ selected: $(this).select2('val') || 0,
101
+ exclude: $(this).data('exclude'),
102
+ include: $(this).data('include'),
103
+ limit: $(this).data('limit'),
104
+ display_stock: $(this).data('display_stock')
105
+ };
106
+ },
107
+ processResults: function (data) {
108
+ var terms = [];
109
+ if (data) {
110
+ $.each(data, function (id, text) {
111
+ terms.push({id: id, text: text});
112
+ });
113
+ }
114
+ return {
115
+ results: terms
116
+ };
117
+ },
118
+ cache: true
119
+ }
120
+ };
121
+
122
+ select2_args = $.extend(select2_args, getEnhancedSelectFormatString());
123
+
124
+ $(this).selectWoo(select2_args).addClass('enhanced');
125
+
126
+ if ($(this).data('sortable')) {
127
+ var $select = $(this);
128
+ var $list = $(this).next('.select2-container').find('ul.select2-selection__rendered');
129
+
130
+ $list.sortable({
131
+ placeholder: 'ui-state-highlight select2-selection__choice',
132
+ forcePlaceholderSize: true,
133
+ items: 'li:not(.select2-search__field)',
134
+ tolerance: 'pointer',
135
+ stop: function () {
136
+ $($list.find('.select2-selection__choice').get().reverse()).each(function () {
137
+ var id = $(this).data('data').id;
138
+ var option = $select.find('option[value="' + id + '"]')[0];
139
+ $select.prepend(option);
140
+ });
141
+ }
142
+ });
143
+ // Keep multiselects ordered alphabetically if they are not sortable.
144
+ } else if ($(this).prop('multiple')) {
145
+ $(this).on('change', function () {
146
+ var $children = $(this).children();
147
+ $children.sort(function (a, b) {
148
+ var atext = a.text.toLowerCase();
149
+ var btext = b.text.toLowerCase();
150
+
151
+ if (atext > btext) {
152
+ return 1;
153
+ }
154
+ if (atext < btext) {
155
+ return -1;
156
+ }
157
+ return 0;
158
+ });
159
+ $(this).html($children);
160
+ });
161
+ }
162
+ });
163
+
164
+ });
165
+
166
+ $(document).on('click', '.wooccm-field-toggle-enabled', function () {
167
 
168
  var $link = $(this),
169
  $tr = $link.closest('tr'),
assets/js/wooccm-admin.min.js CHANGED
@@ -1 +1 @@
1
- (function(a){a.fn.serializeArrayAll=function(){var d={};var c=this.serializeArray();a.each(c,function(){if(d[this.name]!==undefined){if(!d[this.name].push){d[this.name]=[d[this.name]]}d[this.name].push(this.value||"")}else{d[this.name]=this.value||""}});var b=a("input[type=radio],input[type=checkbox]",this);a.each(b,function(){if(!d.hasOwnProperty(this.name)){d[this.name]=""}});return d};a("#wooccm_billing_fields").on("click",".wooccm-field-toggle-enabled",function(){var b=a(this),d=b.closest("tr"),c=b.find(".woocommerce-input-toggle");a.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_toggle_field_enabled",nonce:wooccm.nonce,field_id:d.data("field_id")},dataType:"json",type:"POST",beforeSend:function(e){c.addClass("woocommerce-input-toggle--loading")},success:function(e){if(true===e.data){c.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled");c.addClass("woocommerce-input-toggle--enabled");c.removeClass("woocommerce-input-toggle--loading")}else{if(true!==e.data){c.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled");c.addClass("woocommerce-input-toggle--disabled");c.removeClass("woocommerce-input-toggle--loading")}}}});return false})})(jQuery);
1
+ (function(b){b.fn.serializeArrayAll=function(){var e={};var d=this.serializeArray();b.each(d,function(){if(e[this.name]!==undefined){if(!e[this.name].push){e[this.name]=[e[this.name]]}e[this.name].push(this.value||"")}else{e[this.name]=this.value||""}});var c=b("input[type=radio],input[type=checkbox]",this);b.each(c,function(){if(!e.hasOwnProperty(this.name)){e[this.name]=""}});return e};function a(){return{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(c){var d=c.input.length-c.maximum;if(1===d){return wc_enhanced_select_params.i18n_input_too_long_1}return wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",d)},inputTooShort:function(c){var d=c.minimum-c.input.length;if(1===d){return wc_enhanced_select_params.i18n_input_too_short_1}return wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",d)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(c){if(c.maximum===1){return wc_enhanced_select_params.i18n_selection_too_long_1}return wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",c.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}}}b(document).on("wooccm-enhanced-select",function(c){b(".wooccm-enhanced-select").filter(":not(.enhanced)").each(function(){var d=b.extend({minimumResultsForSearch:10,allowClear:b(this).data("allow_clear")?true:false,placeholder:b(this).data("placeholder")},a());b(this).selectWoo(d).addClass("enhanced")});b(".wooccm-product-search").filter(":not(.enhanced)").each(function(){var f={allowClear:b(this).data("allow_clear")?true:false,placeholder:b(this).data("placeholder"),minimumInputLength:b(this).data("minimum_input_length")?b(this).data("minimum_input_length"):"3",escapeMarkup:function(g){return g},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(g){return{term:g.term,action:b(this).data("action")||"wooccm_select_search_products",security:wc_enhanced_select_params.search_products_nonce,selected:b(this).select2("val")||0,exclude:b(this).data("exclude"),include:b(this).data("include"),limit:b(this).data("limit"),display_stock:b(this).data("display_stock")}},processResults:function(h){var g=[];if(h){b.each(h,function(j,i){g.push({id:j,text:i})})}return{results:g}},cache:true}};f=b.extend(f,a());b(this).selectWoo(f).addClass("enhanced");if(b(this).data("sortable")){var e=b(this);var d=b(this).next(".select2-container").find("ul.select2-selection__rendered");d.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:true,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){b(d.find(".select2-selection__choice").get().reverse()).each(function(){var h=b(this).data("data").id;var g=e.find('option[value="'+h+'"]')[0];e.prepend(g)})}})}else{if(b(this).prop("multiple")){b(this).on("change",function(){var g=b(this).children();g.sort(function(i,h){var k=i.text.toLowerCase();var j=h.text.toLowerCase();if(k>j){return 1}if(k<j){return -1}return 0});b(this).html(g)})}}})});b(document).on("click",".wooccm-field-toggle-enabled",function(){var c=b(this),e=c.closest("tr"),d=c.find(".woocommerce-input-toggle");b.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_toggle_field_enabled",nonce:wooccm.nonce,field_id:e.data("field_id")},dataType:"json",type:"POST",beforeSend:function(f){d.addClass("woocommerce-input-toggle--loading")},success:function(f){if(true===f.data){d.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled");d.addClass("woocommerce-input-toggle--enabled");d.removeClass("woocommerce-input-toggle--loading")}else{if(true!==f.data){d.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled");d.addClass("woocommerce-input-toggle--disabled");d.removeClass("woocommerce-input-toggle--loading")}}}});return false})})(jQuery);
assets/js/wooccm-checkout.js CHANGED
@@ -142,7 +142,7 @@
142
  e.preventDefault();
143
  var $form = $('form.checkout'),
144
  $place_order = $(this),
145
- $results = $('#wooccm_checkout_attachment_results'),
146
  $fields = $('.wooccmupload-field'),
147
  fields = $fields.length;
148
  $fields.each(function (i, field) {
@@ -196,7 +196,7 @@
196
  //$place_order.html(wooccm.uploading);
197
  },
198
  success: function (response) {
199
- $results.removeClass('woocommerce-message');
200
  if (response.success) {
201
  //console.log(response.data);
202
  $attachment_ids.val(response.data);
@@ -235,6 +235,66 @@
235
  $(document).on('change', '.wooccm-add-checkout-fees', function (e) {
236
  $('body').trigger('update_checkout');
237
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  // Color fields
239
  // ---------------------------------------------------------------------------
240
 
142
  e.preventDefault();
143
  var $form = $('form.checkout'),
144
  $place_order = $(this),
145
+ //$results = $('#wooccm_checkout_attachment_results'),
146
  $fields = $('.wooccmupload-field'),
147
  fields = $fields.length;
148
  $fields.each(function (i, field) {
196
  //$place_order.html(wooccm.uploading);
197
  },
198
  success: function (response) {
199
+ //$results.removeClass('woocommerce-message');
200
  if (response.success) {
201
  //console.log(response.data);
202
  $attachment_ids.val(response.data);
235
  $(document).on('change', '.wooccm-add-checkout-fees', function (e) {
236
  $('body').trigger('update_checkout');
237
  });
238
+
239
+ // Conditional
240
+ // ---------------------------------------------------------------------------
241
+
242
+ $('.wooccm-conditional-child').each(function (i, field) {
243
+
244
+ var $field = $(field),
245
+ $parent = $('.wooccm-field-' + $field.find('[data-conditional-parent]').data('conditional-parent')),
246
+ show_if_value = $field.find('[data-conditional-parent-value]').data('conditional-parent-value');
247
+
248
+ if ($parent.length) {
249
+
250
+ $parent.on('change keyup', function (e) {
251
+
252
+ var $this = $(e.target),
253
+ value = $this.val();
254
+
255
+ if ($this.prop('type') == 'checkbox') {
256
+ value = $this.is(':checked');
257
+ }
258
+
259
+ if (show_if_value == value || ($.isArray(value) && value.indexOf(show_if_value) > -1)) {
260
+ $field.fadeIn();
261
+ } else {
262
+ $field.fadeOut();
263
+ }
264
+
265
+ });
266
+
267
+ $parent.find('select').trigger('change');
268
+ $parent.find('textarea').trigger('keyup');
269
+ $parent.find('input[type=button]').trigger('click');
270
+ $parent.find('input[type=radio]:checked').trigger('keyup');
271
+ $parent.find('input[type=checkbox]:checked').trigger('keyup');
272
+ $parent.find('input[type=color]').trigger('keyup');
273
+ $parent.find('input[type=date]').trigger('keyup');
274
+ $parent.find('input[type=datetime-local]').trigger('keyup');
275
+ $parent.find('input[type=email]').trigger('keyup');
276
+ $parent.find('input[type=file]').trigger('keyup');
277
+ $parent.find('input[type=hidden]').trigger('keyup');
278
+ $parent.find('input[type=image]').trigger('keyup');
279
+ $parent.find('input[type=month]').trigger('keyup');
280
+ $parent.find('input[type=number]').trigger('keyup');
281
+ $parent.find('input[type=password]').trigger('keyup');
282
+ $parent.find('input[type=range]').trigger('keyup');
283
+ $parent.find('input[type=reset]').trigger('keyup');
284
+ $parent.find('input[type=search]').trigger('keyup');
285
+ $parent.find('input[type=submit]').trigger('keyup');
286
+ $parent.find('input[type=tel]').trigger('keyup');
287
+ $parent.find('input[type=text]').trigger('keyup');
288
+ $parent.find('input[type=time]').trigger('keyup');
289
+ $parent.find('input[type=url]').trigger('keyup');
290
+ $parent.find('input[type=week]').trigger('keyup');
291
+
292
+ } else {
293
+ $field.show();
294
+ }
295
+
296
+ });
297
+
298
  // Color fields
299
  // ---------------------------------------------------------------------------
300
 
assets/js/wooccm-checkout.min.js CHANGED
@@ -1 +1 @@
1
- (function(d){var e=function(g){return g.is(".processing")||g.parents(".processing").length};var f=function(g){if(!e(g)){g.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(g){g.removeClass("processing").unblock()};var c=function(m,k,l,g,j){var n=d(m),o;if(j.match("image.*")){o="image"}else{if(j.match("application/ms.*")){l=wooccm.icons.spreadsheet;o="spreadsheet"}else{if(j.match("application/x.*")){l=wooccm.icons.archive;o="application"}else{if(j.match("audio.*")){l=wooccm.icons.audio;o="audio"}else{if(j.match("text.*")){l=wooccm.icons.text;o="text"}else{if(j.match("video.*")){l=wooccm.icons.video;o="video"}else{l=wooccm.icons.interactive;o="interactive"}}}}}}var h='<span data-file_id="'+k+'" title="'+g+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <a title="'+g+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n <span class="wooccmupload_file_image_container">\n <img class="'+o+'" alt="'+g+'" src="'+l+'"/>\n </span>\n </span>\n </span>';n.append(h).fadeIn()};var b=[];d(".wooccmupload-field").each(function(h,l){var j=d(l),k=j.find("[type=file]"),g=j.find(".wooccmupload_button"),m=j.find(".wooccmupload_list");b[j.attr("id")]=[];g.on("click",function(i){i.preventDefault();k.trigger("click")});m.on("click",".wooccmupload_file_delete",function(i){d(this).closest(".wooccmupload_file").remove()});k.on("change",function(n){var i=d(this)[0].files;if(i.length){if(window.FileReader){d.each(i,function(p,o){var q=m.find("span[data-file_id]").length+p;if(q>=wooccm.limit.max_files){alert("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(o.size>wooccm.limit.max_file_size){alert("Exeeds max file size of "+wooccm.limit.max_file_size);return true}reader=new FileReader();reader.onload=(function(r){return function(s){setTimeout(function(){c(m,b[j.attr("id")].push(o)-1,s.target.result,r.name,r.type)},200)}})(o);console.log(o.name);reader.readAsDataURL(o)})}}})});d("#order_review").on("ajaxSuccess",function(k){var j=d(k.target),i=j.find("#place_order"),h=d(".wooccmupload-field"),g=h.length;if(g){i.addClass("wooccm-upload-process")}});d(document).on("click","#place_order.wooccm-upload-process",function(l){l.preventDefault();var i=d("form.checkout"),k=d(this),h=d("#wooccm_checkout_attachment_results"),j=d(".wooccmupload-field"),g=j.length;j.each(function(m,p){var n=d(p),r=n.find(".wooccmupload_field"),q=n.find(".wooccmupload_list");if(window.FormData&&b[n.attr("id")].length){if(!e(i)){k.html(wooccm.uploading);f(i)}var o=new FormData();q.find("span[data-file_id]").each(function(t,s){var u=d(s).data("file_id");if(t>wooccm.limit.max_files){console.log("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(b[n.attr("id")][u]===undefined){console.log("Undefined "+u);return true}if(b[n.attr("id")][u].size>wooccm.limit.max_file_size){console.log("Exeeds max file size of "+wooccm.limit.max_files);return true}console.log("We're ready to upload "+b[n.attr("id")][u].name);o.append("wooccm_checkout_attachment_upload[]",b[n.attr("id")][u])});o.append("action","wooccm_checkout_attachment_upload");o.append("nonce",wooccm.nonce);d.ajax({async:false,url:wooccm.ajaxurl,type:"POST",cache:false,data:o,processData:false,contentType:false,beforeSend:function(s){},success:function(s){h.removeClass("woocommerce-message");if(s.success){r.val(s.data)}else{d("body").trigger("update_checkout")}},complete:function(s){g=g-1}})}else{g=g-1}if(g==0){a(i);k.removeClass("wooccm-upload-process").trigger("click")}})});d(document).on("change",".wooccm-add-checkout-fees",function(g){d("body").trigger("update_checkout")});d(".wooccm-colorpicker-farbtastic").each(function(g,j){var h=d(j),l=h.find("input[type=text]"),k=h.find(".wooccmcolorpicker_container");l.hide();if(d.isFunction(d.fn.farbtastic)){k.farbtastic("#"+l.attr("id"));k.on("click",function(i){l.fadeIn()})}});d(".wooccm-colorpicker-iris").each(function(g,j){var h=d(j),l=h.find("input[type=text]"),k=h.find(".wooccmcolorpicker_container");l.css("color","#fff").css("background",l.val()).hide();l.iris({wccmclass:l.attr("id"),palettes:true,color:"",hide:false,change:function(i,m){l.css("color","#000").css("background",m.color.toString()).fadeIn()}})})})(jQuery);
1
+ (function(d){var e=function(g){return g.is(".processing")||g.parents(".processing").length};var f=function(g){if(!e(g)){g.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(g){g.removeClass("processing").unblock()};var c=function(m,k,l,g,j){var n=d(m),o;if(j.match("image.*")){o="image"}else{if(j.match("application/ms.*")){l=wooccm.icons.spreadsheet;o="spreadsheet"}else{if(j.match("application/x.*")){l=wooccm.icons.archive;o="application"}else{if(j.match("audio.*")){l=wooccm.icons.audio;o="audio"}else{if(j.match("text.*")){l=wooccm.icons.text;o="text"}else{if(j.match("video.*")){l=wooccm.icons.video;o="video"}else{l=wooccm.icons.interactive;o="interactive"}}}}}}var h='<span data-file_id="'+k+'" title="'+g+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <a title="'+g+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n <span class="wooccmupload_file_image_container">\n <img class="'+o+'" alt="'+g+'" src="'+l+'"/>\n </span>\n </span>\n </span>';n.append(h).fadeIn()};var b=[];d(".wooccmupload-field").each(function(h,l){var j=d(l),k=j.find("[type=file]"),g=j.find(".wooccmupload_button"),m=j.find(".wooccmupload_list");b[j.attr("id")]=[];g.on("click",function(i){i.preventDefault();k.trigger("click")});m.on("click",".wooccmupload_file_delete",function(i){d(this).closest(".wooccmupload_file").remove()});k.on("change",function(n){var i=d(this)[0].files;if(i.length){if(window.FileReader){d.each(i,function(p,o){var q=m.find("span[data-file_id]").length+p;if(q>=wooccm.limit.max_files){alert("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(o.size>wooccm.limit.max_file_size){alert("Exeeds max file size of "+wooccm.limit.max_file_size);return true}reader=new FileReader();reader.onload=(function(r){return function(s){setTimeout(function(){c(m,b[j.attr("id")].push(o)-1,s.target.result,r.name,r.type)},200)}})(o);console.log(o.name);reader.readAsDataURL(o)})}}})});d("#order_review").on("ajaxSuccess",function(k){var j=d(k.target),i=j.find("#place_order"),h=d(".wooccmupload-field"),g=h.length;if(g){i.addClass("wooccm-upload-process")}});d(document).on("click","#place_order.wooccm-upload-process",function(k){k.preventDefault();var h=d("form.checkout"),j=d(this),i=d(".wooccmupload-field"),g=i.length;i.each(function(l,o){var m=d(o),q=m.find(".wooccmupload_field"),p=m.find(".wooccmupload_list");if(window.FormData&&b[m.attr("id")].length){if(!e(h)){j.html(wooccm.uploading);f(h)}var n=new FormData();p.find("span[data-file_id]").each(function(s,r){var t=d(r).data("file_id");if(s>wooccm.limit.max_files){console.log("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(b[m.attr("id")][t]===undefined){console.log("Undefined "+t);return true}if(b[m.attr("id")][t].size>wooccm.limit.max_file_size){console.log("Exeeds max file size of "+wooccm.limit.max_files);return true}console.log("We're ready to upload "+b[m.attr("id")][t].name);n.append("wooccm_checkout_attachment_upload[]",b[m.attr("id")][t])});n.append("action","wooccm_checkout_attachment_upload");n.append("nonce",wooccm.nonce);d.ajax({async:false,url:wooccm.ajaxurl,type:"POST",cache:false,data:n,processData:false,contentType:false,beforeSend:function(r){},success:function(r){if(r.success){q.val(r.data)}else{d("body").trigger("update_checkout")}},complete:function(r){g=g-1}})}else{g=g-1}if(g==0){a(h);j.removeClass("wooccm-upload-process").trigger("click")}})});d(document).on("change",".wooccm-add-checkout-fees",function(g){d("body").trigger("update_checkout")});d(".wooccm-conditional-child").each(function(g,l){var h=d(l),k=d(".wooccm-field-"+h.find("[data-conditional-parent]").data("conditional-parent")),j=h.find("[data-conditional-parent-value]").data("conditional-parent-value");if(k.length){k.on("change keyup",function(n){var m=d(n.target),i=m.val();if(m.prop("type")=="checkbox"){i=m.is(":checked")}if(j==i||(d.isArray(i)&&i.indexOf(j)>-1)){h.fadeIn()}else{h.fadeOut()}});k.find("select").trigger("change");k.find("textarea").trigger("keyup");k.find("input[type=button]").trigger("click");k.find("input[type=radio]:checked").trigger("keyup");k.find("input[type=checkbox]:checked").trigger("keyup");k.find("input[type=color]").trigger("keyup");k.find("input[type=date]").trigger("keyup");k.find("input[type=datetime-local]").trigger("keyup");k.find("input[type=email]").trigger("keyup");k.find("input[type=file]").trigger("keyup");k.find("input[type=hidden]").trigger("keyup");k.find("input[type=image]").trigger("keyup");k.find("input[type=month]").trigger("keyup");k.find("input[type=number]").trigger("keyup");k.find("input[type=password]").trigger("keyup");k.find("input[type=range]").trigger("keyup");k.find("input[type=reset]").trigger("keyup");k.find("input[type=search]").trigger("keyup");k.find("input[type=submit]").trigger("keyup");k.find("input[type=tel]").trigger("keyup");k.find("input[type=text]").trigger("keyup");k.find("input[type=time]").trigger("keyup");k.find("input[type=url]").trigger("keyup");k.find("input[type=week]").trigger("keyup")}else{h.show()}});d(".wooccm-colorpicker-farbtastic").each(function(g,j){var h=d(j),l=h.find("input[type=text]"),k=h.find(".wooccmcolorpicker_container");l.hide();if(d.isFunction(d.fn.farbtastic)){k.farbtastic("#"+l.attr("id"));k.on("click",function(i){l.fadeIn()})}});d(".wooccm-colorpicker-iris").each(function(g,j){var h=d(j),l=h.find("input[type=text]"),k=h.find(".wooccmcolorpicker_container");l.css("color","#fff").css("background",l.val()).hide();l.iris({wccmclass:l.attr("id"),palettes:true,color:"",hide:false,change:function(i,m){l.css("color","#000").css("background",m.color.toString()).fadeIn()}})})})(jQuery);
assets/js/wooccm-modal.js CHANGED
@@ -17,6 +17,7 @@
17
  var unblock = function ($node) {
18
  $node.removeClass('processing').unblock();
19
  };
 
20
  var wpmi = {
21
  __instance: undefined
22
  };
@@ -64,15 +65,22 @@
64
  alert('Error!');
65
  },
66
  success: function (response) {
 
67
  $modal.$el.attr('tabindex', '0');
68
  $modal.$el.html($modal.templates.window(response.data));
69
  //$(document).on('focusin', $modal.preserveFocus);
70
  $modal.$el.focus().trigger('wc-init-tabbed-panels');
 
 
 
71
  }
72
  });
73
  },
74
  update: function (e) {
75
  'use strict';
 
 
 
76
  var $button = $(e.target),
77
  field_id = $button.data('field_id');
78
  this.render(field_id);
17
  var unblock = function ($node) {
18
  $node.removeClass('processing').unblock();
19
  };
20
+
21
  var wpmi = {
22
  __instance: undefined
23
  };
65
  alert('Error!');
66
  },
67
  success: function (response) {
68
+ console.log(response);
69
  $modal.$el.attr('tabindex', '0');
70
  $modal.$el.html($modal.templates.window(response.data));
71
  //$(document).on('focusin', $modal.preserveFocus);
72
  $modal.$el.focus().trigger('wc-init-tabbed-panels');
73
+ $modal.$el.focus().trigger('init_tooltips');
74
+ ///$modal.$el.focus().trigger('wc-enhanced-select-init');
75
+ $modal.$el.focus().trigger('wooccm-enhanced-select');
76
  }
77
  });
78
  },
79
  update: function (e) {
80
  'use strict';
81
+
82
+ e.preventDefault();
83
+
84
  var $button = $(e.target),
85
  field_id = $button.data('field_id');
86
  this.render(field_id);
assets/js/wooccm-modal.min.js CHANGED
@@ -1 +1 @@
1
- (function(c){var d=function(f){return f.is(".processing")||f.parents(".processing").length};var e=function(f){if(!d(f)){f.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var b=function(f){f.removeClass("processing").unblock()};var a={__instance:undefined};a.Application=Backbone.View.extend({id:"wpmi_modal",events:{"click .media-modal-backdrop":"Close","click .media-modal-close":"Close","click .media-modal-delete":"Delete","click .media-modal-prev":"update","click .media-modal-next":"update","submit .media-modal-form":"Save",},templates:{},initialize:function(f){_.bindAll(this,"open","update","render","Close","Save");this.init();this.open(f)},init:function(){this.templates.window=wp.template("wpmi-modal-window")},render:function(g){var f=this;c.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_edit_field",nonce:wooccm.nonce,field_id:g},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(h){f.$el.attr("tabindex","0");f.$el.html(f.templates.window(h.data));f.$el.focus().trigger("wc-init-tabbed-panels")}})},update:function(h){var g=c(h.target),f=g.data("field_id");this.render(f)},open:function(i){var h=c(i.target),g=h.closest("tr"),f=g.data("field_id");this.render(f);c("body").addClass("modal-open").append(this.$el)},Close:function(f){f.preventDefault();this.undelegateEvents();c(document).off("focusin");c("body").removeClass("modal-open");this.remove();a.__instance=undefined},Save:function(i){i.preventDefault();var f=c(i.target),g=this.$el,h=g.find(".settings-save-status .spinner");c.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_save_field",nonce:wooccm.nonce,field_id:f.data("field_id"),field_data:f.serializeArrayAll()},dataType:"json",type:"POST",beforeSend:function(){h.addClass("is-active");e(g)},complete:function(){h.removeClass("is-active");b(g)},error:function(){alert("Error!")},success:function(j){console.log(j)}});return false},Delete:function(g){g.preventDefault();var f=this;f.Close(g)}});c("#wooccm_billing_settings_add").on("click",function(f){f.preventDefault();if(a.__instance===undefined){a.__instance=new a.Application(f)}});c(".wooccm_billing_settings_edit").on("click",function(f){f.preventDefault();if(a.__instance===undefined){a.__instance=new a.Application(f)}})})(jQuery);
1
+ (function(c){var d=function(f){return f.is(".processing")||f.parents(".processing").length};var e=function(f){if(!d(f)){f.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var b=function(f){f.removeClass("processing").unblock()};var a={__instance:undefined};a.Application=Backbone.View.extend({id:"wpmi_modal",events:{"click .media-modal-backdrop":"Close","click .media-modal-close":"Close","click .media-modal-delete":"Delete","click .media-modal-prev":"update","click .media-modal-next":"update","submit .media-modal-form":"Save",},templates:{},initialize:function(f){_.bindAll(this,"open","update","render","Close","Save");this.init();this.open(f)},init:function(){this.templates.window=wp.template("wpmi-modal-window")},render:function(g){var f=this;c.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_edit_field",nonce:wooccm.nonce,field_id:g},dataType:"json",type:"POST",beforeSend:function(){},complete:function(){},error:function(){alert("Error!")},success:function(h){console.log(h);f.$el.attr("tabindex","0");f.$el.html(f.templates.window(h.data));f.$el.focus().trigger("wc-init-tabbed-panels");f.$el.focus().trigger("init_tooltips");f.$el.focus().trigger("wooccm-enhanced-select")}})},update:function(h){h.preventDefault();var g=c(h.target),f=g.data("field_id");this.render(f)},open:function(i){var h=c(i.target),g=h.closest("tr"),f=g.data("field_id");this.render(f);c("body").addClass("modal-open").append(this.$el)},Close:function(f){f.preventDefault();this.undelegateEvents();c(document).off("focusin");c("body").removeClass("modal-open");this.remove();a.__instance=undefined},Save:function(i){i.preventDefault();var f=c(i.target),g=this.$el,h=g.find(".settings-save-status .spinner");c.ajax({url:woocommerce_admin.ajax_url,data:{action:"wooccm_save_field",nonce:wooccm.nonce,field_id:f.data("field_id"),field_data:f.serializeArrayAll()},dataType:"json",type:"POST",beforeSend:function(){h.addClass("is-active");e(g)},complete:function(){h.removeClass("is-active");b(g)},error:function(){alert("Error!")},success:function(j){console.log(j)}});return false},Delete:function(g){g.preventDefault();var f=this;f.Close(g)}});c("#wooccm_billing_settings_add").on("click",function(f){f.preventDefault();if(a.__instance===undefined){a.__instance=new a.Application(f)}});c(".wooccm_billing_settings_edit").on("click",function(f){f.preventDefault();if(a.__instance===undefined){a.__instance=new a.Application(f)}})})(jQuery);
assets/less/wooccm-admin.less ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .woocommerce_options_panel {
2
+ .select2-container {
3
+ width: 80%!important;
4
+ line-height: 16px;
5
+ //box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
6
+
7
+ .select2-selection--multiple {
8
+ line-height: 16px;
9
+ min-height: 30px;
10
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
11
+ }
12
+ }
13
+
14
+ .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
15
+ margin: 3px 3px 0 0;
16
+ }
17
+ .select2-container--default.select2-container--focus .select2-selection--multiple {
18
+ border-color: #5b9dd9!important;
19
+ box-shadow: 0 0 2px rgba(30, 140, 190, 0.8)!important;
20
+ outline: 2px solid transparent!important;
21
+ }
22
+ }
changelog.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
includes/classes/field_filters.php DELETED
@@ -1,966 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Checkout Manager
4
- */
5
-
6
- // Exit if accessed directly
7
- if ( !defined( 'ABSPATH' ) ) exit;
8
-
9
- // WooCommerce Checkout field - Text Input
10
- function wooccm_checkout_field_text_handler( $field = '', $key, $args, $value ) {
11
-
12
- global $current_user;
13
-
14
- $user_roles = $current_user->roles;
15
- $user_role = array_shift($user_roles);
16
-
17
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
18
- $rolekeys = explode('||',$args['role_options']);
19
- $rolekeys2 = explode('||',$args['role_options2']);
20
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
21
- return;
22
- }
23
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
24
- return;
25
- }
26
- }
27
-
28
- if( !empty( $args['clear'] ) )
29
- $after = '<div class="clear"></div>';
30
- else
31
- $after = '';
32
-
33
- $required = false;
34
- if( $args['wooccm_required'] ) {
35
- $args['class'][] = 'validate-required';
36
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
37
- }
38
-
39
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
40
-
41
- if( is_string( $args['label_class'] ) ) {
42
- $args['label_class'] = array( $args['label_class'] );
43
- }
44
-
45
- if( is_null( $value ) ) {
46
- $value = $args['default'];
47
- }
48
-
49
- // Custom attribute handling
50
- $custom_attributes = array();
51
-
52
- if( !empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
53
- foreach( $args['custom_attributes'] as $attribute => $attribute_value ) {
54
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
55
- }
56
- }
57
-
58
- if( !empty( $args['validate'] ) ) {
59
- foreach( $args['validate'] as $validate ) {
60
- $args['class'][] = 'validate-' . $validate;
61
- }
62
- }
63
-
64
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
65
-
66
- if( $args['label'] || $required ) {
67
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . $required . '</label>';
68
- }
69
-
70
- $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
71
-
72
- if( $args['description'] ) {
73
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
74
- }
75
-
76
- $field .= '</p>' . $after;
77
-
78
- return $field;
79
-
80
- }
81
- add_filter( 'woocommerce_form_field_wooccmtext', 'wooccm_checkout_field_text_handler', 10, 4 );
82
-
83
- // WooCommerce Checkout field - Textarea
84
- function wooccm_checkout_field_textarea_handler( $field = '', $key, $args, $value ) {
85
-
86
- global $current_user;
87
-
88
- $user_roles = $current_user->roles;
89
- $user_role = array_shift($user_roles);
90
-
91
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
92
- $rolekeys = explode('||',$args['role_options']);
93
- $rolekeys2 = explode('||',$args['role_options2']);
94
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
95
- return;
96
- }
97
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
98
- return;
99
- }
100
- }
101
-
102
- if( !empty( $args['clear'] ) )
103
- $after = '<div class="clear"></div>';
104
- else
105
- $after = '';
106
-
107
- if( $args['wooccm_required'] ) {
108
- $args['class'][] = 'validate-required';
109
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
110
- } else {
111
- $required = '';
112
- }
113
-
114
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
115
-
116
- if( is_string( $args['label_class'] ) ) {
117
- $args['label_class'] = array( $args['label_class'] );
118
- }
119
-
120
- if( is_null( $value ) ) {
121
- $value = $args['default'];
122
- }
123
-
124
- // Custom attribute handling
125
- $custom_attributes = array();
126
-
127
- if( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
128
- foreach( $args['custom_attributes'] as $attribute => $attribute_value ) {
129
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
130
- }
131
- }
132
-
133
- if( !empty( $args['validate'] ) ) {
134
- foreach( $args['validate'] as $validate ) {
135
- $args['class'][] = 'validate-' . $validate;
136
- }
137
- }
138
-
139
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
140
-
141
- if( $args['label'] ) {
142
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label']. $required . '</label>';
143
- }
144
-
145
- // WordPress Filters to override default row and column counts
146
- $rows = apply_filters( 'wooccm_checkout_field_texarea_rows', 2, $key, $args );
147
- $columns = apply_filters( 'wooccm_checkout_field_texarea_columns', 5, $key, $args );
148
-
149
- $field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['maxlength'] . ' ' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="' . $rows . '"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="' . $columns . '"' : '' ) . implode( ' ', $custom_attributes ) . '>'. esc_textarea( $value ) .'</textarea>';
150
-
151
- if( $args['description'] ) {
152
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
153
- }
154
-
155
- $field .= '</p>' . $after;
156
-
157
- return $field;
158
-
159
- }
160
- add_filter( 'woocommerce_form_field_wooccmtextarea', 'wooccm_checkout_field_textarea_handler', 10, 4 );
161
-
162
- // WooCommerce Checkout field - Password
163
- function wooccm_checkout_field_password_handler( $field = '', $key, $args, $value ) {
164
-
165
- global $current_user;
166
-
167
- $user_roles = $current_user->roles;
168
- $user_role = array_shift($user_roles);
169
-
170
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
171
- $rolekeys = explode('||',$args['role_options']);
172
- $rolekeys2 = explode('||',$args['role_options2']);
173
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
174
- return;
175
- }
176
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
177
- return;
178
- }
179
- }
180
-
181
- if( !empty( $args['clear'] ) )
182
- $after = '<div class="clear"></div>';
183
- else
184
- $after = '';
185
-
186
- if( $args['wooccm_required'] ) {
187
- $args['class'][] = 'validate-required';
188
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
189
- } else {
190
- $required = '';
191
- }
192
-
193
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
194
-
195
- if( is_string( $args['label_class'] ) ) {
196
- $args['label_class'] = array( $args['label_class'] );
197
- }
198
-
199
- if( is_null( $value ) ) {
200
- $value = $args['default'];
201
- }
202
-
203
- // Custom attribute handling
204
- $custom_attributes = array();
205
-
206
- if( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
207
- foreach( $args['custom_attributes'] as $attribute => $attribute_value ) {
208
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
209
- }
210
- }
211
-
212
- if( !empty( $args['validate'] ) ) {
213
- foreach( $args['validate'] as $validate ) {
214
- $args['class'][] = 'validate-' . $validate;
215
- }
216
- }
217
-
218
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
219
-
220
- if( $args['label'] ) {
221
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label']. $required . '</label>';
222
- }
223
-
224
- $field .= '<input type="password" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
225
-
226
- if( $args['description'] ) {
227
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
228
- }
229
-
230
- $field .= '</p>' . $after;
231
-
232
- return $field;
233
-
234
- }
235
- add_filter( 'woocommerce_form_field_wooccmpassword', 'wooccm_checkout_field_password_handler', 10, 4 );
236
-
237
- // WooCommerce Checkout field - Radio Buttons
238
- function wooccm_checkout_field_radio_handler( $field = '', $key, $args, $value ) {
239
-
240
- global $current_user;
241
-
242
- $user_roles = $current_user->roles;
243
- $user_role = array_shift($user_roles);
244
-
245
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
246
- $rolekeys = explode('||',$args['role_options']);
247
- $rolekeys2 = explode('||',$args['role_options2']);
248
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
249
- return;
250
- }
251
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
252
- return;
253
- }
254
- }
255
-
256
- if( !empty( $args['clear'] ) )
257
- $after = '<div class="clear"></div>';
258
- else
259
- $after = '';
260
-
261
- if( $args['wooccm_required'] ) {
262
- $args['class'][] = 'validate-required';
263
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
264
- } else {
265
- $required = '';
266
- }
267
-
268
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
269
-
270
- $field = '<div class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
271
-
272
- $field .= '<fieldset><legend>' . $args['label'] . $required . '</legend>';
273
-
274
- if( !empty( $args['options'] ) ) {
275
- foreach( explode('||',$args['options']) as $option_key => $option_text ) {
276
- $field .= '<label><input type="radio" ' . checked( $value, wooccm_wpml_string( esc_attr( $option_text ) ), false ) . ' name="' . esc_attr( $key ) . '" value="' . wooccm_wpml_string( esc_attr( $option_text ) ). '" /> ' . wooccm_wpml_string( esc_html( $option_text ) ). '</label>';
277
- }
278
- }
279
-
280
- $field .= '</fieldset></div>' . $after;
281
-
282
- return $field;
283
-
284
- }
285
- add_filter( 'woocommerce_form_field_wooccmradio', 'wooccm_checkout_field_radio_handler', 10, 4 );
286
-
287
- // WooCommerce Checkout field - Select Options
288
- function wooccm_checkout_field_select_handler( $field = '', $key, $args, $value ) {
289
-
290
- global $current_user;
291
-
292
- $user_roles = $current_user->roles;
293
- $user_role = array_shift($user_roles);
294
-
295
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
296
- $rolekeys = explode('||',$args['role_options']);
297
- $rolekeys2 = explode('||',$args['role_options2']);
298
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
299
- return;
300
- }
301
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
302
- return;
303
- }
304
- }
305
-
306
- if( !empty( $args['clear'] ) )
307
- $after = '<div class="clear"></div>';
308
- else
309
- $after = '';
310
-
311
- if( $args['wooccm_required'] ) {
312
- $args['class'][] = 'validate-required';
313
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
314
- } else {
315
- $required = '';
316
- }
317
-
318
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
319
-
320
- $options = '';
321
-
322
- if( !empty( $args['options'] ) ) {
323
- $options .= ( $args['default'] ? '<option value="">' . $args['default'] .'</option>' : '' );
324
- foreach( explode( '||', $args['options'] ) as $option_key => $option_text )
325
- $options .= '<option '. selected( $value, $option_key, false ) . '>' . wooccm_wpml_string( esc_attr( $option_text ) ) .'</option>';
326
- }
327
-
328
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
329
-
330
- if( $args['label'] )
331
- $field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
332
-
333
- $field .= '
334
- <select class="' . esc_attr( $args['fancy'] ) .'" data-placeholder="' . ( !empty( $args['default'] ) ? __( $args['default'], 'woocommerce-checkout-manager' ) : '' ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" >
335
- ' . $options . '
336
- </select>
337
- </p>' . $after;
338
-
339
- return $field;
340
-
341
- }
342
- add_filter( 'woocommerce_form_field_wooccmselect', 'wooccm_checkout_field_select_handler', 10, 4 );
343
-
344
- // WooCommerce Checkout field - Check Box
345
- function wooccm_checkout_field_checkbox_handler( $field = '', $key, $args, $value ) {
346
-
347
- global $current_user;
348
-
349
- $user_roles = $current_user->roles;
350
- $user_role = array_shift($user_roles);
351
-
352
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
353
- $rolekeys = explode('||',$args['role_options']);
354
- $rolekeys2 = explode('||',$args['role_options2']);
355
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
356
- return;
357
- }
358
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
359
- return;
360
- }
361
- }
362
-
363
- $args['options'] = explode('||',$args['options']);
364
-
365
- if( !empty( $args['clear'] ) )
366
- $after = '<div class="clear"></div>';
367
- else
368
- $after = '';
369
-
370
- if( $args['wooccm_required'] ) {
371
- $args['class'][] = 'validate-required';
372
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
373
- } else {
374
- $required = '';
375
- }
376
-
377
- $field = '
378
- <p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">
379
- <label for="' . $key . '_checkbox" class="woocommerce-form__label woocommerce-form__label-for-checkbox ' . implode( ' ', $args['label_class'] ) .'">
380
- <input type="checkbox" id="' . $key . '_checkbox" name="' . $key . '" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" value="1" />
381
- <span>' . $args['label'] . '</span>' . $required . '
382
- </label>
383
- </p>' . $after;
384
-
385
- return $field;
386
-
387
- }
388
- add_filter( 'woocommerce_form_field_checkbox_wccm', 'wooccm_checkout_field_checkbox_handler', 10, 4 );
389
-
390
- // WooCommerce Checkout field - State
391
- function wooccm_checkout_field_state_handler( $field = '', $key, $args, $value ) {
392
-
393
- global $current_user;
394
-
395
- $user_roles = $current_user->roles;
396
- $user_role = array_shift($user_roles);
397
-
398
- if( !empty( $args['user_role'] ) && (!empty( $args['role_options'] ) || !empty ($args['role_options2'] )) ) {
399
- $rolekeys = explode( '||',$args['role_options'] );
400
- $rolekeys2 = explode( '||',$args['role_options2'] );
401
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
402
- return;
403
- }
404
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
405
- return;
406
- }
407
- }
408
-
409
- if( !empty( $args['clear'] ) )
410
- $after = '<div class="clear"></div>';
411
- else
412
- $after = '';
413
-
414
- //$args['class'][] = 'address-field';
415
-
416
- $country_key = $key == 'billing_state' ? 'billing_country' : 'shipping_country';
417
- $current_cc = WC()->checkout->get_value( $country_key );
418
- $states = WC()->countries->get_states( $current_cc );
419
-
420
- if( $args['wooccm_required'] ) {
421
- if( !empty( $states ) ) {
422
- if( !in_array( 'validate-required', $args['class'] ) )
423
- $args['class'][] = 'validate-required';
424
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
425
- } else {
426
- $args['class'][] = 'woocommerce-validated';
427
- }
428
- } else {
429
- $required = '';
430
- $args['class'][] = 'woocommerce-validated';
431
- }
432
-
433
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
434
-
435
- if( is_string( $args['label_class'] ) ) {
436
- $args['label_class'] = array( $args['label_class'] );
437
- }
438
-
439
- if( is_null( $value ) ) {
440
- $value = $args['default'];
441
- }
442
-
443
- // Custom attribute handling
444
- $custom_attributes = array();
445
-
446
- if( !empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
447
- foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
448
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
449
- }
450
- }
451
-
452
- if( !empty( $states ) && !empty( $args['validate'] ) ) {
453
- foreach( $args['validate'] as $validate ) {
454
- $args['class'][] = 'validate-' . $validate;
455
- }
456
- }
457
-
458
- if( is_array( $states ) && empty( $states ) ) {
459
-
460
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field" style="display: none">';
461
-
462
- if( $args['label'] ) {
463
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . $required . '</label>';
464
- }
465
- $field .= '<input type="hidden" class="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '" />';
466
-
467
- if( $args['description'] ) {
468
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
469
- }
470
-
471
- $field .= '</p>' . $after;
472
-
473
- } elseif ( is_array( $states ) ) {
474
-
475
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
476
-
477
- if( $args['label'] )
478
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label']. $required . '</label>';
479
- $field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="state_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '">
480
- <option value="">' . __( 'Select a state&hellip;', 'woocommerce-checkout-manager' ) . '</option>';
481
-
482
- foreach( $states as $ckey => $cvalue ) {
483
- $field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>' . ( !empty( $cvalue ) ? __( $cvalue, 'woocommerce-checkout-manager' ) : '' ) .'</option>';
484
- }
485
-
486
- $field .= '</select>';
487
-
488
- if( $args['description'] ) {
489
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
490
- }
491
-
492
- $field .= '</p>' . $after;
493
-
494
- } else {
495
-
496
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
497
-
498
- if( $args['label'] ) {
499
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label']. $required . '</label>';
500
- }
501
- $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
502
-
503
- if( $args['description'] ) {
504
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
505
- }
506
-
507
- $field .= '</p>' . $after;
508
- }
509
-
510
- return $field;
511
-
512
- }
513
- add_filter( 'woocommerce_form_field_wooccmstate', 'wooccm_checkout_field_state_handler', 10, 4 );
514
-
515
- // WooCommerce Checkout field - Country
516
- function wooccm_checkout_field_country_handler( $field = '', $key, $args, $value ) {
517
-
518
- global $current_user;
519
-
520
- $user_roles = $current_user->roles;
521
- $user_role = array_shift($user_roles);
522
-
523
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
524
- $rolekeys = explode('||',$args['role_options']);
525
- $rolekeys2 = explode('||',$args['role_options2']);
526
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
527
- return;
528
- }
529
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
530
- return;
531
- }
532
- }
533
-
534
- if( !empty( $args['clear'] ) )
535
- $after = '<div class="clear"></div>';
536
- else
537
- $after = '';
538
-
539
- //$args['class'][] = 'address-field';
540
-
541
- if( $args['wooccm_required'] ) {
542
- $args['class'][] = 'validate-required';
543
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
544
- } else {
545
- $required = '';
546
- }
547
-
548
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
549
-
550
- if( is_string( $args['label_class'] ) ) {
551
- $args['label_class'] = array( $args['label_class'] );
552
- }
553
-
554
- if( is_null( $value ) ) {
555
- $value = $args['default'];
556
- }
557
-
558
- // Custom attribute handling
559
- $custom_attributes = array();
560
-
561
- if( !empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
562
- foreach( $args['custom_attributes'] as $attribute => $attribute_value ) {
563
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
564
- }
565
- }
566
-
567
- if( !empty( $args['validate'] ) ) {
568
- foreach( $args['validate'] as $validate ) {
569
- $args['class'][] = 'validate-' . $validate;
570
- }
571
- }
572
-
573
- $countries = $key == 'shipping_country' ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries();
574
-
575
- if( sizeof( $countries ) == 1 ) {
576
-
577
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
578
-
579
- if( $args['label'] ) {
580
- $field .= '<label class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . '</label>';
581
- }
582
-
583
- $field .= '<strong>' . current( array_values( $countries ) ) . '</strong>';
584
-
585
- $field .= '<input type="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" value="' . current( array_keys($countries ) ) . '" ' . implode( ' ', $custom_attributes ) . ' class="country_to_state" />';
586
-
587
- if( $args['description'] ) {
588
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
589
- }
590
-
591
- $field .= '</p>' . $after;
592
-
593
- } else {
594
-
595
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">'
596
- . '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . $required . '</label>'
597
- . '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="country_to_state country_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" ' . implode( ' ', $custom_attributes ) . '>'
598
- . '<option value="">' . __( 'Select a country&hellip;', 'woocommerce-checkout-manager' ) . '</option>';
599
-
600
- foreach( $countries as $ckey => $cvalue ) {
601
- $field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>' . ( !empty( $cvalue ) ? __( $cvalue, 'woocommerce-checkout-manager' ) : '' ) . '</option>';
602
- }
603
-
604
- $field .= '</select>';
605
-
606
- $field .= '<noscript><input type="submit" name="woocommerce_checkout_update_totals" value="' . __( 'Update country', 'woocommerce-checkout-manager' ) . '" /></noscript>';
607
-
608
- if( $args['description'] ) {
609
- $field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
610
- }
611
-
612
- $field .= '</p>' . $after;
613
-
614
- }
615
-
616
- return $field;
617
-
618
- }
619
- add_filter( 'woocommerce_form_field_wooccmcountry', 'wooccm_checkout_field_country_handler', 10, 4 );
620
-
621
- // WooCommerce Checkout field - Multi-Select
622
- function wooccm_checkout_field_multiselect_handler( $field = '', $key, $args, $value ) {
623
-
624
- global $current_user;
625
-
626
- $user_roles = $current_user->roles;
627
- $user_role = array_shift($user_roles);
628
-
629
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
630
- $rolekeys = explode('||',$args['role_options']);
631
- $rolekeys2 = explode('||',$args['role_options2']);
632
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
633
- return;
634
- }
635
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
636
- return;
637
- }
638
- }
639
-
640
- if( !empty( $args['clear'] ) )
641
- $after = '<div class="clear"></div>';
642
- else
643
- $after = '';
644
-
645
- if( $args['wooccm_required'] ) {
646
- $args['class'][] = 'validate-required';
647
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
648
- } else {
649
- $required = '';
650
- }
651
-
652
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
653
-
654
- $options = '';
655
-
656
- if( !empty( $args['options'] ) )
657
- foreach (explode('||',$args['options']) as $option_key => $option_text )
658
- $options .= '<option value="'.wooccm_wpml_string( esc_attr( $option_text ) ).'" '. selected( $value, $option_key, false ) . '>' . wooccm_wpml_string( esc_attr( $option_text ) ) .'</option>';
659
-
660
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
661
-
662
- if ( $args['label'] )
663
- $field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
664
-
665
- $field .= '<select data-placeholder="' . __( 'Select some options', 'woocommerce-checkout-manager' ) . '" multiple="multiple" name="' . esc_attr( $key ) . '[]" id="' . esc_attr( $key ) . '" class="checkout_chosen_select select">
666
- ' . $options . '
667
- </select>
668
- </p>' . $after;
669
-
670
- return $field;
671
-
672
- }
673
- add_filter( 'woocommerce_form_field_multiselect', 'wooccm_checkout_field_multiselect_handler', 10, 4 );
674
-
675
- // WooCommerce Checkout field - Multi-Checkbox
676
- function wooccm_checkout_field_multicheckbox_handler( $field = '', $key, $args, $value ) {
677
-
678
- global $current_user;
679
-
680
- $user_roles = $current_user->roles;
681
- $user_role = array_shift( $user_roles );
682
-
683
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
684
- $rolekeys = explode('||',$args['role_options']);
685
- $rolekeys2 = explode('||',$args['role_options2']);
686
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
687
- return;
688
- }
689
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
690
- return;
691
- }
692
- }
693
-
694
- if( !empty( $args['clear'] ) )
695
- $after = '<div class="clear"></div>';
696
- else
697
- $after = '';
698
-
699
- if( $args['wooccm_required'] ) {
700
- $args['class'][] = 'validate-required';
701
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
702
- } else {
703
- $required = '';
704
- }
705
-
706
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
707
-
708
- $options = '';
709
-
710
- if( !empty( $args['options'] ) ) {
711
- foreach( explode('||',$args['options']) as $option_key => $option_text ) {
712
- $options .= '<label><input type="checkbox" name="' . esc_attr( $key ) . '[]" value="'.wooccm_wpml_string( esc_attr( $option_text ) ).'"'. selected( $value, $option_key, false ) . ' /> ' . wooccm_wpml_string( esc_attr( $option_text ) ) . '</label>';
713
- }
714
- }
715
-
716
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
717
-
718
- if( $args['label'] )
719
- $field .= '<label class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
720
-
721
- $field .= $options . '
722
- </p>' . $after;
723
-
724
- return $field;
725
-
726
- }
727
- add_filter( 'woocommerce_form_field_multicheckbox', 'wooccm_checkout_field_multicheckbox_handler', 10, 4 );
728
-
729
- // WooCommerce Checkout field - Color Picker
730
- function wooccm_checkout_field_colorpicker_handler( $field = '', $key, $args, $value ) {
731
-
732
- global $current_user;
733
-
734
- $user_roles = $current_user->roles;
735
- $user_role = array_shift($user_roles);
736
-
737
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
738
- $rolekeys = explode('||',$args['role_options']);
739
- $rolekeys2 = explode('||',$args['role_options2']);
740
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
741
- return;
742
- }
743
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
744
- return;
745
- }
746
- }
747
-
748
- if( !empty( $args['clear'] ) )
749
- $after = '<div class="clear"></div>';
750
- else
751
- $after = '';
752
-
753
- if( $args['wooccm_required'] ) {
754
- $args['class'][] = 'validate-required';
755
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
756
- } else {
757
- $required = '';
758
- }
759
-
760
- //if ( isset($value) ) {
761
- $value = $args['color'];
762
- //}
763
-
764
- $field = '
765
- <p class="form-row ' . implode( ' ', $args['class'] ) .' wccs_colorpicker" id="' . $key . '_field">
766
- <label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>
767
- <input type="text" class="input-text" maxlength="7" size="6" name="' . $key . '" id="' . $key . '_colorpicker" placeholder="' . $args['placeholder'] . '" value="'.$value.'" />
768
- <span id="' . $key . '_colorpickerdiv" class="spec_shootd"></span>
769
- </p>' . $after;
770
-
771
- return $field;
772
-
773
- }
774
- add_filter( 'woocommerce_form_field_colorpicker', 'wooccm_checkout_field_colorpicker_handler', 10, 4 );
775
-
776
- // WooCommerce Checkout field - Date Picker
777
- function wooccm_checkout_field_datepicker_handler( $field = '', $key, $args, $value ) {
778
-
779
- global $current_user;
780
-
781
- $user_roles = $current_user->roles;
782
- $user_role = array_shift($user_roles);
783
-
784
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
785
- $rolekeys = explode('||',$args['role_options']);
786
- $rolekeys2 = explode('||',$args['role_options2']);
787
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
788
- return;
789
- }
790
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
791
- return;
792
- }
793
- }
794
-
795
- if( !empty( $args['clear'] ) )
796
- $after = '<div class="clear"></div>';
797
- else
798
- $after = '';
799
-
800
- if( $args['wooccm_required'] ) {
801
- $args['class'][] = 'validate-required';
802
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
803
- } else {
804
- $required = '';
805
- }
806
-
807
- $field = '<p class="form-row ' . implode( ' ', $args['class'] ) . 'MyDate' . $args['cow'] . ' wccs-form-row-wide" id="' . $key . '_field">
808
- <label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>
809
- <input type="text" class="input-text" name="' . $key . '" id="' . $key . '" placeholder="' . $args['placeholder'] . '" value="'. $value.'" />
810
- </p>' . $after;
811
-
812
- return $field;
813
-
814
- }
815
- add_filter( 'woocommerce_form_field_datepicker', 'wooccm_checkout_field_datepicker_handler', 10, 4 );
816
-
817
- // WooCommerce Checkout field - Time Picker
818
- function wooccm_checkout_field_timepicker_handler( $field = '', $key, $args, $value ) {
819
-
820
- global $current_user;
821
-
822
- $user_roles = $current_user->roles;
823
- $user_role = array_shift($user_roles);
824
-
825
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
826
- $rolekeys = explode('||',$args['role_options']);
827
- $rolekeys2 = explode('||',$args['role_options2']);
828
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
829
- return;
830
- }
831
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
832
- return;
833
- }
834
- }
835
-
836
- if( !empty( $args['clear'] ) )
837
- $after = '<div class="clear"></div>';
838
- else
839
- $after = '';
840
-
841
- if( $args['wooccm_required'] ) {
842
- $args['class'][] = 'validate-required';
843
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
844
- } else {
845
- $required = '';
846
- }
847
-
848
- $field = '<p class="form-row ' . implode( ' ', $args['class'] ) . 'MyTime' . $args['cow'] . ' wccs-form-row-wide" id="' . $key . '_field">
849
- <label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>
850
- <input type="text" class="input-text" name="' . $key . '" id="' . $key . '" placeholder="' . $args['placeholder'] . '" value="'. $value.'" />
851
- </p>' . $after;
852
-
853
- return $field;
854
-
855
- }
856
- add_filter( 'woocommerce_form_field_time', 'wooccm_checkout_field_timepicker_handler', 10, 4 );
857
-
858
- // WooCommerce Checkout field - File Picker
859
- function wooccm_checkout_field_upload_handler( $field = '', $key, $args, $value ) {
860
-
861
- global $wpdb, $woocommerce, $post, $current_user;
862
-
863
- $user_roles = $current_user->roles;
864
- $user_role = array_shift($user_roles);
865
-
866
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
867
- $rolekeys = explode('||',$args['role_options']);
868
- $rolekeys2 = explode('||',$args['role_options2']);
869
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
870
- return;
871
- }
872
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
873
- return;
874
- }
875
- }
876
-
877
- $upload_name = ( !empty($args['placeholder'] ) ? esc_attr( $args['placeholder'] ) : __( 'Upload Files', 'woocommerce-checkout-manager' ) );
878
-
879
- if( !empty( $args['clear'] ) )
880
- $after = '<div class="clear"></div>';
881
- else
882
- $after = '';
883
-
884
- if( $args['wooccm_required'] ) {
885
- $args['class'][] = 'validate-required';
886
- $required = '&nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
887
- } else {
888
- $required = '';
889
- }
890
-
891
- $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
892
-
893
- if( is_string( $args['label_class'] ) ) {
894
- $args['label_class'] = array( $args['label_class'] );
895
- }
896
-
897
- if( is_null( $value ) ) {
898
- $value = $args['default'];
899
- }
900
-
901
- // Custom attribute handling
902
- $custom_attributes = array();
903
-
904
- if( !empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
905
- foreach( $args['custom_attributes'] as $attribute => $attribute_value ) {
906
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
907
- }
908
- }
909
-
910
- if( !empty( $args['validate'] ) ) {
911
- foreach( $args['validate'] as $validate ) {
912
- $args['class'][] = 'validate-' . $validate;
913
- }
914
- }
915
-
916
- $field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
917
-
918
- if( $args['label'] ) {
919
- $field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label'] . $required . '</label>';
920
- }
921
-
922
- /*
923
- // @mod - It looks like the file picker ignores required
924
- $field .= '
925
- <!-- <input style="display:none;" type="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="1||" /> -->
926
- ';
927
- */
928
- $field .= '
929
- <input style="display:none;" type="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="" />
930
- <input style="display:none;" type="file" name="' . esc_attr( $key ) . '_file" id="' . esc_attr( $key ) . '_file" class="file_upload_button_hide" multiple />
931
-
932
- <button type="button" class="file_upload_account wooccm-btn wooccm-btn-primary start" id="' . esc_attr( $key ) . '_files_button_wccm">'.$upload_name.'</button>';
933
-
934
- $field .= '</p>' . $after;
935
-
936
- return $field;
937
-
938
- }
939
- add_filter( 'woocommerce_form_field_wooccmupload', 'wooccm_checkout_field_upload_handler', 10, 4 );
940
-
941
- // WooCommerce Checkout field - Heading
942
- function wooccm_checkout_field_heading_handler( $field = '', $key, $args, $value ) {
943
-
944
- global $current_user;
945
-
946
- $user_roles = $current_user->roles;
947
- $user_role = array_shift($user_roles);
948
-
949
- if( !empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2'])) ) {
950
- $rolekeys = explode('||',$args['role_options']);
951
- $rolekeys2 = explode('||',$args['role_options2']);
952
- if( !empty($args['role_options']) && !in_array($user_role, $rolekeys) ) {
953
- return;
954
- }
955
- if( !empty($args['role_options2']) && in_array($user_role, $rolekeys2) ) {
956
- return;
957
- }
958
- }
959
-
960
- $field = '<h3 class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">' . $args['label'] . '</h3>';
961
-
962
- return $field;
963
-
964
- }
965
- add_filter( 'woocommerce_form_field_heading', 'wooccm_checkout_field_heading_handler', 10, 4 );
966
- ?>