WooCommerce Checkout Manager - Version 4.3.3

Version Description

  • Improvement: woocommerce order upload rebuilt
  • Improvement: woocommerce checkout upload rebuilt
  • Improvement: woocommerce order admin upload rebuilt
  • Improvement: woocommerce register fields rebuilt
  • Improvement: woocommerce register fields rebuilt
  • Fix: woocommerce checkout additional fields required
Download this release

Release Info

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

Code changes from version 4.3.2 to 4.3.3

assets/css/wooccm.css ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .button.fileinput-button {
2
+ position: relative;
3
+ overflow: hidden!important;
4
+ }
5
+ .button.fileinput-button input {
6
+ position: absolute;
7
+ top: 0;
8
+ right: 0;
9
+ margin: 0;
10
+ opacity: 0;
11
+ -ms-filter: 'alpha(opacity=0)';
12
+ font-size: 200px;
13
+ direction: ltr;
14
+ cursor: pointer;
15
+ }
16
+ .wooccmupload_list {
17
+ margin: 0 -5px;
18
+ padding: 0;
19
+ display: flex;
20
+ flex-wrap: wrap;
21
+ align-items: center;
22
+ justify-content: start;
23
+ }
24
+ .wooccmupload_list .wooccmupload_file {
25
+ display: flex;
26
+ justify-content: center;
27
+ align-items: stretch;
28
+ box-sizing: border-box;
29
+ padding: 10px 5px 0 5px;
30
+ width: 25%;
31
+ max-height: 90px;
32
+ position: relative;
33
+ }
34
+ .wooccmupload_list .wooccmupload_file .wooccmupload_file_delete {
35
+ position: absolute;
36
+ top: 2px;
37
+ right: -3px;
38
+ width: 16px;
39
+ height: 16px;
40
+ background-color: #222;
41
+ display: block;
42
+ line-height: 13px;
43
+ text-align: center;
44
+ color: #fefefe;
45
+ font-weight: 900;
46
+ border-radius: 50%;
47
+ font-size: 14px;
48
+ cursor: pointer;
49
+ }
50
+ .wooccmupload_list .wooccmupload_file .wooccmupload_file_container {
51
+ width: 100%;
52
+ overflow: hidden;
53
+ }
54
+ /*# sourceMappingURL=wooccm.css.map */
assets/css/wooccm.css.map ADDED
@@ -0,0 +1 @@
 
1
+ {"version":3,"sources":["../less/wooccm.less"],"names":[],"mappings":"AACE,OAAC;EACC,kBAAA;EACA,0BAAA;;AAFF,OAAC,iBAIC;EACE,kBAAA;EACA,MAAA;EACA,QAAA;EACA,SAAA;EACA,UAAA;EACA,YAAW,kBAAX;EACA,gBAAA;EACA,cAAA;EACA,eAAA;;AAMN;EACE,cAAA;EACA,UAAA;EACA,aAAA;EACA,eAAA;EACA,mBAAA;EACA,sBAAA;;AANF,kBAQE;EACE,aAAA;EACA,uBAAA;EACA,oBAAA;EACA,sBAAA;EACA,uBAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;;AAhBJ,kBAQE,mBAWE;EACE,kBAAA;EACA,QAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,sBAAA;EACA,cAAA;EACA,iBAAA;EACA,kBAAA;EACA,cAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;EACA,eAAA;;AAjCN,kBAQE,mBA6BE;EACE,WAAA;EACA,gBAAA","file":"wooccm.css"}
assets/css/wooccm.min.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+
2
+ .fileinput-button{position:relative;overflow:hidden!important}.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:'alpha(opacity=0)';font-size:200px;direction:ltr;cursor:pointer}
assets/js/wooccm-admin.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+
3
+ // Toggle gateway on/off.
4
+ $('.wooccm_billing_fields').on('click', '.wooccm-field-toggle-enabled', function () {
5
+
6
+ var $link = $(this),
7
+ $row = $link.closest('tr'),
8
+ $toggle = $link.find('.woocommerce-input-toggle');
9
+
10
+ var data = {
11
+ action: 'wooccm_toggle_field_enabled',
12
+ nonce: wooccm.nonce,
13
+ field_id: $row.data('field_id')
14
+ };
15
+
16
+ $toggle.addClass('woocommerce-input-toggle--loading');
17
+
18
+ $.ajax({
19
+ url: woocommerce_admin.ajax_url,
20
+ data: data,
21
+ dataType: 'json',
22
+ type: 'POST',
23
+ success: function (response) {
24
+
25
+ if (true === response.data) {
26
+ $toggle.removeClass('woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled');
27
+ $toggle.addClass('woocommerce-input-toggle--enabled');
28
+ $toggle.removeClass('woocommerce-input-toggle--loading');
29
+ } else if (true !== response.data) {
30
+ $toggle.removeClass('woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled');
31
+ $toggle.addClass('woocommerce-input-toggle--disabled');
32
+ $toggle.removeClass('woocommerce-input-toggle--loading');
33
+ } //else if ('needs_setup' === response.data) {
34
+ //window.location.href = $link.attr('href');
35
+ //}
36
+ }
37
+ });
38
+ return false;
39
+ });
40
+ })(jQuery);
assets/js/wooccm-admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(a){a(".wooccm_billing_fields").on("click",".wooccm-field-toggle-enabled",function(){var c=a(this),b=c.closest("tr"),d=c.find(".woocommerce-input-toggle");var e={action:"wooccm_toggle_field_enabled",nonce:wooccm.nonce,field_id:b.data("field_id")};d.addClass("woocommerce-input-toggle--loading");a.ajax({url:woocommerce_admin.ajax_url,data:e,dataType:"json",type:"POST",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-upload.funciona.js ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+
3
+ var is_blocked = function ($node) {
4
+ return $node.is('.processing') || $node.parents('.processing').length;
5
+ };
6
+ var block = function ($node) {
7
+ if (!is_blocked($node)) {
8
+ $node.addClass('processing').block({
9
+ message: null,
10
+ overlayCSS: {
11
+ background: '#fff',
12
+ opacity: 0.6
13
+ }
14
+ });
15
+ }
16
+ };
17
+ var unblock = function ($node) {
18
+ $node.removeClass('processing').unblock();
19
+ };
20
+
21
+ var append_image = function (list, i, source, name, filetype) {
22
+
23
+ var $list = $(list);
24
+
25
+ if ((false === filetype.match('application/ms.*') && false === filetype.match('application/x.*') && false === filetype.match('audio.*') && false === filetype.match('text.*') && false === filetype.match('video.*')) || (0 === filetype.length || !filetype)) {
26
+ source = wooccm.icons.interactive;
27
+ }
28
+ if (filetype.match('application/ms.*')) {
29
+ source = wooccm.icons.spreadsheet;
30
+ }
31
+ if (filetype.match('application/x.*')) {
32
+ source = wooccm.icons.archive;
33
+ }
34
+ if (filetype.match('audio.*')) {
35
+ source = wooccm.icons.audio;
36
+ }
37
+ if (filetype.match('text.*')) {
38
+ source = wooccm.icons.text;
39
+ }
40
+ if (filetype.match('video.*')) {
41
+ source = wooccm.icons.video;
42
+ }
43
+
44
+ var html = '<span data-file_id="' + i + '" title="' + name + '" class="wooccm_file">\n\
45
+ <span class="wooccm_file_container">\n\
46
+ <img alt="' + name + '" src="' + source + '"/>\n\
47
+ <a title="' + name + '" class="wooccm_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n\
48
+ </span>\n\
49
+ </span>';
50
+
51
+ $list.append(html).fadeIn();
52
+
53
+ }
54
+
55
+
56
+ // Field
57
+ // ---------------------------------------------------------------------------
58
+
59
+ $('.wooccmupload-field').each(function (i, field) {
60
+
61
+ var $field = $(field),
62
+ $button = $field.find('[type=button]'),
63
+ $files = $field.find('[type=file]'),
64
+ $list = $field.find('.wooccm_checkout_attachment_upload');
65
+
66
+ // Click
67
+ // -------------------------------------------------------------------------
68
+
69
+ $button.on('click', function (e) {
70
+ e.preventDefault();
71
+ $files.trigger('click');
72
+ });
73
+
74
+ // Delete
75
+ // ---------------------------------------------------------------------------
76
+
77
+ $(document).on('click', '.wooccm_file_delete', function (e) {
78
+
79
+ alert('delete');
80
+
81
+ //var $tr = $(this).closest('tr'),
82
+ // attachment_id = $(this).data('attachment_id');
83
+
84
+ //$tr.hide();
85
+
86
+ //$('#delete_attachments_ids').val($('#delete_attachments_ids').val().replace(attachment_id, ''));
87
+ });
88
+
89
+ // Append images
90
+ // -------------------------------------------------------------------------
91
+
92
+ $files.on('change', function (e) {
93
+
94
+ var $field = $(field),
95
+ $files = $field.find('[type=file]'),
96
+ files = $files[0].files;
97
+
98
+ if (files.length) {
99
+ $.each(files, function (i, file) {
100
+
101
+ if (window.FileReader) {
102
+
103
+ reader = new FileReader();
104
+
105
+ reader.onload = (function (theFile) {
106
+ return function (e) {
107
+
108
+ setTimeout(function () {
109
+ append_image($list, i, e.target.result, theFile.name, theFile.type);
110
+ }, 200);
111
+
112
+ };
113
+ })(file);
114
+
115
+ reader.readAsDataURL(file);
116
+ }
117
+
118
+ });
119
+ }
120
+
121
+ });
122
+ });
123
+
124
+ // Upload
125
+ // ---------------------------------------------------------------------------
126
+
127
+ $('#order_review').on('ajaxSuccess', function (e) {
128
+
129
+ var $order_review = $(e.target),
130
+ $place_order = $order_review.find('#place_order'),
131
+ $fields = $('.wooccmupload-field'),
132
+ fields = $fields.length;
133
+
134
+ if (fields) {
135
+ $place_order.addClass('wooccm-upload-process');
136
+ }
137
+
138
+ });
139
+
140
+ $(document).on('click', '#place_order.wooccm-upload-process', function (e) {
141
+
142
+ e.preventDefault();
143
+
144
+ var $form = $('form.checkout'),
145
+ $place_order = $(this),
146
+ $results = $('#wooccm_checkout_attachment_results'),
147
+ $fields = $('.wooccmupload-field'),
148
+ fields = $fields.length;
149
+
150
+ $fields.each(function (i, field) {
151
+
152
+ var $field = $(field),
153
+ $input = $field.find('[type=hidden]'),
154
+ $files = $field.find('[type=file]'),
155
+ files = $files[0].files;
156
+
157
+ if (window.FormData && files.length) {
158
+
159
+ if (!is_blocked($form)) {
160
+ $place_order.html(wooccm.uploading);
161
+ block($form);
162
+ }
163
+
164
+ var data = new FormData();
165
+
166
+ $.each(files, function (i, file) {
167
+ data.append('wooccm_checkout_attachment_upload[]', file);
168
+ });
169
+
170
+ data.append('action', 'wooccm_checkout_attachment_upload');
171
+ data.append('nonce', wooccm.nonce);
172
+
173
+ $.ajax({
174
+ async: false,
175
+ url: wooccm.ajaxurl,
176
+ type: 'POST',
177
+ cache: false,
178
+ data: data,
179
+ processData: false,
180
+ contentType: false,
181
+ beforeSend: function (response) {
182
+ //$place_order.html(wooccm.uploading);
183
+ },
184
+ success: function (response) {
185
+ $results.removeClass('woocommerce-message');
186
+ if (response.success) {
187
+ //$results.addClass('woocommerce-message').html(wooccm.success);
188
+ //console.log(response.data);
189
+ $input.val(response.data);
190
+ } else {
191
+ $results.addClass('woocommerce-error').html(response.data).show();
192
+ }
193
+ //$results.show();
194
+ },
195
+ complete: function (response) {
196
+ //$place_order.html(text);
197
+ fields = fields - 1;
198
+ //console.log('ajax: fields = ' + fields);
199
+ }
200
+ });
201
+
202
+ } else {
203
+ fields = fields - 1;
204
+ //console.log('no ajax: fields = ' + fields);
205
+ }
206
+
207
+ //console.log('fields = ' + fields);
208
+
209
+ if (fields == 0) {
210
+ //console.log('llamar al click aca');
211
+ unblock($form);
212
+ $place_order.removeClass('wooccm-upload-process').trigger('click');
213
+ //return;
214
+ }
215
+
216
+ });
217
+ //return false;
218
+ //}
219
+ });
220
+
221
+ })(jQuery);
assets/js/wooccm-checkout-upload.js ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+
3
+ var is_blocked = function ($node) {
4
+ return $node.is('.processing') || $node.parents('.processing').length;
5
+ };
6
+ var block = function ($node) {
7
+ if (!is_blocked($node)) {
8
+ $node.addClass('processing').block({
9
+ message: null,
10
+ overlayCSS: {
11
+ background: '#fff',
12
+ opacity: 0.6
13
+ }
14
+ });
15
+ }
16
+ };
17
+ var unblock = function ($node) {
18
+ $node.removeClass('processing').unblock();
19
+ };
20
+
21
+ var append_image = function (list, i, source, name, filetype) {
22
+
23
+ var $list = $(list);
24
+
25
+ if ((false === filetype.match('application/ms.*') && false === filetype.match('application/x.*') && false === filetype.match('audio.*') && false === filetype.match('text.*') && false === filetype.match('video.*')) || (0 === filetype.length || !filetype)) {
26
+ source = wooccm.icons.interactive;
27
+ }
28
+ if (filetype.match('application/ms.*')) {
29
+ source = wooccm.icons.spreadsheet;
30
+ }
31
+ if (filetype.match('application/x.*')) {
32
+ source = wooccm.icons.archive;
33
+ }
34
+ if (filetype.match('audio.*')) {
35
+ source = wooccm.icons.audio;
36
+ }
37
+ if (filetype.match('text.*')) {
38
+ source = wooccm.icons.text;
39
+ }
40
+ if (filetype.match('video.*')) {
41
+ source = wooccm.icons.video;
42
+ }
43
+
44
+ var html = '<span data-file_id="' + i + '" title="' + name + '" class="wooccmupload_file">\n\
45
+ <span class="wooccmupload_file_container">\n\
46
+ <img alt="' + name + '" src="' + source + '"/>\n\
47
+ <a title="' + name + '" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n\
48
+ </span>\n\
49
+ </span>';
50
+
51
+ $list.append(html).fadeIn();
52
+
53
+ }
54
+
55
+
56
+ // Field
57
+ // ---------------------------------------------------------------------------
58
+
59
+ $('.wooccmupload-field').each(function (i, field) {
60
+
61
+ var $field = $(field),
62
+ $files = $field.find('[type=file]'),
63
+ $button = $field.find('.wooccmupload_button'),
64
+ $list = $field.find('.wooccmupload_list');
65
+
66
+ // Simulate click
67
+ // -------------------------------------------------------------------------
68
+
69
+ $button.on('click', function (e) {
70
+ e.preventDefault();
71
+ $files.trigger('click');
72
+ });
73
+
74
+ // Delete images
75
+ // ---------------------------------------------------------------------------
76
+
77
+ $field.on('click', '.wooccmupload_file_delete', function (e) {
78
+ $(this).closest('.wooccmupload_file').remove();
79
+ });
80
+
81
+ // Append images
82
+ // -------------------------------------------------------------------------
83
+
84
+ $files.on('change', function (e) {
85
+
86
+ var $field = $(field),
87
+ $files = $field.find('[type=file]'),
88
+ files = $files[0].files;
89
+
90
+ if (files.length) {
91
+ $.each(files, function (i, file) {
92
+
93
+ if (window.FileReader) {
94
+
95
+ reader = new FileReader();
96
+
97
+ reader.onload = (function (theFile) {
98
+ return function (e) {
99
+
100
+ setTimeout(function () {
101
+ append_image($list, i, e.target.result, theFile.name, theFile.type);
102
+ }, 200);
103
+
104
+ };
105
+ })(file);
106
+
107
+ reader.readAsDataURL(file);
108
+ }
109
+
110
+ });
111
+ }
112
+
113
+ });
114
+ });
115
+
116
+ // Add class on place order reload if upload field exists
117
+ // ---------------------------------------------------------------------------
118
+
119
+ $('#order_review').on('ajaxSuccess', function (e) {
120
+
121
+ var $order_review = $(e.target),
122
+ $place_order = $order_review.find('#place_order'),
123
+ $fields = $('.wooccmupload-field'),
124
+ fields = $fields.length;
125
+
126
+ if (fields) {
127
+ $place_order.addClass('wooccm-upload-process');
128
+ }
129
+
130
+ });
131
+
132
+ // Upload files
133
+ // ---------------------------------------------------------------------------
134
+
135
+ $(document).on('click', '#place_order.wooccm-upload-process', function (e) {
136
+
137
+ e.preventDefault();
138
+
139
+ var $form = $('form.checkout'),
140
+ $place_order = $(this),
141
+ $results = $('#wooccm_checkout_attachment_results'),
142
+ $fields = $('.wooccmupload-field'),
143
+ fields = $fields.length;
144
+
145
+ $fields.each(function (i, field) {
146
+
147
+ var $field = $(field),
148
+ $files = $field.find('[type=file]'),
149
+ $input = $field.find('.wooccmupload_field'),
150
+ $list = $field.find('.wooccmupload_list'),
151
+ files = $files[0].files;
152
+
153
+ if (window.FormData && files.length) {
154
+
155
+ if (!is_blocked($form)) {
156
+ $place_order.html(wooccm.uploading);
157
+ block($form);
158
+ }
159
+
160
+ var data = new FormData();
161
+
162
+ $.each(files, function (i, file) {
163
+
164
+ if ($list.find('span[data-file_id=' + i + ']').length) {
165
+ console.log('existe: ' + i);
166
+ data.append('wooccm_checkout_attachment_upload[]', file);
167
+ } else {
168
+ console.log('no existe: ' + i);
169
+ }
170
+ });
171
+
172
+ data.append('action', 'wooccm_checkout_attachment_upload');
173
+ data.append('nonce', wooccm.nonce);
174
+
175
+ $.ajax({
176
+ async: false,
177
+ url: wooccm.ajaxurl,
178
+ type: 'POST',
179
+ cache: false,
180
+ data: data,
181
+ processData: false,
182
+ contentType: false,
183
+ beforeSend: function (response) {
184
+ //$place_order.html(wooccm.uploading);
185
+ },
186
+ success: function (response) {
187
+ $results.removeClass('woocommerce-message');
188
+ if (response.success) {
189
+ //console.log(response.data);
190
+ $input.val(response.data);
191
+ } else {
192
+ $results.addClass('woocommerce-error').html(response.data).show();
193
+ }
194
+ },
195
+ complete: function (response) {
196
+ fields = fields - 1;
197
+ //console.log('ajax: fields = ' + fields);
198
+ }
199
+ });
200
+
201
+ } else {
202
+ fields = fields - 1;
203
+ //console.log('no ajax: fields = ' + fields);
204
+ }
205
+
206
+ //console.log('fields = ' + fields);
207
+
208
+ if (fields == 0) {
209
+ //console.log('llamar al click aca');
210
+ unblock($form);
211
+ $place_order.removeClass('wooccm-upload-process').trigger('click');
212
+ //return;
213
+ }
214
+
215
+ });
216
+ //return false;
217
+ //}
218
+ });
219
+
220
+ })(jQuery);
assets/js/wooccm-checkout-upload.min.js ADDED
@@ -0,0 +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 a=function(f){f.removeClass("processing").unblock()};var b=function(m,k,l,g,j){var f=c(m);if((false===j.match("application/ms.*")&&false===j.match("application/x.*")&&false===j.match("audio.*")&&false===j.match("text.*")&&false===j.match("video.*"))||(0===j.length||!j)){l=wooccm.icons.interactive}if(j.match("application/ms.*")){l=wooccm.icons.spreadsheet}if(j.match("application/x.*")){l=wooccm.icons.archive}if(j.match("audio.*")){l=wooccm.icons.audio}if(j.match("text.*")){l=wooccm.icons.text}if(j.match("video.*")){l=wooccm.icons.video}var h='<span data-file_id="'+k+'" title="'+g+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <img alt="'+g+'" src="'+l+'"/>\n <a title="'+g+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n </span>\n </span>';f.append(h).fadeIn()};c(".wooccmupload-field").each(function(h,l){var j=c(l),g=j.find("[type=file]"),k=j.find(".wooccmupload_button"),f=j.find(".wooccmupload_list");k.on("click",function(i){i.preventDefault();g.trigger("click")});j.on("click",".wooccmupload_file_delete",function(i){c(this).closest(".wooccmupload_file").remove()});g.on("change",function(o){var m=c(l),i=m.find("[type=file]"),n=i[0].files;if(n.length){c.each(n,function(q,p){if(window.FileReader){reader=new FileReader();reader.onload=(function(r){return function(s){setTimeout(function(){b(f,q,s.target.result,r.name,r.type)},200)}})(p);reader.readAsDataURL(p)}})}})});c("#order_review").on("ajaxSuccess",function(j){var i=c(j.target),h=i.find("#place_order"),g=c(".wooccmupload-field"),f=g.length;if(f){h.addClass("wooccm-upload-process")}});c(document).on("click","#place_order.wooccm-upload-process",function(k){k.preventDefault();var h=c("form.checkout"),j=c(this),g=c("#wooccm_checkout_attachment_results"),i=c(".wooccmupload-field"),f=i.length;i.each(function(n,r){var o=c(r),m=o.find("[type=file]"),s=o.find(".wooccmupload_field"),l=o.find(".wooccmupload_list"),p=m[0].files;if(window.FormData&&p.length){if(!d(h)){j.html(wooccm.uploading);e(h)}var q=new FormData();c.each(p,function(u,t){if(l.find("span[data-file_id="+u+"]").length){console.log("existe: "+u);q.append("wooccm_checkout_attachment_upload[]",t)}else{console.log("no existe: "+u)}});q.append("action","wooccm_checkout_attachment_upload");q.append("nonce",wooccm.nonce);c.ajax({async:false,url:wooccm.ajaxurl,type:"POST",cache:false,data:q,processData:false,contentType:false,beforeSend:function(t){},success:function(t){g.removeClass("woocommerce-message");if(t.success){s.val(t.data)}else{g.addClass("woocommerce-error").html(t.data).show()}},complete:function(t){f=f-1}})}else{f=f-1}if(f==0){a(h);j.removeClass("wooccm-upload-process").trigger("click")}})})})(jQuery);
assets/js/wooccm-order-upload.js ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+
3
+ var is_blocked = function ($node) {
4
+ return $node.is('.processing') || $node.parents('.processing').length;
5
+ };
6
+ var block = function ($node) {
7
+ if (!is_blocked($node)) {
8
+ $node.addClass('processing').block({
9
+ message: null,
10
+ overlayCSS: {
11
+ background: '#fff',
12
+ opacity: 0.6
13
+ }
14
+ });
15
+ }
16
+ };
17
+ var unblock = function ($node) {
18
+ $node.removeClass('processing').unblock();
19
+ };
20
+
21
+ $(document).ready(function ($) {
22
+
23
+ // Delete
24
+ // -------------------------------------------------------------------------
25
+ $(document).on('click', '.wooccm_delete_attachment', function (e) {
26
+
27
+ var $tr = $(this).closest('tr'),
28
+ attachment_id = $(this).data('attachment_id');
29
+
30
+ $tr.hide();
31
+
32
+ $('#wooccm_order_attachment_update').prop('disabled', false);
33
+
34
+ $('#delete_attachments_ids').val($('#delete_attachments_ids').val().replace(attachment_id, ''));
35
+ });
36
+
37
+ $(document).on('click', '#wooccm_order_attachment_update', function (e) {
38
+
39
+ $.ajax({
40
+ url: wooccm.ajaxurl,
41
+ type: 'POST',
42
+ cache: false,
43
+ data: {
44
+ action: 'wooccm_order_attachment_update',
45
+ nonce: wooccm.nonce,
46
+ delete_attachments_ids: $('#delete_attachments_ids').val(),
47
+ all_attachments_ids: $('#all_attachments_ids').val()
48
+ },
49
+ beforeSend: function (response) {
50
+ $('.wccm_results').html(wooccm.saving);
51
+ },
52
+ success: function (response) {
53
+ if (response.success) {
54
+ $('.wccm_results').html(wooccm.deleted);
55
+ } else {
56
+ $('.wccm_results').html(response.data);
57
+ }
58
+ }
59
+ });
60
+ });
61
+ // Upload
62
+ // -------------------------------------------------------------------------
63
+
64
+ $(document).on('change', '#wooccm_order_attachment_upload', function (e) {
65
+
66
+ var data = false,
67
+ order_id = $(this).data('order_id');
68
+
69
+ if (window.FormData) {
70
+ data = new FormData();
71
+ }
72
+
73
+ var i = 0, len = this.files.length, img, reader, file;
74
+ for (; i < len; i++) {
75
+ file = this.files[i];
76
+ if (data) {
77
+ data.append('wooccm_order_attachment_upload[]', file);
78
+ }
79
+ }
80
+
81
+ /*
82
+ * filter file types
83
+ * var file_array = ' . wooccm_js_array($file_types) . ';
84
+ var wooempt = "' . implode(',', $file_types) . '";
85
+
86
+ for ( i = 0; i < length; i++ ) {
87
+ file = this.files[i];
88
+ for(x=0; x < ' . $number_of_types . '; x++){
89
+ if( !wooempt || file.type.match(file_array[x]) ) {
90
+ if (formdata) {
91
+ formdata.append("files_wccm[]",file);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ */
97
+
98
+ if (data) {
99
+
100
+ data.append('action', 'wooccm_order_attachment_upload');
101
+ data.append('nonce', wooccm.nonce);
102
+ data.append('order_id', order_id);
103
+
104
+ $.ajax({
105
+ url: wooccm.ajaxurl,
106
+ type: 'POST',
107
+ cache: false,
108
+ data: data,
109
+ processData: false,
110
+ contentType: false,
111
+ beforeSend: function (response) {
112
+
113
+ $('.wccm_results').html(wooccm.uploading);
114
+
115
+ block($('#wooccm_order_attachment_inner'));
116
+ },
117
+ success: function (response) {
118
+
119
+ if (response.success) {
120
+ $('#wooccm_order_attachment_inner').replaceWith(response.data);
121
+ $('.wccm_results').html(wooccm.success);
122
+ } else {
123
+ $('.wccm_results').html(response.data);
124
+ }
125
+
126
+ unblock($('#wooccm_order_attachment_inner'));
127
+ }
128
+ });
129
+ }
130
+ });
131
+ });
132
+ })(jQuery);
assets/js/wooccm-order-upload.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(b){var c=function(e){return e.is(".processing")||e.parents(".processing").length};var d=function(e){if(!c(e)){e.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(e){e.removeClass("processing").unblock()};b(document).ready(function(e){e(document).on("click",".wooccm_delete_attachment",function(h){var g=e(this).closest("tr"),f=e(this).data("attachment_id");g.hide();e("#wooccm_order_attachment_update").prop("disabled",false);e("#delete_attachments_ids").val(e("#delete_attachments_ids").val().replace(f,""))});e(document).on("click","#wooccm_order_attachment_update",function(f){e.ajax({url:wooccm.ajaxurl,type:"POST",cache:false,data:{action:"wooccm_order_attachment_update",nonce:wooccm.nonce,delete_attachments_ids:e("#delete_attachments_ids").val(),all_attachments_ids:e("#all_attachments_ids").val()},beforeSend:function(g){e(".wccm_results").html(wooccm.saving)},success:function(g){if(g.success){e(".wccm_results").html(wooccm.deleted)}else{e(".wccm_results").html(g.data)}}})});e(document).on("change","#wooccm_order_attachment_upload",function(m){var l=false,n=e(this).data("order_id");if(window.FormData){l=new FormData()}var k=0,g=this.files.length,h,f,j;for(;k<g;k++){j=this.files[k];if(l){l.append("wooccm_order_attachment_upload[]",j)}}if(l){l.append("action","wooccm_order_attachment_upload");l.append("nonce",wooccm.nonce);l.append("order_id",n);e.ajax({url:wooccm.ajaxurl,type:"POST",cache:false,data:l,processData:false,contentType:false,beforeSend:function(i){e(".wccm_results").html(wooccm.uploading);d(e("#wooccm_order_attachment_inner"))},success:function(i){if(i.success){e("#wooccm_order_attachment_inner").replaceWith(i.data);e(".wccm_results").html(wooccm.success)}else{e(".wccm_results").html(i.data)}a(e("#wooccm_order_attachment_inner"))}})}})})})(jQuery);
assets/less/wooccm.less ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .button {
2
+ &.fileinput-button {
3
+ position: relative;
4
+ overflow: hidden!important;
5
+
6
+ input {
7
+ position: absolute;
8
+ top: 0;
9
+ right: 0;
10
+ margin: 0;
11
+ opacity: 0;
12
+ -ms-filter:'alpha(opacity=0)';
13
+ font-size: 200px;
14
+ direction: ltr;
15
+ cursor: pointer;
16
+ }
17
+
18
+ }
19
+
20
+ }
21
+ .wooccmupload_list {
22
+ margin: 0 -5px;
23
+ padding: 0;
24
+ display: flex;
25
+ flex-wrap: wrap;
26
+ align-items: center;
27
+ justify-content: start;
28
+
29
+ .wooccmupload_file {
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: stretch;
33
+ box-sizing: border-box;
34
+ padding: 10px 5px 0 5px;
35
+ width: 25%;
36
+ max-height: 90px;
37
+ position: relative;
38
+
39
+
40
+ .wooccmupload_file_delete {
41
+ position: absolute;
42
+ top: 2px;
43
+ right: -3px;
44
+ width: 16px;
45
+ height: 16px;
46
+ background-color: #222;
47
+ display: block;
48
+ line-height: 13px;
49
+ text-align: center;
50
+ color: #fefefe;
51
+ font-weight: 900;
52
+ border-radius: 50%;
53
+ font-size: 14px;
54
+ cursor: pointer;
55
+
56
+ }
57
+
58
+ .wooccmupload_file_container {
59
+ width: 100%;
60
+ overflow: hidden;
61
+ }
62
+ }
63
+
64
+ }
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/admin.php CHANGED
@@ -11,7 +11,8 @@ if (is_admin()) {
11
  add_action('admin_init', 'wooccm_admin_actions');
12
  add_action('admin_init', 'wooccm_admin_woocheckout_actions');
13
  // Updater notice
14
- add_action('admin_notices', 'wooccm_admin_notices');
 
15
  // Add fields to the Edit Order screen
16
  add_action('woocommerce_admin_order_data_after_order_details', 'wooccm_admin_edit_order_additional_details');
17
  add_action('woocommerce_admin_order_data_after_billing_address', 'wooccm_admin_edit_order_billing_details');
@@ -930,7 +931,7 @@ function wooccm_options_validate_billing($input) {
930
  return $input;
931
  }
932
 
933
- function wooccm_admin_notices() {
934
 
935
  // Check the User has the manage_options capability
936
  if (current_user_can('manage_options') == false)
@@ -956,7 +957,7 @@ function wooccm_admin_notices() {
956
  </p>';
957
  echo wooccm_admin_notice_html($message);
958
  }
959
- }
960
 
961
  function wooccm_admin_updater_notice() {
962
 
@@ -1416,7 +1417,7 @@ function wooccm_admin_edit_order_shipping_details($order) {
1416
  }
1417
  }
1418
 
1419
- function wooccm_validate_upload_process_customer() {
1420
 
1421
  $options = get_option('wccs_settings');
1422
 
@@ -1425,23 +1426,25 @@ function wooccm_validate_upload_process_customer() {
1425
  } else {
1426
  return false;
1427
  }
1428
- }
1429
 
1430
  // Check if the customer can upload images
1431
  // @mod - This disables the Order Uploaded Files meta box even for Administrators...?
1432
- if (wooccm_validate_upload_process_customer()) {
 
 
1433
  add_action('woocommerce_view_order', 'wooccm_file_uploader_front_end');
1434
  add_action('add_meta_boxes', 'wooccm_admin_edit_order_metaboxes');
1435
- }
1436
 
1437
- function wooccm_admin_edit_order_metaboxes() {
1438
 
1439
  global $post;
1440
 
1441
  $post_type = 'shop_order';
1442
  add_meta_box('woocommerce-order-files', __('Order Uploaded Files', 'woocommerce-checkout-manager'), 'wooccm_admin_edit_order_uploaded_files_meta_box', $post_type, 'normal', 'default');
1443
- }
1444
-
1445
  function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1446
 
1447
  global $wpdb, $thepostid, $theorder, $woocommerce, $post;
@@ -1605,7 +1608,7 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1605
  <td>' . strtoupper($wp_filetype['ext']) . '</td>
1606
  <td class="column-actions" nowrap>
1607
  <a href="' . $image_attributes2[0] . '" target="_blank" class="button">' . __('Download', 'woocommerce-checkout-manager') . '</a>
1608
- <a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete file', 'woocommerce-checkout-manager') . '">' . __('Delete file', 'woocommerce-checkout-manager') . '</a>
1609
  </td>
1610
  </tr>
1611
  ';
@@ -1669,7 +1672,7 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1669
  success: function (res) {
1670
  $('#files_wccm').show();
1671
  $(".wccm_results").html("Files uploaded successfully.");
1672
- /* $(".wccm_results").html(res); */
1673
 
1674
  $.ajax({
1675
  url: '<?php echo admin_url('/post.php?post=' . $post->ID . '&action=edit'); ?>',
@@ -1677,7 +1680,7 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1677
  success: function (data) {
1678
  $("div#product_images_container").html($(data).find("div#product_images_container"));
1679
  $(".wccm_results").html("Files uploaded successfully.");
1680
- /* $(".wccm_results").html(data); */
1681
  },
1682
  dataType: 'html'
1683
  });
@@ -1699,9 +1702,11 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1699
  </div>
1700
  <!-- .woocommerce_order_items_wrapper -->
1701
  <?php
1702
- }
1703
 
1704
- // front end for user
 
 
1705
  function wooccm_file_uploader_front_end($order_id) {
1706
 
1707
  global $wpdb, $thepostid, $theorder, $woocommerce, $post;
@@ -1768,7 +1773,7 @@ function wooccm_file_uploader_front_end($order_id) {
1768
 
1769
  <h2><?php echo ( empty($options['checkness']['upload_title']) ? 'Order Uploaded Files' : esc_attr($options['checkness']['upload_title']) ); ?></h2>
1770
  <div class="woocommerce_order_items_wrapper front_end">
1771
- <table class="woocommerce_order_items front_end">
1772
 
1773
  <thead>
1774
  <tr>
@@ -1823,7 +1828,7 @@ function wooccm_file_uploader_front_end($order_id) {
1823
  </td>
1824
  <td>' . strtoupper($wp_filetype['ext']) . '</td>
1825
  <td class="column-actions" nowrap>
1826
- <a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete file', 'woocommerce-checkout-manager') . '">' . __('Delete file', 'woocommerce-checkout-manager') . '</a>
1827
  </td>
1828
  </tr>';
1829
  }
@@ -1938,8 +1943,8 @@ jQuery(document).ready(function($){
1938
  // ------------
1939
  }
1940
  }
1941
-
1942
- function wccs_upload_file_func_callback($order_id) {
1943
 
1944
  $name = ( isset($_REQUEST['name']) ? $_REQUEST['name'] : false );
1945
  $order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
@@ -2058,14 +2063,17 @@ function wccs_upload_file_func_callback($order_id) {
2058
  echo ' ' . __('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
2059
  }
2060
  die();
2061
- }
2062
 
2063
- add_action("wp_ajax_wccs_upload_file_func", "wccs_upload_file_func_callback");
 
2064
 
2065
- function wooccm_set_html_content_type() {
 
 
2066
 
2067
  return 'text/html';
2068
- }
2069
 
2070
  function wooccm_js_str($s) {
2071
 
@@ -2078,7 +2086,7 @@ function wooccm_js_array($array) {
2078
  return '[' . implode(',', $temp) . ']';
2079
  }
2080
 
2081
- function update_attachment_wccm_callback() {
2082
 
2083
  global $post, $wpdb, $woocommerce;
2084
 
@@ -2114,7 +2122,6 @@ function update_attachment_wccm_callback() {
2114
  echo __('Deleted successfully.', 'woocommerce-checkout-manager');
2115
  }
2116
  die();
2117
- }
2118
 
2119
- add_action('wp_ajax_update_attachment_wccm', 'update_attachment_wccm_callback');
2120
- ?>
11
  add_action('admin_init', 'wooccm_admin_actions');
12
  add_action('admin_init', 'wooccm_admin_woocheckout_actions');
13
  // Updater notice
14
+ //1326
15
+ //add_action('admin_notices', 'wooccm_admin_notices');
16
  // Add fields to the Edit Order screen
17
  add_action('woocommerce_admin_order_data_after_order_details', 'wooccm_admin_edit_order_additional_details');
18
  add_action('woocommerce_admin_order_data_after_billing_address', 'wooccm_admin_edit_order_billing_details');
931
  return $input;
932
  }
933
 
934
+ /*function wooccm_admin_notices() {
935
 
936
  // Check the User has the manage_options capability
937
  if (current_user_can('manage_options') == false)
957
  </p>';
958
  echo wooccm_admin_notice_html($message);
959
  }
960
+ }*/
961
 
962
  function wooccm_admin_updater_notice() {
963
 
1417
  }
1418
  }
1419
 
1420
+ /*function wooccm_validate_upload_process_customer() {
1421
 
1422
  $options = get_option('wccs_settings');
1423
 
1426
  } else {
1427
  return false;
1428
  }
1429
+ }*/
1430
 
1431
  // Check if the customer can upload images
1432
  // @mod - This disables the Order Uploaded Files meta box even for Administrators...?
1433
+ /*
1434
+ * 1326
1435
+ * if (wooccm_validate_upload_process_customer()) {
1436
  add_action('woocommerce_view_order', 'wooccm_file_uploader_front_end');
1437
  add_action('add_meta_boxes', 'wooccm_admin_edit_order_metaboxes');
1438
+ }*/
1439
 
1440
+ /*function wooccm_admin_edit_order_metaboxes() {
1441
 
1442
  global $post;
1443
 
1444
  $post_type = 'shop_order';
1445
  add_meta_box('woocommerce-order-files', __('Order Uploaded Files', 'woocommerce-checkout-manager'), 'wooccm_admin_edit_order_uploaded_files_meta_box', $post_type, 'normal', 'default');
1446
+ }*/
1447
+ /*
1448
  function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
1449
 
1450
  global $wpdb, $thepostid, $theorder, $woocommerce, $post;
1608
  <td>' . strtoupper($wp_filetype['ext']) . '</td>
1609
  <td class="column-actions" nowrap>
1610
  <a href="' . $image_attributes2[0] . '" target="_blank" class="button">' . __('Download', 'woocommerce-checkout-manager') . '</a>
1611
+ <a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
1612
  </td>
1613
  </tr>
1614
  ';
1672
  success: function (res) {
1673
  $('#files_wccm').show();
1674
  $(".wccm_results").html("Files uploaded successfully.");
1675
+
1676
 
1677
  $.ajax({
1678
  url: '<?php echo admin_url('/post.php?post=' . $post->ID . '&action=edit'); ?>',
1680
  success: function (data) {
1681
  $("div#product_images_container").html($(data).find("div#product_images_container"));
1682
  $(".wccm_results").html("Files uploaded successfully.");
1683
+
1684
  },
1685
  dataType: 'html'
1686
  });
1702
  </div>
1703
  <!-- .woocommerce_order_items_wrapper -->
1704
  <?php
1705
+ }*/
1706
 
1707
+ /*
1708
+ * 1326
1709
+ * front end for user
1710
  function wooccm_file_uploader_front_end($order_id) {
1711
 
1712
  global $wpdb, $thepostid, $theorder, $woocommerce, $post;
1773
 
1774
  <h2><?php echo ( empty($options['checkness']['upload_title']) ? 'Order Uploaded Files' : esc_attr($options['checkness']['upload_title']) ); ?></h2>
1775
  <div class="woocommerce_order_items_wrapper front_end">
1776
+ <table class="shop_table woocommerce_order_items front_end">
1777
 
1778
  <thead>
1779
  <tr>
1828
  </td>
1829
  <td>' . strtoupper($wp_filetype['ext']) . '</td>
1830
  <td class="column-actions" nowrap>
1831
+ <a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
1832
  </td>
1833
  </tr>';
1834
  }
1943
  // ------------
1944
  }
1945
  }
1946
+ */
1947
+ /*function wccs_upload_file_func_callback($order_id) {
1948
 
1949
  $name = ( isset($_REQUEST['name']) ? $_REQUEST['name'] : false );
1950
  $order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
2063
  echo ' ' . __('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
2064
  }
2065
  die();
2066
+ }*/
2067
 
2068
+ //1326
2069
+ //add_action("wp_ajax_wccs_upload_file_func", "wccs_upload_file_func_callback");
2070
 
2071
+ /*
2072
+ * 1326
2073
+ * function wooccm_set_html_content_type() {
2074
 
2075
  return 'text/html';
2076
+ }*/
2077
 
2078
  function wooccm_js_str($s) {
2079
 
2086
  return '[' . implode(',', $temp) . ']';
2087
  }
2088
 
2089
+ /*function update_attachment_wccm_callback() {
2090
 
2091
  global $post, $wpdb, $woocommerce;
2092
 
2122
  echo __('Deleted successfully.', 'woocommerce-checkout-manager');
2123
  }
2124
  die();
2125
+ }*/
2126
 
2127
+ //add_action('wp_ajax_update_attachment_wccm', 'update_attachment_wccm_callback');
 
includes/checkout.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  // Decides where the Additional Checkout fields appear on the Checkout page
3
- function wooccm_checkout_additional_positioning() {
 
 
4
 
5
  $options = get_option( 'wccs_settings' );
6
  // Defaults to after_order_notes
@@ -17,7 +19,7 @@ function wooccm_checkout_additional_positioning() {
17
 
18
  }
19
 
20
- }
21
 
22
  function wooccm_checkout_default_address_fields( $fields = array() ) {
23
 
@@ -126,162 +128,10 @@ var ajaxnonce = "' . wp_create_nonce( "wccs_ajax_nonce" ) . '";
126
  }
127
  }
128
 
129
- @media screen and (max-width: 770px) {
130
- .checkout .wooccm_each_file .wooccm-image-holder {
131
- width: 20%;
132
- }
133
- .checkout name.wooccm_name, .wooccm_each_file span.container{
134
- width: 80%;
135
- }
136
- .checkout .container .wooccm-btn {
137
- padding: 1% 10%;
138
- }
139
- }
140
-
141
- @media screen and (max-width: 992px) {
142
- .wooccm_each_file .wooccm-image-holder {
143
- width: 26%;
144
- }
145
- name.wooccm_name, .wooccm_each_file span.container{
146
- width: 74%;
147
- }
148
- .container .wooccm-btn {
149
- padding: 5px 8px;
150
- font-size: 12px;
151
- }
152
- }
153
-
154
  .container .wooccm-btn {
155
  padding: 1.7% 6.7%;
156
  }
157
 
158
- #caman_content .blockUI.blockOverlay:before, #caman_content .loader:before {
159
- height: 1em;
160
- width: 1em;
161
- position: absolute;
162
- top: 50%;
163
- left: 50%;
164
- margin-left: -.5em;
165
- margin-top: -.5em;
166
- display: block;
167
- -webkit-animation: spin 1s ease-in-out infinite;
168
- -moz-animation: spin 1s ease-in-out infinite;
169
- animation: spin 1s ease-in-out infinite;
170
- content: "";
171
- /* @mod - We need to check this file exists */
172
- background: url('.plugins_url( 'woocommerce/assets/images/icons/loader.svg' ).') center center/cover;
173
- line-height: 1;
174
- text-align: center;
175
- font-size: 2em;
176
- color: rgba(0,0,0,.75);
177
- }
178
- body.admin-bar #caman_content {
179
- margin-top: 32px;
180
- }
181
-
182
- .file_upload_button_hide {
183
- display: none;
184
- }
185
-
186
- .wooccm_each_file {
187
- display: block;
188
- padding-top: 20px;
189
- clear: both;
190
- text-align: center;
191
- }
192
- .wooccm_each_file .wooccm-image-holder {
193
- width: 20%;
194
- display: block;
195
- float: left;
196
- }
197
- .wooccm-btn.disable {
198
- margin-right: 10px;
199
- cursor: auto;
200
- }
201
- zoom.wooccm_zoom, edit.wooccm_edit, dele.wooccm_dele {
202
- padding: 5px;
203
- }
204
- .wooccm_each_file name {
205
- font-size: 18px;
206
- }
207
- name.wooccm_name, .wooccm_each_file span.container {
208
- display: block;
209
- padding: 0 0 10px 20px;
210
- float: left;
211
- width: 80%;
212
- }
213
-
214
- .wooccm_each_file img{
215
- display: inline-block;
216
- height: 90px;
217
- border: 2px solid #767676;
218
- border-radius: 4px;
219
- }
220
- .file_upload_account:before{ content: "\f317";font-family: dashicons; margin-right: 10px; }
221
- .wooccm_each_file .wooccm_zoom:before{ content: "\f179";font-family: dashicons; margin-right: 5px; }
222
- .wooccm_each_file .wooccm_edit:before{ content: "\f464";font-family: dashicons; margin-right: 5px; }
223
- .wooccm_each_file .wooccm_dele:before{ content: "\f158";font-family: dashicons; margin-right: 5px; }
224
- .wooccm-btn{
225
- display: inline-block;
226
- padding: 6px 12px;
227
- margin-bottom: 0;
228
- font-size: 14px;
229
- font-weight: 400;
230
- line-height: 1.42857143;
231
- text-align: center;
232
- white-space: nowrap;
233
- vertical-align: middle;
234
- cursor: pointer;
235
- -webkit-user-select: none;
236
- -moz-user-select: none;
237
- -ms-user-select: none;
238
- user-select: none;
239
- background-image: none;
240
- border: 1px solid transparent;
241
- border-radius: 4px;
242
- font-family: "Raleway", Arial, Helvetica, sans-serif;
243
- color: #767676;
244
- background-color: buttonface;
245
- align-items: flex-start;
246
- text-indent: 0px;
247
- text-shadow: none;
248
- letter-spacing: normal;
249
- word-spacing: normal;
250
- text-rendering: auto;
251
- }
252
- .wooccm-btn-primary {
253
- width: 100%;
254
- color: #fff;
255
- background-color: #428bca;
256
- border-color: #357ebd;
257
- }
258
-
259
- .wooccm-btn-danger {
260
- color: #fff;
261
- background-color: #d9534f;
262
- border-color: #d43f3a;
263
- margin-right: 10px;
264
- }
265
- .wooccm_each_file .container a:hover, .wooccm_each_file .container a:focus, .wooccm_each_file .container a:active, .wooccm_each_file .container a:visited, .wooccm_each_file .container a:link {
266
- color: #fff;
267
- }
268
- #caman_content #wooccmtoolbar #close:hover, #caman_content #wooccmtoolbar #save:hover {
269
- background: #1b1917;
270
- }
271
- .wooccm-btn-zoom {
272
- color: #fff;
273
- background-color: #5cb85c;
274
- border-color: #4cae4c;
275
- margin-right: 10px;
276
- }
277
-
278
- .wooccm-btn-edit {
279
- color: #fff;
280
- background-color: #f0ad4e;
281
- border-color: #eea236;
282
- margin-right: 10px;
283
- }
284
-
285
  </style>
286
  ';
287
 
@@ -332,7 +182,7 @@ function wooccm_checkout_text_before(){
332
  }
333
 
334
  // We are overriding the default Order Post meta values with our own secret sauce
335
- function wooccm_custom_checkout_field_update_order_meta( $order ) {
336
 
337
  // Additional section
338
  $options = get_option( 'wccs_settings' );
@@ -341,15 +191,15 @@ function wooccm_custom_checkout_field_update_order_meta( $order ) {
341
  foreach( $buttons as $btn ) {
342
  if( $btn['type'] == 'wooccmtextarea' ) {
343
  if( !empty( $_POST[$btn['cow']] ) ) {
344
- update_post_meta( $order, $btn['cow'] , wp_kses( $_POST[ $btn['cow']], false ) );
345
  }
346
  } else if( $btn['type'] !== 'multiselect' && $btn['type'] !== 'multicheckbox' ) {
347
  if( !empty( $_POST[$btn['cow']] ) ) {
348
- update_post_meta( $order, $btn['cow'] , sanitize_text_field( $_POST[ $btn['cow'] ] ) );
349
  }
350
  } elseif( $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox' ) {
351
  if( !empty( $_POST[$btn['cow']] ) ) {
352
- update_post_meta( $order, $btn['cow'] , maybe_serialize( array_map( 'sanitize_text_field', $_POST[$btn['cow']] ) ) );
353
  }
354
  }
355
  }
@@ -362,7 +212,7 @@ function wooccm_custom_checkout_field_update_order_meta( $order ) {
362
  foreach( $buttons as $btn ) {
363
  if( $btn['type'] == 'wooccmtextarea' ) {
364
  if( !empty( $_POST[sprintf( 'shipping_%s', $btn['cow'] )] ) ) {
365
- update_post_meta( $order, sprintf( '_shipping_%s', $btn['cow'] ), wp_kses( $_POST[sprintf( 'shipping_%s', $btn['cow'] )], false ) );
366
  }
367
  }
368
  }
@@ -375,7 +225,7 @@ function wooccm_custom_checkout_field_update_order_meta( $order ) {
375
  foreach( $buttons as $btn ) {
376
  if( $btn['type'] == 'wooccmtextarea' ) {
377
  if( !empty( $_POST[sprintf( 'billing_%s', $btn['cow'] )] ) ) {
378
- update_post_meta( $order, sprintf( '_billing_%s', $btn['cow'] ), wp_kses( $_POST[sprintf( 'billing_%s', $btn['cow'] )], false ) );
379
  }
380
  }
381
  }
1
  <?php
2
  // Decides where the Additional Checkout fields appear on the Checkout page
3
+ /*
4
+ * 1326
5
+ * function wooccm_checkout_additional_positioning() {
6
 
7
  $options = get_option( 'wccs_settings' );
8
  // Defaults to after_order_notes
19
 
20
  }
21
 
22
+ }*/
23
 
24
  function wooccm_checkout_default_address_fields( $fields = array() ) {
25
 
128
  }
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  .container .wooccm-btn {
132
  padding: 1.7% 6.7%;
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  </style>
136
  ';
137
 
182
  }
183
 
184
  // We are overriding the default Order Post meta values with our own secret sauce
185
+ function wooccm_custom_checkout_field_update_order_meta( $order_id ) {
186
 
187
  // Additional section
188
  $options = get_option( 'wccs_settings' );
191
  foreach( $buttons as $btn ) {
192
  if( $btn['type'] == 'wooccmtextarea' ) {
193
  if( !empty( $_POST[$btn['cow']] ) ) {
194
+ update_post_meta( $order_id, $btn['cow'] , wp_kses( $_POST[ $btn['cow']], false ) );
195
  }
196
  } else if( $btn['type'] !== 'multiselect' && $btn['type'] !== 'multicheckbox' ) {
197
  if( !empty( $_POST[$btn['cow']] ) ) {
198
+ update_post_meta( $order_id, $btn['cow'] , sanitize_text_field( $_POST[ $btn['cow'] ] ) );
199
  }
200
  } elseif( $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox' ) {
201
  if( !empty( $_POST[$btn['cow']] ) ) {
202
+ update_post_meta( $order_id, $btn['cow'] , maybe_serialize( array_map( 'sanitize_text_field', $_POST[$btn['cow']] ) ) );
203
  }
204
  }
205
  }
212
  foreach( $buttons as $btn ) {
213
  if( $btn['type'] == 'wooccmtextarea' ) {
214
  if( !empty( $_POST[sprintf( 'shipping_%s', $btn['cow'] )] ) ) {
215
+ update_post_meta( $order_id, sprintf( '_shipping_%s', $btn['cow'] ), wp_kses( $_POST[sprintf( 'shipping_%s', $btn['cow'] )], false ) );
216
  }
217
  }
218
  }
225
  foreach( $buttons as $btn ) {
226
  if( $btn['type'] == 'wooccmtextarea' ) {
227
  if( !empty( $_POST[sprintf( 'billing_%s', $btn['cow'] )] ) ) {
228
+ update_post_meta( $order_id, sprintf( '_billing_%s', $btn['cow'] ), wp_kses( $_POST[sprintf( 'billing_%s', $btn['cow'] )], false ) );
229
  }
230
  }
231
  }
includes/template.php CHANGED
@@ -1,745 +1,732 @@
1
  <?php
2
- function wooccm_front_end_upload() {
3
-
4
- check_ajax_referer( 'wccs_ajax_nonce', 'nonce' );
5
-
6
- $name = ( isset( $_REQUEST["name"] ) ? $_REQUEST["name"] : false );
7
-
8
- // Check if a file has been uploaded
9
- if( empty( $_FILES ) ) {
10
- wooccm_error_log( '[' . $name . '] $_FILES is empty' );
11
- return;
12
- }
13
-
14
- // Check if the $_REQUEST name attribute matches the $_FILES field name
15
- if( !isset( $_FILES[$name] ) ) {
16
- wooccm_error_log( '[' . $name . '] $_REQUEST name does not match' );
17
- return;
18
- }
19
-
20
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
21
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
22
-
23
- $wp_upload_dir = wp_upload_dir();
24
-
25
- $number_of_files = 0;
26
- $attach_ids = array();
27
-
28
- $files = $_FILES[$name];
29
- foreach( $files['name'] as $key => $value ) {
30
- if( $files['name'][$key] ) {
31
- $file = array(
32
- 'name' => $_FILES[$name]['name'][$key],
33
- 'type' => $_FILES[$name]['type'][$key],
34
- 'tmp_name' => $_FILES[$name]['tmp_name'][$key],
35
- 'error' => $_FILES[$name]['error'][$key],
36
- 'size' => $_FILES[$name]['size'][$key]
37
- );
38
- $upload_overrides = array( 'test_form' => false );
39
- $movefile = wp_handle_upload( $file, $upload_overrides );
40
-
41
- // Check if upload was successful
42
- if( isset( $movefile['error'] ) && $movefile['error'] > 0 ) {
43
- wooccm_error_log( '[' . $name . '] upload failed: ' . print_r( $movefile, true ) );
44
- return;
45
- }
46
-
47
- $post_title = basename( $file['name'] );
48
- if( isset( $movefile['file'] ) )
49
- $post_title = basename( $movefile['file'] );
50
- $attachment = array(
51
- 'guid' => ( isset( $movefile['url'] ) ? $movefile['url'] : false ),
52
- 'post_mime_type' => ( isset( $movefile['type'] ) ? $movefile['type'] : $file['type'] ),
53
- 'post_title' => preg_replace( '/\.[^.]+$/', '', $post_title ),
54
- 'post_content' => '',
55
- 'post_status' => 'inherit'
56
- );
57
-
58
- if( !empty( $movefile['url'] ) ) {
59
- $attach_id = wp_insert_attachment( $attachment, $movefile['url'] );
60
- $attach_ids[] = $attach_id;
61
- $number_of_files++;
62
- // echo json_encode( array( $number_of_files, $attach_id ) );
63
- }
64
-
65
- }
66
- }
67
-
68
- if( !empty( $attach_ids ) ) {
69
- $output = implode( ',', $attach_ids );
70
- $output = json_encode( $output );
71
- echo $output;
72
- }
73
-
74
- die();
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
 
77
  add_action("wp_ajax_wooccm_front_end_upload", "wooccm_front_end_upload");
78
  add_action("wp_ajax_nopriv_wooccm_front_end_upload", "wooccm_front_end_upload");
 
79
 
80
- function wooccm_front_end_upload_save() {
81
-
82
- global $wpdb, $woocommerce, $post;
83
-
84
- check_ajax_referer( 'wccs_ajax_nonce', 'nonce' );
85
 
86
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
87
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
88
 
89
- $name = ( isset( $_REQUEST["name"] ) ? $_REQUEST["name"] : false );
90
- $attachtoremove = ( isset( $_REQUEST["remove"] ) ? $_REQUEST["remove"] : false );
91
 
92
- if( !empty( $attachtoremove ) ) {
93
- // Check the Attachment exists...
94
- if( get_post_status( $attachtoremove ) == false )
95
- die();
96
 
97
- // Check the Attachment is associated with an Order
98
- $post_parent = get_post_field( 'post_parent', $attachtoremove );
99
- if( empty( $post_parent ) ) {
100
- die();
101
- } else {
102
- if( get_post_type( $post_parent ) <> 'shop_order' )
103
- die();
104
- }
105
 
106
- // Delete the Attachment
107
- wp_delete_attachment( $attachtoremove );
108
- }
 
 
 
 
 
109
 
110
- $file = array(
111
- 'name' => $_FILES[$name]['name'],
112
- 'type' => $_FILES[$name]['type'],
113
- 'tmp_name' => $_FILES[$name]['tmp_name'],
114
- 'error' => $_FILES[$name]['error'],
115
- 'size' => $_FILES[$name]['size']
116
- );
117
 
118
- $upload_overrides = array( 'test_form' => false );
119
- $movefile = wp_handle_upload( $file, $upload_overrides );
 
 
 
 
 
120
 
121
- $attachment = array(
122
- 'guid' => $movefile['url'],
123
- 'post_mime_type' => $movefile['type'],
124
- 'post_title' => preg_replace( '/\.[^.]+$/', '', basename($movefile['file'])),
125
- 'post_content' => '',
126
- 'post_status' => 'inherit'
127
- );
128
 
129
- $attach_id = wp_insert_attachment( $attachment, $movefile['url'] );
 
 
 
 
 
 
130
 
131
- echo json_encode( $attach_id );
132
 
133
- die();
134
 
 
 
135
  }
 
136
  //frontend handle
137
  add_action("wp_ajax_wooccm_front_end_upload_save", "wooccm_front_end_upload_save");
138
- add_action("wp_ajax_nopriv_wooccm_front_end_upload_save", "wooccm_front_end_upload_save");
139
-
140
- function wooccm_update_attachment_ids( $order_id = 0 ) {
141
-
142
- $has_uploads = false;
143
- $email_attachments = array();
144
-
145
- $shipping = array(
146
- 'country',
147
- 'first_name',
148
- 'last_name',
149
- 'company',
150
- 'address_1',
151
- 'address_2',
152
- 'city',
153
- 'state',
154
- 'postcode'
155
- );
156
- $billing = array(
157
- 'country',
158
- 'first_name',
159
- 'last_name',
160
- 'company',
161
- 'address_1',
162
- 'address_2',
163
- 'city',
164
- 'state',
165
- 'postcode',
166
- 'email',
167
- 'phone'
168
- );
169
-
170
- $names = array(
171
- 'billing',
172
- 'shipping'
173
- );
174
- $inc = 3;
175
-
176
- foreach( $names as $name ) {
177
-
178
- $array = ( $name == 'billing' ) ? $billing : $shipping;
179
-
180
- $options = get_option( 'wccs_settings'.$inc );
181
- if( !empty( $options[sprintf( '%s_buttons', $name )] ) ) {
182
- foreach( $options[sprintf( '%s_buttons', $name )] as $btn ) {
183
-
184
- if( !in_array( $btn['cow'], $array ) ) {
185
- if( $btn['type'] == 'wooccmupload' ) {
186
- $attachments = get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true );
187
- if( !empty( $attachments ) ) {
188
-
189
- // Check for delimiter
190
- if( strstr( $attachments, '||' ) !== false )
191
- $attachments = explode( '||', $attachments );
192
- else if( strstr( $attachments, ',' ) !== false )
193
- $attachments = explode( ',', $attachments );
194
- else
195
- $attachments = array( $attachments );
196
-
197
- if( !empty( $attachments ) ) {
198
- foreach( $attachments as $image_id ) {
199
-
200
- if( !empty( $image_id ) ) {
201
- $has_uploads = true;
202
- wp_update_post( array( 'ID' => $image_id, 'post_parent' => $order_id ) );
203
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
204
- wp_update_attachment_metadata( $image_id, wp_generate_attachment_metadata( $image_id, get_attached_file( $image_id ) ) );
205
- $email_attachments[] = get_attached_file( $image_id );
206
- }
207
-
208
- }
209
- }
210
- }
211
- }
212
- }
213
-
214
- }
215
- }
216
- $inc--;
217
- }
218
-
219
- $options = get_option( 'wccs_settings' );
220
- $buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : false );
221
- if( !empty( $buttons ) ) {
222
- foreach( $buttons as $btn ) {
223
-
224
- if( $btn['type'] == 'wooccmupload' ) {
225
- $attachments = get_post_meta( $order_id , $btn['cow'], true );
226
- if( !empty( $attachments ) ) {
227
-
228
- // Check for delimiter
229
- if( strstr( $attachments, '||' ) !== false )
230
- $attachments = explode( '||', $attachments );
231
- else if( strstr( $attachments, ',' ) !== false )
232
- $attachments = explode( ',', $attachments );
233
- else if( is_numeric( $attachments ) )
234
- $attachments = array( $attachments );
235
-
236
- if( !is_array( $attachments ) )
237
- continue;
238
-
239
- foreach( $attachments as $image_id ) {
240
-
241
- if( !empty( $image_id ) ) {
242
- $has_uploads = true;
243
- wp_update_post( array( 'ID' => $image_id, 'post_parent' => $order_id ) );
244
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
245
- wp_update_attachment_metadata( $image_id, wp_generate_attachment_metadata( $image_id, get_attached_file( $image_id ) ) );
246
- $email_attachments[] = get_attached_file( $image_id );
247
- }
248
-
249
- }
250
- }
251
- }
252
-
253
- }
254
- }
255
-
256
- if( $has_uploads ) {
257
-
258
- $order = new WC_Order( $order_id );
259
-
260
- // send email
261
- $email_recipients = $options['checkness']['wooccm_notification_email'];
262
- if( empty( $email_recipients ) )
263
- $email_recipients = get_option( 'admin_email' );
264
- $email_heading = __( 'Files Uploaded at Checkout', 'woocommerce-checkout-manager' );
265
- $subject = sprintf( __( 'WooCommerce Checkout Manager - %s', 'woocommerce-checkout-manager' ), $email_heading );
266
-
267
- $mailer = WC()->mailer();
268
-
269
- // Buffer
270
- ob_start();
271
- ?>
272
- <p>This is an automatic message from WooCommerce Checkout Manager, reporting that files have been uploaded by <?php echo $order->billing_first_name; ?> <?php echo $order->billing_last_name; ?>.</p>
273
- <h3>Customer Details</h3>
274
- <ul>
275
- <li>Name: <?php echo $order->billing_first_name; ?> <?php $order->billing_last_name; ?></li>
276
- <li>E-mail: <?php echo $order->billing_email; ?></li>
277
- <li>Order Number: <?php echo $order_id; ?></li>
278
- </ul>
279
- <p>You can view the files and order details via back-end by following this <a href="<?php echo admin_url( '/post.php?post='.$order_id.'&action=edit' ); ?>" target="_blank">link</a>.</p>
280
- <?php
281
- // Get contents
282
- $message = ob_get_clean();
283
-
284
- $message = $mailer->wrap_message( $email_heading, $message );
285
-
286
- // add_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
287
- // wc_mail( $email_recipients, $message_subject, $message_content );
288
- $mailer->send( $email_recipients, strip_tags( $subject ), $message, $email_attachments );
289
- // remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
290
 
291
- }
292
 
293
- }
294
- add_action( 'woocommerce_thankyou', 'wooccm_update_attachment_ids' );
295
  // @mod - Change to thank you page to catch all Order Status
296
  // add_action( 'woocommerce_order_status_completed', 'wooccm_update_attachment_ids' );
297
-
298
  // Checkout - Order Received
299
- function wooccm_order_received_checkout_details( $order ) {
300
-
301
- if( version_compare( wooccm_get_woo_version(), '2.7', '>=' ) )
302
- $order_id = ( method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id );
303
- else
304
- $order_id = ( isset( $order->id ) ? $order->id : 0 );
305
-
306
- $shipping = array(
307
- 'country',
308
- 'first_name',
309
- 'last_name',
310
- 'company',
311
- 'address_1',
312
- 'address_2',
313
- 'city',
314
- 'state',
315
- 'postcode'
316
- );
317
- $billing = array(
318
- 'country',
319
- 'first_name',
320
- 'last_name',
321
- 'company',
322
- 'address_1',
323
- 'address_2',
324
- 'city',
325
- 'state',
326
- 'postcode',
327
- 'email',
328
- 'phone'
329
- );
330
-
331
- $names = array(
332
- 'billing',
333
- 'shipping'
334
- );
335
- $inc = 3;
336
-
337
- $show_table = apply_filters( 'wooccm_order_received_checkout_show_table', ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.3', '>=' ) ) );
338
- $print_table = apply_filters( 'wooccm_order_received_checkout_print_table', true );
339
-
340
- // Check if above WooCommerce 2.3+
341
- if( $show_table ) {
342
-
343
- if( $print_table ) {
344
- echo '<table class="wccs_custom_fields shop_table">';
345
- }
346
-
347
- foreach( $names as $name ) {
348
-
349
- $array = ( $name == 'billing' ) ? $billing : $shipping;
350
-
351
- $options = get_option( 'wccs_settings'.$inc );
352
- if( !empty( $options[sprintf( '%s_buttons', $name )] ) ) {
353
- foreach( $options[sprintf( '%s_buttons', $name )] as $btn ) {
354
-
355
- if( !in_array( $btn['cow'], $array ) ) {
356
- if(
357
- ( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true) !== '' ) &&
358
- !empty( $btn['label'] ) &&
359
- empty( $btn['deny_receipt'] ) &&
360
- $btn['type'] !== 'heading' &&
361
- $btn['type'] !== 'wooccmupload' &&
362
- $btn['type'] !== 'multiselect' &&
363
- $btn['type'] !== 'multicheckbox'
364
- ) {
365
- echo '
366
  <tr>
367
- <th>'.wooccm_wpml_string($btn['label']).':</th>
368
- <td>'.nl2br( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true ) ).'</td>
369
  </tr>';
370
- } elseif (
371
- !empty( $btn['label'] ) &&
372
- empty( $btn['deny_receipt'] ) &&
373
- $btn['type'] !== 'multiselect' &&
374
- $btn['type'] !== 'multicheckbox' &&
375
- $btn['type'] == 'heading'
376
- ) {
377
- echo '
378
  <tr>
379
- <th colspan="2">' .wooccm_wpml_string($btn['label']). '</th>
380
  </tr>';
381
- } elseif (
382
- ( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true) !== '') &&
383
- $btn['type'] !== 'wooccmupload' &&
384
- !empty( $btn['label'] ) &&
385
- empty( $btn['deny_receipt'] ) &&
386
- $btn['type'] !== 'heading' &&
387
- (
388
- ( $btn['type'] == 'multiselect' ) || ( $btn['type'] == 'multicheckbox' )
389
- )
390
- ) {
391
- $value = get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true );
392
- $strings = maybe_unserialize( $value );
393
- echo '
394
  <tr>
395
- <th>'.wooccm_wpml_string( $btn['label'] ).':</th>
396
- <td data-title="' . wooccm_wpml_string( $btn['label'] ) . '">';
397
- if( !empty( $strings ) ) {
398
- if( is_array( $strings ) ) {
399
- foreach( $strings as $key ) {
400
- echo wooccm_wpml_string( $key ) . ', ';
401
- }
402
- } else {
403
- echo $strings;
404
- }
405
- } else {
406
- echo '-';
407
- }
408
- echo '
409
  </td>
410
  </tr>';
411
- } elseif( $btn['type'] == 'wooccmupload' ) {
412
- $info = get_post_meta( $order_id, sprintf( '_%s_%s', $name, $btn['cow'] ), true );
413
- if( !empty( $info ) ) {
414
- // Check for delimiter
415
- if( strstr( $info, '||' ) !== false )
416
- $info = explode( '||', $info );
417
- else if( strstr( $info, ',' ) !== false )
418
- $info = explode( ',', $info );
419
- else if( is_numeric( $info ) )
420
- $info = array( $info );
421
- if( is_array( $info ) ) {
422
- $num_files = count( $info );
423
- if( !empty( $num_files ) )
424
- $info = sprintf( _n( '%s file', '%s files', $num_files, 'woocommerce-checkout-manager' ), number_format_i18n( $num_files ) );
425
- else
426
- $info = '-';
427
- } else {
428
- $info = '-';
429
- }
430
- } else {
431
- $info = '-';
432
- }
433
-
434
- $btn['label'] = ( !empty( $btn['force_title2'] ) ? $btn['force_title2'] : $btn['label'] );
435
- echo '
436
  <tr>
437
- <th>'.wooccm_wpml_string( trim( $btn['label'] ) ).':</th>
438
- <td>'.$info.'</td>
439
  </tr>';
440
- }
441
- }
442
-
443
- }
444
- }
445
- $inc--;
446
-
447
- }
448
-
449
- $options = get_option( 'wccs_settings' );
450
- $buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : false );
451
- if( !empty( $buttons ) ) {
452
- foreach( $buttons as $btn ) {
453
-
454
- if(
455
- ( get_post_meta( $order_id , $btn['cow'], true ) !== '' ) &&
456
- !empty( $btn['label'] ) &&
457
- empty( $btn['deny_receipt'] ) &&
458
- $btn['type'] !== 'heading' &&
459
- $btn['type'] !== 'wooccmupload' &&
460
- $btn['type'] !== 'multiselect' &&
461
- $btn['type'] !== 'multicheckbox'
462
- ) {
463
- $value = get_post_meta( $order_id, $btn['cow'], true );
464
- if( $value == '1' )
465
- $value = __( 'Yes', 'woocommerce-checkout-manager' );
466
- else if( $value == '0' )
467
- $value = __( 'No', 'woocommerce-checkout-manager' );
468
- echo '
469
  <tr>
470
- <th>'.wooccm_wpml_string( $btn['label'] ).':</th>
471
- <td data-title="' . wooccm_wpml_string( $btn['label'] ) . '">'.nl2br( $value ).'</td>
472
  </tr>';
473
- } elseif(
474
- !empty( $btn['label'] ) &&
475
- empty( $btn['deny_receipt'] ) &&
476
- $btn['type'] !== 'wooccmupload' &&
477
- $btn['type'] !== 'multiselect' &&
478
- $btn['type'] !== 'multicheckbox' &&
479
- $btn['type'] == 'heading'
480
- ) {
481
- echo '
482
  <tr>
483
- <th colspan="2">' .wooccm_wpml_string($btn['label']). '</th>
484
  </tr>';
485
- } elseif(
486
- ( get_post_meta( $order_id, $btn['cow'], true ) !== '' ) &&
487
- !empty( $btn['label'] ) &&
488
- empty( $btn['deny_receipt'] ) &&
489
- $btn['type'] !== 'heading' &&
490
- $btn['type'] !== 'wooccmupload' &&
491
- (
492
- $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
493
- )
494
- ) {
495
- $value = get_post_meta( $order_id , $btn['cow'], true );
496
- $strings = maybe_unserialize( $value );
497
- echo '
498
  <tr>
499
- <th>'.wooccm_wpml_string( $btn['label'] ).':</th>
500
- <td data-title="' . wooccm_wpml_string( $btn['label'] ) . '">';
501
- if( !empty( $strings ) ) {
502
- if( is_array( $strings ) ) {
503
- foreach( $strings as $key ) {
504
- echo wooccm_wpml_string( $key ) . ', ';
505
- }
506
- } else {
507
- echo $strings;
508
- }
509
- } else {
510
- echo '-';
511
- }
512
- echo '
513
  </td>
514
  </tr>';
515
- } elseif( $btn['type'] == 'wooccmupload' ) {
516
- $info = get_post_meta( $order_id, $btn['cow'], true );
517
- if( !empty( $info ) ) {
518
- // Check for delimiter
519
- if( strstr( $info, '||' ) !== false )
520
- $info = explode( '||', $info );
521
- else if( strstr( $info, ',' ) !== false )
522
- $info = explode( ',', $info );
523
- else if( is_numeric( $info ) )
524
- $info = array( $info );
525
- if( is_array( $info ) ) {
526
- $num_files = count( $info );
527
- if( !empty( $num_files ) )
528
- $info = sprintf( _n( '%s file', '%s files', $num_files, 'woocommerce-checkout-manager' ), number_format_i18n( $num_files ) );
529
- else
530
- $info = '-';
531
- } else {
532
- $info = '-';
533
- }
534
- } else {
535
- $info = '-';
536
- }
537
-
538
- $btn['label'] = ( !empty( $btn['force_title2'] ) ? $btn['force_title2'] : $btn['label'] );
539
- echo '
540
  <tr>
541
- <th>2'.wooccm_wpml_string( trim( $btn['label'] ) ).':</th>
542
- <td data-title="' . wooccm_wpml_string( trim( $btn['label'] ) ) . '">'.$info.'</td>
543
  </tr>';
544
- }
545
-
546
- }
547
- }
548
-
549
- if( $print_table ) {
550
- echo '</table>';
551
- echo '<!-- .wccs_custom_fields -->';
552
- }
553
-
554
- } else {
555
-
556
- // @mod - Legacy support below WooCommerce 2.3
557
- echo '<div class="wccs_custom_fields">';
558
-
559
- foreach( $names as $name ) {
560
-
561
- $array = ( $name == 'billing' ) ? $billing : $shipping;
562
-
563
- $options = get_option( 'wccs_settings'.$inc );
564
- if( !empty( $options[sprintf( '%s_buttons', $name )] ) ) {
565
- foreach( $options[sprintf( '%s_buttons', $name )] as $btn ) {
566
-
567
- if( !in_array( $btn['cow'], $array ) ) {
568
- if(
569
- ( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true ) !== '' ) &&
570
- !empty( $btn['label'] ) &&
571
- empty( $btn['deny_receipt'] ) &&
572
- $btn['type'] !== 'heading' &&
573
- $btn['type'] !== 'multiselect' &&
574
- $btn['type'] !== 'wooccmupload' &&
575
- $btn['type'] !== 'multicheckbox'
576
- ) {
577
- echo '
578
- <dt>'.wooccm_wpml_string($btn['label']).':</dt>
579
- <dd>'.nl2br( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true ) ).'</dd>';
580
- } elseif(
581
- !empty( $btn['label'] ) &&
582
- empty( $btn['deny_receipt'] ) &&
583
- $btn['type'] !== 'multiselect' &&
584
- $btn['type'] !== 'multicheckbox' &&
585
- $btn['type'] == 'heading'
586
- ) {
587
- echo '
588
- <h2>' .wooccm_wpml_string($btn['label']). '</h2>';
589
- } elseif(
590
- ( get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true ) !== '' ) &&
591
- !empty( $btn['label'] ) &&
592
- empty( $btn['deny_receipt'] ) &&
593
- $btn['type'] !== 'heading' &&
594
- (
595
- $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
596
- )
597
- ) {
598
- $value = get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true );
599
- $strings = maybe_unserialize( $value );
600
- echo '
601
- <dt>'.wooccm_wpml_string($btn['label']).':</dt>
602
  <dd>';
603
- if( !empty( $strings ) ) {
604
- if( is_array( $strings ) ) {
605
- foreach( $strings as $key ) {
606
- echo wooccm_wpml_string($key).', ';
607
- }
608
- } else {
609
- echo $strings;
610
- }
611
- } else {
612
- echo '-';
613
- }
614
- echo '
615
  </dd>';
616
- } elseif( $btn['type'] == 'wooccmupload' ) {
617
- $info = get_post_meta( $order_id , sprintf( '_%s_%s', $name, $btn['cow'] ), true );
618
- if( !empty( $info ) ) {
619
- // Check for delimiter
620
- if( strstr( $info, '||' ) !== false )
621
- $info = explode( '||', $info );
622
- else if( strstr( $info, ',' ) !== false )
623
- $info = explode( ',', $info );
624
- else if( is_numeric( $info ) )
625
- $info = array( $info );
626
- if( is_array( $info ) ) {
627
- $num_files = count( $info );
628
- if( !empty( $num_files ) )
629
- $info = sprintf( _n( '%s file', '%s files', $num_files, 'woocommerce-checkout-manager' ), number_format_i18n( $num_files ) );
630
- else
631
- $info = '-';
632
- } else {
633
- $info = '-';
634
- }
635
- } else {
636
- $info = '-';
637
- }
638
-
639
- $btn['label'] = ( !empty( $btn['force_title2'] ) ? $btn['force_title2'] : $btn['label'] );
640
- echo '
641
- <dt>'.wooccm_wpml_string( trim( $btn['label'] ) ).':</dt>
642
- <dd>'.$info.'</dd>';
643
- }
644
- }
645
-
646
- }
647
- }
648
- $inc--;
649
-
650
- }
651
-
652
- $options = get_option( 'wccs_settings' );
653
- $buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : false );
654
- if( !empty( $buttons ) ) {
655
- foreach( $buttons as $btn ) {
656
-
657
- if(
658
- ( get_post_meta( $order_id , $btn['cow'], true ) !== '' ) &&
659
- !empty( $btn['label'] ) &&
660
- empty( $btn['deny_receipt'] ) &&
661
- $btn['type'] !== 'heading' &&
662
- $btn['type'] !== 'multicheckbox' &&
663
- (
664
- $btn['type'] !== 'wooccmupload' && $btn['type'] !== 'multiselect'
665
- )
666
- ) {
667
- echo '
668
- <dt>'.wooccm_wpml_string($btn['label']).':</dt>
669
- <dd>'.nl2br( get_post_meta( $order_id , $btn['cow'], true ) ).'</dd>';
670
- } elseif(
671
- !empty( $btn['label'] ) &&
672
- empty( $btn['deny_receipt'] ) &&
673
- $btn['type'] !== 'wooccmupload' &&
674
- $btn['type'] !== 'multiselect' &&
675
- $btn['type'] !== 'multicheckbox' &&
676
- $btn['type'] == 'heading'
677
- ) {
678
- echo '
679
- <h2>' .wooccm_wpml_string($btn['label']). '</h2>';
680
- } elseif(
681
- ( get_post_meta( $order_id , $btn['cow'], true ) !== '' ) &&
682
- !empty( $btn['label'] ) &&
683
- empty( $btn['deny_receipt'] ) &&
684
- $btn['type'] !== 'heading' &&
685
- $btn['type'] !== 'wooccmupload' &&
686
- (
687
- $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
688
- )
689
- ) {
690
- $value = get_post_meta( $order_id , $btn['cow'], true );
691
- $strings = maybe_unserialize( $value );
692
- echo '
693
- <dt>'.wooccm_wpml_string($btn['label']).':</dt>
694
  <dd>';
695
- if( !empty( $strings ) ) {
696
- if( is_array( $strings ) ) {
697
- foreach( $strings as $key ) {
698
- echo wooccm_wpml_string($key).', ';
699
- }
700
- } else {
701
- echo $strings;
702
- }
703
- } else {
704
- echo '-';
705
- }
706
- echo '
707
  </dd>';
708
- } elseif( $btn['type'] == 'wooccmupload' ) {
709
- $info = get_post_meta( $order_id , $btn['cow'], true );
710
- if( !empty( $info ) ) {
711
- // Check for delimiter
712
- if( strstr( $info, '||' ) !== false )
713
- $info = explode( '||', $info );
714
- else if( strstr( $info, ',' ) !== false )
715
- $info = explode( ',', $info );
716
- else if( is_numeric( $info ) )
717
- $info = array( $info );
718
- if( is_array( $info ) ) {
719
- $num_files = count( $info );
720
- if( !empty( $num_files ) )
721
- $info = sprintf( _n( '%s file', '%s files', $num_files, 'woocommerce-checkout-manager' ), number_format_i18n( $num_files ) );
722
- else
723
- $info = '-';
724
- } else {
725
- $info = '-';
726
- }
727
- } else {
728
- $info = '-';
729
- }
730
-
731
- $btn['label'] = ( !empty( $btn['force_title2'] ) ? $btn['force_title2'] : $btn['label'] );
732
- echo '
733
- <dt>'.wooccm_wpml_string( trim( $btn['label'] ) ).':</dt>
734
- <dd>'.$info.'</dd>';
735
- }
736
-
737
- }
738
- }
739
- echo '</div>';
740
- echo '<!-- .wccs_custom_fields -->';
741
-
742
- }
743
-
744
  }
745
  ?>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ /*function wooccm_front_end_upload() {
4
+
5
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_checkout_attachment_upload', 'nonce')) {
6
+
7
+ $name = ( isset($_REQUEST["name"]) ? $_REQUEST["name"] : false );
8
+
9
+ // Check if a file has been uploaded
10
+ if (empty($_FILES)) {
11
+ wooccm_error_log('[' . $name . '] $_FILES is empty');
12
+ return;
13
+ }
14
+
15
+ // Check if the $_REQUEST name attribute matches the $_FILES field name
16
+ if (!isset($_FILES[$name])) {
17
+ wooccm_error_log('[' . $name . '] $_REQUEST name does not match');
18
+ return;
19
+ }
20
+
21
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
22
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
23
+
24
+ $wp_upload_dir = wp_upload_dir();
25
+
26
+ $number_of_files = 0;
27
+ $attach_ids = array();
28
+
29
+ $files = $_FILES[$name];
30
+ foreach ($files['name'] as $key => $value) {
31
+ if ($files['name'][$key]) {
32
+ $file = array(
33
+ 'name' => $_FILES[$name]['name'][$key],
34
+ 'type' => $_FILES[$name]['type'][$key],
35
+ 'tmp_name' => $_FILES[$name]['tmp_name'][$key],
36
+ 'error' => $_FILES[$name]['error'][$key],
37
+ 'size' => $_FILES[$name]['size'][$key]
38
+ );
39
+ $upload_overrides = array('test_form' => false);
40
+ $movefile = wp_handle_upload($file, $upload_overrides);
41
+
42
+ // Check if upload was successful
43
+ if (isset($movefile['error']) && $movefile['error'] > 0) {
44
+ wooccm_error_log('[' . $name . '] upload failed: ' . print_r($movefile, true));
45
+ return;
46
+ }
47
+
48
+ $post_title = basename($file['name']);
49
+ if (isset($movefile['file']))
50
+ $post_title = basename($movefile['file']);
51
+ $attachment = array(
52
+ 'guid' => ( isset($movefile['url']) ? $movefile['url'] : false ),
53
+ 'post_mime_type' => ( isset($movefile['type']) ? $movefile['type'] : $file['type'] ),
54
+ 'post_title' => preg_replace('/\.[^.]+$/', '', $post_title),
55
+ 'post_content' => '',
56
+ 'post_status' => 'inherit'
57
+ );
58
+
59
+ if (!empty($movefile['url'])) {
60
+ $attach_id = wp_insert_attachment($attachment, $movefile['url']);
61
+ $attach_ids[] = $attach_id;
62
+ $number_of_files++;
63
+ // echo json_encode( array( $number_of_files, $attach_id ) );
64
+ }
65
+ }
66
+ }
67
+
68
+ if (!empty($attach_ids)) {
69
+ $output = implode(',', $attach_ids);
70
+ $output = json_encode($output);
71
+ echo $output;
72
+ }
73
+
74
+ die();
75
+ }
76
  }
77
+
78
  add_action("wp_ajax_wooccm_front_end_upload", "wooccm_front_end_upload");
79
  add_action("wp_ajax_nopriv_wooccm_front_end_upload", "wooccm_front_end_upload");
80
+ */
81
 
82
+ /*function wooccm_front_end_upload_save() {
 
 
 
 
83
 
84
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_checkout_attachment_upload', 'nonce')) {
 
85
 
86
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
87
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
88
 
89
+ $name = ( isset($_REQUEST["name"]) ? $_REQUEST["name"] : false );
90
+ $attachtoremove = ( isset($_REQUEST["remove"]) ? $_REQUEST["remove"] : false );
 
 
91
 
92
+ if (!empty($attachtoremove)) {
93
+ // Check the Attachment exists...
94
+ if (get_post_status($attachtoremove) == false)
95
+ die();
 
 
 
 
96
 
97
+ // Check the Attachment is associated with an Order
98
+ $post_parent = get_post_field('post_parent', $attachtoremove);
99
+ if (empty($post_parent)) {
100
+ die();
101
+ } else {
102
+ if (get_post_type($post_parent) <> 'shop_order')
103
+ die();
104
+ }
105
 
106
+ // Delete the Attachment
107
+ wp_delete_attachment($attachtoremove);
108
+ }
 
 
 
 
109
 
110
+ $file = array(
111
+ 'name' => $_FILES[$name]['name'],
112
+ 'type' => $_FILES[$name]['type'],
113
+ 'tmp_name' => $_FILES[$name]['tmp_name'],
114
+ 'error' => $_FILES[$name]['error'],
115
+ 'size' => $_FILES[$name]['size']
116
+ );
117
 
118
+ $upload_overrides = array('test_form' => false);
119
+ $movefile = wp_handle_upload($file, $upload_overrides);
 
 
 
 
 
120
 
121
+ $attachment = array(
122
+ 'guid' => $movefile['url'],
123
+ 'post_mime_type' => $movefile['type'],
124
+ 'post_title' => preg_replace('/\.[^.]+$/', '', basename($movefile['file'])),
125
+ 'post_content' => '',
126
+ 'post_status' => 'inherit'
127
+ );
128
 
129
+ $attach_id = wp_insert_attachment($attachment, $movefile['url']);
130
 
131
+ echo json_encode($attach_id);
132
 
133
+ die();
134
+ }
135
  }
136
+
137
  //frontend handle
138
  add_action("wp_ajax_wooccm_front_end_upload_save", "wooccm_front_end_upload_save");
139
+ add_action("wp_ajax_nopriv_wooccm_front_end_upload_save", "wooccm_front_end_upload_save");*/
140
+
141
+ /*function wooccm_update_attachment_ids($order_id = 0) {
142
+
143
+ $has_uploads = false;
144
+ $email_attachments = array();
145
+
146
+ $shipping = array(
147
+ 'country',
148
+ 'first_name',
149
+ 'last_name',
150
+ 'company',
151
+ 'address_1',
152
+ 'address_2',
153
+ 'city',
154
+ 'state',
155
+ 'postcode'
156
+ );
157
+ $billing = array(
158
+ 'country',
159
+ 'first_name',
160
+ 'last_name',
161
+ 'company',
162
+ 'address_1',
163
+ 'address_2',
164
+ 'city',
165
+ 'state',
166
+ 'postcode',
167
+ 'email',
168
+ 'phone'
169
+ );
170
+
171
+ $names = array(
172
+ 'billing',
173
+ 'shipping'
174
+ );
175
+ $inc = 3;
176
+
177
+ foreach ($names as $name) {
178
+
179
+ $array = ( $name == 'billing' ) ? $billing : $shipping;
180
+
181
+ $options = get_option('wccs_settings' . $inc);
182
+ if (!empty($options[sprintf('%s_buttons', $name)])) {
183
+ foreach ($options[sprintf('%s_buttons', $name)] as $btn) {
184
+
185
+ if (!in_array($btn['cow'], $array)) {
186
+ if ($btn['type'] == 'wooccmupload') {
187
+ $attachments = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
188
+ if (!empty($attachments)) {
189
+
190
+ // Check for delimiter
191
+ if (strstr($attachments, '||') !== false)
192
+ $attachments = explode('||', $attachments);
193
+ else if (strstr($attachments, ',') !== false)
194
+ $attachments = explode(',', $attachments);
195
+ else
196
+ $attachments = array($attachments);
197
+
198
+ if (!empty($attachments)) {
199
+ foreach ($attachments as $image_id) {
200
+
201
+ if (!empty($image_id)) {
202
+ $has_uploads = true;
203
+ wp_update_post(array('ID' => $image_id, 'post_parent' => $order_id));
204
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
205
+ wp_update_attachment_metadata($image_id, wp_generate_attachment_metadata($image_id, get_attached_file($image_id)));
206
+ $email_attachments[] = get_attached_file($image_id);
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ $inc--;
216
+ }
217
+
218
+ $options = get_option('wccs_settings');
219
+ $buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
220
+ if (!empty($buttons)) {
221
+ foreach ($buttons as $btn) {
222
+
223
+ if ($btn['type'] == 'wooccmupload') {
224
+ $attachments = get_post_meta($order_id, $btn['cow'], true);
225
+ if (!empty($attachments)) {
226
+
227
+ // Check for delimiter
228
+ if (strstr($attachments, '||') !== false)
229
+ $attachments = explode('||', $attachments);
230
+ else if (strstr($attachments, ',') !== false)
231
+ $attachments = explode(',', $attachments);
232
+ else if (is_numeric($attachments))
233
+ $attachments = array($attachments);
234
+
235
+ if (!is_array($attachments))
236
+ continue;
237
+
238
+ foreach ($attachments as $image_id) {
239
+
240
+ if (!empty($image_id)) {
241
+ $has_uploads = true;
242
+ wp_update_post(array('ID' => $image_id, 'post_parent' => $order_id));
243
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
244
+ wp_update_attachment_metadata($image_id, wp_generate_attachment_metadata($image_id, get_attached_file($image_id)));
245
+ $email_attachments[] = get_attached_file($image_id);
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ if ($has_uploads) {
254
+
255
+ $order = new WC_Order($order_id);
256
+
257
+ // send email
258
+ $email_recipients = $options['checkness']['wooccm_notification_email'];
259
+ if (empty($email_recipients))
260
+ $email_recipients = get_option('admin_email');
261
+ $email_heading = __('Files Uploaded at Checkout', 'woocommerce-checkout-manager');
262
+ $subject = sprintf(__('WooCommerce Checkout Manager - %s', 'woocommerce-checkout-manager'), $email_heading);
263
+
264
+ $mailer = WC()->mailer();
265
+
266
+ // Buffer
267
+ ob_start();
268
+ ?>
269
+ <p>This is an automatic message from WooCommerce Checkout Manager, reporting that files have been uploaded by <?php echo $order->billing_first_name; ?> <?php echo $order->billing_last_name; ?>.</p>
270
+ <h3>Customer Details</h3>
271
+ <ul>
272
+ <li>Name: <?php echo $order->billing_first_name; ?> <?php $order->billing_last_name; ?></li>
273
+ <li>E-mail: <?php echo $order->billing_email; ?></li>
274
+ <li>Order Number: <?php echo $order_id; ?></li>
275
+ </ul>
276
+ <p>You can view the files and order details via back-end by following this <a href="<?php echo admin_url('/post.php?post=' . $order_id . '&action=edit'); ?>" target="_blank">link</a>.</p>
277
+ <?php
278
+ // Get contents
279
+ $message = ob_get_clean();
280
+
281
+ $message = $mailer->wrap_message($email_heading, $message);
282
+
283
+ // add_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
284
+ // wc_mail( $email_recipients, $message_subject, $message_content );
285
+ $mailer->send($email_recipients, strip_tags($subject), $message, $email_attachments);
286
+ // remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
287
+ }
288
+ }
 
 
289
 
290
+ add_action('woocommerce_thankyou', 'wooccm_update_attachment_ids');*/
291
 
 
 
292
  // @mod - Change to thank you page to catch all Order Status
293
  // add_action( 'woocommerce_order_status_completed', 'wooccm_update_attachment_ids' );
 
294
  // Checkout - Order Received
295
+ function wooccm_order_received_checkout_details($order) {
296
+
297
+ if (version_compare(wooccm_get_woo_version(), '2.7', '>='))
298
+ $order_id = ( method_exists($order, 'get_id') ? $order->get_id() : $order->id );
299
+ else
300
+ $order_id = ( isset($order->id) ? $order->id : 0 );
301
+
302
+ $shipping = array(
303
+ 'country',
304
+ 'first_name',
305
+ 'last_name',
306
+ 'company',
307
+ 'address_1',
308
+ 'address_2',
309
+ 'city',
310
+ 'state',
311
+ 'postcode'
312
+ );
313
+ $billing = array(
314
+ 'country',
315
+ 'first_name',
316
+ 'last_name',
317
+ 'company',
318
+ 'address_1',
319
+ 'address_2',
320
+ 'city',
321
+ 'state',
322
+ 'postcode',
323
+ 'email',
324
+ 'phone'
325
+ );
326
+
327
+ $names = array(
328
+ 'billing',
329
+ 'shipping'
330
+ );
331
+ $inc = 3;
332
+
333
+ $show_table = apply_filters('wooccm_order_received_checkout_show_table', ( defined('WOOCOMMERCE_VERSION') && version_compare(WOOCOMMERCE_VERSION, '2.3', '>=')));
334
+ $print_table = apply_filters('wooccm_order_received_checkout_print_table', true);
335
+
336
+ // Check if above WooCommerce 2.3+
337
+ if ($show_table) {
338
+
339
+ if ($print_table) {
340
+ echo '<table class="wccs_custom_fields shop_table">';
341
+ }
342
+
343
+ foreach ($names as $name) {
344
+
345
+ $array = ( $name == 'billing' ) ? $billing : $shipping;
346
+
347
+ $options = get_option('wccs_settings' . $inc);
348
+ if (!empty($options[sprintf('%s_buttons', $name)])) {
349
+ foreach ($options[sprintf('%s_buttons', $name)] as $btn) {
350
+
351
+ if (!in_array($btn['cow'], $array)) {
352
+ if (
353
+ ( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
354
+ !empty($btn['label']) &&
355
+ empty($btn['deny_receipt']) &&
356
+ $btn['type'] !== 'heading' &&
357
+ $btn['type'] !== 'wooccmupload' &&
358
+ $btn['type'] !== 'multiselect' &&
359
+ $btn['type'] !== 'multicheckbox'
360
+ ) {
361
+ echo '
362
  <tr>
363
+ <th>' . wooccm_wpml_string($btn['label']) . ':</th>
364
+ <td>' . nl2br(get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true)) . '</td>
365
  </tr>';
366
+ } elseif (
367
+ !empty($btn['label']) &&
368
+ empty($btn['deny_receipt']) &&
369
+ $btn['type'] !== 'multiselect' &&
370
+ $btn['type'] !== 'multicheckbox' &&
371
+ $btn['type'] == 'heading'
372
+ ) {
373
+ echo '
374
  <tr>
375
+ <th colspan="2">' . wooccm_wpml_string($btn['label']) . '</th>
376
  </tr>';
377
+ } elseif (
378
+ ( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '') &&
379
+ $btn['type'] !== 'wooccmupload' &&
380
+ !empty($btn['label']) &&
381
+ empty($btn['deny_receipt']) &&
382
+ $btn['type'] !== 'heading' &&
383
+ (
384
+ ( $btn['type'] == 'multiselect' ) || ( $btn['type'] == 'multicheckbox' )
385
+ )
386
+ ) {
387
+ $value = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
388
+ $strings = maybe_unserialize($value);
389
+ echo '
390
  <tr>
391
+ <th>' . wooccm_wpml_string($btn['label']) . ':</th>
392
+ <td data-title="' . wooccm_wpml_string($btn['label']) . '">';
393
+ if (!empty($strings)) {
394
+ if (is_array($strings)) {
395
+ foreach ($strings as $key) {
396
+ echo wooccm_wpml_string($key) . ', ';
397
+ }
398
+ } else {
399
+ echo $strings;
400
+ }
401
+ } else {
402
+ echo '-';
403
+ }
404
+ echo '
405
  </td>
406
  </tr>';
407
+ } elseif ($btn['type'] == 'wooccmupload') {
408
+ $info = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
409
+ if (!empty($info)) {
410
+ // Check for delimiter
411
+ if (strstr($info, '||') !== false)
412
+ $info = explode('||', $info);
413
+ else if (strstr($info, ',') !== false)
414
+ $info = explode(',', $info);
415
+ else if (is_numeric($info))
416
+ $info = array($info);
417
+ if (is_array($info)) {
418
+ $num_files = count($info);
419
+ if (!empty($num_files))
420
+ $info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
421
+ else
422
+ $info = '-';
423
+ } else {
424
+ $info = '-';
425
+ }
426
+ } else {
427
+ $info = '-';
428
+ }
429
+
430
+ $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
431
+ echo '
432
  <tr>
433
+ <th>' . wooccm_wpml_string(trim($btn['label'])) . ':</th>
434
+ <td>' . $info . '</td>
435
  </tr>';
436
+ }
437
+ }
438
+ }
439
+ }
440
+ $inc--;
441
+ }
442
+
443
+ $options = get_option('wccs_settings');
444
+ $buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
445
+ if (!empty($buttons)) {
446
+ foreach ($buttons as $btn) {
447
+
448
+ if (
449
+ ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
450
+ !empty($btn['label']) &&
451
+ empty($btn['deny_receipt']) &&
452
+ $btn['type'] !== 'heading' &&
453
+ $btn['type'] !== 'wooccmupload' &&
454
+ $btn['type'] !== 'multiselect' &&
455
+ $btn['type'] !== 'multicheckbox'
456
+ ) {
457
+ $value = get_post_meta($order_id, $btn['cow'], true);
458
+ if ($value == '1')
459
+ $value = __('Yes', 'woocommerce-checkout-manager');
460
+ else if ($value == '0')
461
+ $value = __('No', 'woocommerce-checkout-manager');
462
+ echo '
 
 
463
  <tr>
464
+ <th>' . wooccm_wpml_string($btn['label']) . ':</th>
465
+ <td data-title="' . wooccm_wpml_string($btn['label']) . '">' . nl2br($value) . '</td>
466
  </tr>';
467
+ } elseif (
468
+ !empty($btn['label']) &&
469
+ empty($btn['deny_receipt']) &&
470
+ $btn['type'] !== 'wooccmupload' &&
471
+ $btn['type'] !== 'multiselect' &&
472
+ $btn['type'] !== 'multicheckbox' &&
473
+ $btn['type'] == 'heading'
474
+ ) {
475
+ echo '
476
  <tr>
477
+ <th colspan="2">' . wooccm_wpml_string($btn['label']) . '</th>
478
  </tr>';
479
+ } elseif (
480
+ ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
481
+ !empty($btn['label']) &&
482
+ empty($btn['deny_receipt']) &&
483
+ $btn['type'] !== 'heading' &&
484
+ $btn['type'] !== 'wooccmupload' &&
485
+ (
486
+ $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
487
+ )
488
+ ) {
489
+ $value = get_post_meta($order_id, $btn['cow'], true);
490
+ $strings = maybe_unserialize($value);
491
+ echo '
492
  <tr>
493
+ <th>' . wooccm_wpml_string($btn['label']) . ':</th>
494
+ <td data-title="' . wooccm_wpml_string($btn['label']) . '">';
495
+ if (!empty($strings)) {
496
+ if (is_array($strings)) {
497
+ foreach ($strings as $key) {
498
+ echo wooccm_wpml_string($key) . ', ';
499
+ }
500
+ } else {
501
+ echo $strings;
502
+ }
503
+ } else {
504
+ echo '-';
505
+ }
506
+ echo '
507
  </td>
508
  </tr>';
509
+ } elseif ($btn['type'] == 'wooccmupload') {
510
+ $info = get_post_meta($order_id, $btn['cow'], true);
511
+ if (!empty($info)) {
512
+ // Check for delimiter
513
+ if (strstr($info, '||') !== false)
514
+ $info = explode('||', $info);
515
+ else if (strstr($info, ',') !== false)
516
+ $info = explode(',', $info);
517
+ else if (is_numeric($info))
518
+ $info = array($info);
519
+ if (is_array($info)) {
520
+ $num_files = count($info);
521
+ if (!empty($num_files))
522
+ $info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
523
+ else
524
+ $info = '-';
525
+ } else {
526
+ $info = '-';
527
+ }
528
+ } else {
529
+ $info = '-';
530
+ }
531
+
532
+ $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
533
+ echo '
534
  <tr>
535
+ <th>' . wooccm_wpml_string(trim($btn['label'])) . ':</th>
536
+ <td data-title="' . wooccm_wpml_string(trim($btn['label'])) . '">' . $info . '</td>
537
  </tr>';
538
+ }
539
+ }
540
+ }
541
+
542
+ if ($print_table) {
543
+ echo '</table>';
544
+ echo '<!-- .wccs_custom_fields -->';
545
+ }
546
+ } else {
547
+
548
+ // @mod - Legacy support below WooCommerce 2.3
549
+ echo '<div class="wccs_custom_fields">';
550
+
551
+ foreach ($names as $name) {
552
+
553
+ $array = ( $name == 'billing' ) ? $billing : $shipping;
554
+
555
+ $options = get_option('wccs_settings' . $inc);
556
+ if (!empty($options[sprintf('%s_buttons', $name)])) {
557
+ foreach ($options[sprintf('%s_buttons', $name)] as $btn) {
558
+
559
+ if (!in_array($btn['cow'], $array)) {
560
+ if (
561
+ ( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
562
+ !empty($btn['label']) &&
563
+ empty($btn['deny_receipt']) &&
564
+ $btn['type'] !== 'heading' &&
565
+ $btn['type'] !== 'multiselect' &&
566
+ $btn['type'] !== 'wooccmupload' &&
567
+ $btn['type'] !== 'multicheckbox'
568
+ ) {
569
+ echo '
570
+ <dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
571
+ <dd>' . nl2br(get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true)) . '</dd>';
572
+ } elseif (
573
+ !empty($btn['label']) &&
574
+ empty($btn['deny_receipt']) &&
575
+ $btn['type'] !== 'multiselect' &&
576
+ $btn['type'] !== 'multicheckbox' &&
577
+ $btn['type'] == 'heading'
578
+ ) {
579
+ echo '
580
+ <h2>' . wooccm_wpml_string($btn['label']) . '</h2>';
581
+ } elseif (
582
+ ( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
583
+ !empty($btn['label']) &&
584
+ empty($btn['deny_receipt']) &&
585
+ $btn['type'] !== 'heading' &&
586
+ (
587
+ $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
588
+ )
589
+ ) {
590
+ $value = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
591
+ $strings = maybe_unserialize($value);
592
+ echo '
593
+ <dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
 
 
594
  <dd>';
595
+ if (!empty($strings)) {
596
+ if (is_array($strings)) {
597
+ foreach ($strings as $key) {
598
+ echo wooccm_wpml_string($key) . ', ';
599
+ }
600
+ } else {
601
+ echo $strings;
602
+ }
603
+ } else {
604
+ echo '-';
605
+ }
606
+ echo '
607
  </dd>';
608
+ } elseif ($btn['type'] == 'wooccmupload') {
609
+ $info = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
610
+ if (!empty($info)) {
611
+ // Check for delimiter
612
+ if (strstr($info, '||') !== false)
613
+ $info = explode('||', $info);
614
+ else if (strstr($info, ',') !== false)
615
+ $info = explode(',', $info);
616
+ else if (is_numeric($info))
617
+ $info = array($info);
618
+ if (is_array($info)) {
619
+ $num_files = count($info);
620
+ if (!empty($num_files))
621
+ $info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
622
+ else
623
+ $info = '-';
624
+ } else {
625
+ $info = '-';
626
+ }
627
+ } else {
628
+ $info = '-';
629
+ }
630
+
631
+ $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
632
+ echo '
633
+ <dt>' . wooccm_wpml_string(trim($btn['label'])) . ':</dt>
634
+ <dd>' . $info . '</dd>';
635
+ }
636
+ }
637
+ }
638
+ }
639
+ $inc--;
640
+ }
641
+
642
+ $options = get_option('wccs_settings');
643
+ $buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
644
+ if (!empty($buttons)) {
645
+ foreach ($buttons as $btn) {
646
+
647
+ if (
648
+ ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
649
+ !empty($btn['label']) &&
650
+ empty($btn['deny_receipt']) &&
651
+ $btn['type'] !== 'heading' &&
652
+ $btn['type'] !== 'multicheckbox' &&
653
+ (
654
+ $btn['type'] !== 'wooccmupload' && $btn['type'] !== 'multiselect'
655
+ )
656
+ ) {
657
+ echo '
658
+ <dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
659
+ <dd>' . nl2br(get_post_meta($order_id, $btn['cow'], true)) . '</dd>';
660
+ } elseif (
661
+ !empty($btn['label']) &&
662
+ empty($btn['deny_receipt']) &&
663
+ $btn['type'] !== 'wooccmupload' &&
664
+ $btn['type'] !== 'multiselect' &&
665
+ $btn['type'] !== 'multicheckbox' &&
666
+ $btn['type'] == 'heading'
667
+ ) {
668
+ echo '
669
+ <h2>' . wooccm_wpml_string($btn['label']) . '</h2>';
670
+ } elseif (
671
+ ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
672
+ !empty($btn['label']) &&
673
+ empty($btn['deny_receipt']) &&
674
+ $btn['type'] !== 'heading' &&
675
+ $btn['type'] !== 'wooccmupload' &&
676
+ (
677
+ $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
678
+ )
679
+ ) {
680
+ $value = get_post_meta($order_id, $btn['cow'], true);
681
+ $strings = maybe_unserialize($value);
682
+ echo '
683
+ <dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
 
 
684
  <dd>';
685
+ if (!empty($strings)) {
686
+ if (is_array($strings)) {
687
+ foreach ($strings as $key) {
688
+ echo wooccm_wpml_string($key) . ', ';
689
+ }
690
+ } else {
691
+ echo $strings;
692
+ }
693
+ } else {
694
+ echo '-';
695
+ }
696
+ echo '
697
  </dd>';
698
+ } elseif ($btn['type'] == 'wooccmupload') {
699
+ $info = get_post_meta($order_id, $btn['cow'], true);
700
+ if (!empty($info)) {
701
+ // Check for delimiter
702
+ if (strstr($info, '||') !== false)
703
+ $info = explode('||', $info);
704
+ else if (strstr($info, ',') !== false)
705
+ $info = explode(',', $info);
706
+ else if (is_numeric($info))
707
+ $info = array($info);
708
+ if (is_array($info)) {
709
+ $num_files = count($info);
710
+ if (!empty($num_files))
711
+ $info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
712
+ else
713
+ $info = '-';
714
+ } else {
715
+ $info = '-';
716
+ }
717
+ } else {
718
+ $info = '-';
719
+ }
720
+
721
+ $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
722
+ echo '
723
+ <dt>' . wooccm_wpml_string(trim($btn['label'])) . ':</dt>
724
+ <dd>' . $info . '</dd>';
725
+ }
726
+ }
727
+ }
728
+ echo '</div>';
729
+ echo '<!-- .wccs_custom_fields -->';
730
+ }
 
 
 
731
  }
732
  ?>
includes/templates/admin/edit-order-uploads-file_editing_table.css CHANGED
@@ -1,156 +1,144 @@
1
  /*Copied from bootstrap */
2
 
3
  .woocommerce_order_items.front_end tbody td {
4
- text-align: center;
5
  }
6
  .woocommerce_order_items.back_end {
7
- width:100%;
8
  }
9
  .woocommerce_order_items.back_end th,
10
  .woocommerce_order_items.back_end td {
11
- text-align:left;
12
- line-height:26px;
13
  }
14
  .woocommerce_order_items.back_end th.column-actions {
15
- padding: .75em 1em;
16
  }
17
  .woocommerce_order_items.back_end td.column-actions {
18
- padding-right:1em;
19
  }
20
  .woocommerce_order_items.back_end .column-actions {
21
- text-align:right;
22
  }
23
 
24
  .btn {
25
- display: inline-block;
26
- padding: 6px 12px;
27
- margin-bottom: 0;
28
- font-size: 14px;
29
- font-weight: normal;
30
- line-height: 1.42857143;
31
- text-align: center;
32
- white-space: nowrap;
33
- vertical-align: middle;
34
- cursor: pointer;
35
- -webkit-user-select: none;
36
- -moz-user-select: none;
37
- -ms-user-select: none;
38
- user-select: none;
39
- background-image: none;
40
- border: 1px solid transparent;
41
- border-radius: 4px;
42
  }
43
  /*Also */
44
  .btn-success {
45
- color: #fff;
46
- background-color: #5cb85c;
47
- border-color: #4cae4c;
48
  }
49
  /* This is copied from https://github.com/blueimp/jQuery-File-Upload/blob/master/css/jquery.fileupload.css */
50
  .fileinput-button {
51
- position: relative;
52
- overflow: hidden;
53
  }
54
  /*Also*/
55
  .fileinput-button input {
56
- position: absolute;
57
- top: 0;
58
- right: 0;
59
- margin: 0;
60
- opacity: 0;
61
- -ms-filter:'alpha(opacity=0)';
62
- font-size: 200px;
63
- direction: ltr;
64
- cursor: pointer;
65
  }
66
 
67
  .image.wccm_filesli span {
68
- text-align: center;
69
- word-wrap: break-word;
70
  }
71
 
72
  .file_size_wccm {
73
- display: inline-block;
74
- width: 15%;
75
- float: left;
76
  }
77
 
78
  .product_images.ui-sortable .image {
79
- clear: both;
80
- text-align: center;
81
  }
82
  .product_images.ui-sortable .image img {
83
- width: 75px;
84
- height: 75px;
85
  }
86
  .image.wccm_filesli li {
87
- margin-left: 0;
88
  }
89
  .image.wccm_filesli {
90
- clear: both;
91
- margin-left: 0;
92
- }
93
- .add_product_images .wccm_add_order_link:hover {
94
- background: #bb77ae;
95
- border-color: #aa559a;
96
- -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
97
- box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
98
  }
 
99
  #wccm_name {
100
- float: right;
101
  }
102
  .tips.wccm_delete {
103
- cursor: pointer;
104
- }
105
- .add_product_images .wccm_add_order_link {
106
- background: #cc99c2;
107
- border-color: #b366a4;
108
- -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
109
- box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
110
- color: #fff;
111
- text-decoration: none;
112
- float: left;
113
- clear: both;
114
- margin-top: 10px;
115
  }
116
  #wccm_align_right_file {
117
- float:left;
118
  }
119
  #wccm_save_order_submit {
120
- float: left;
121
- margin-left: 10px;
122
- margin-top: 10px;
123
  }
124
  .wccm_results {
125
- float: left;
126
- margin-left: 20px;
127
- font-weight: bold;
128
- margin-top: 13px;
129
  }
130
  .product_images.front_end {
131
- margin: 0;
132
- list-style: none;
133
  }
134
  .delete_action_wccm ul {
135
- list-style: none;
136
- margin: 0;
137
  }
138
  #wccm_save_order_submit.front_end {
139
- clear: both;
140
- margin-bottom: 20px;
141
  }
142
  .woocommerce_order_items_wrapper.front_end table.woocommerce_order_items thead th {
143
- background: #f5f5f5;
144
- padding: 8px;
145
- font-size: 11px;
146
- text-align: center;
147
- font-weight: bold;
148
  }
149
  .woocommerce_order_items.front_end {
150
- border-collapse: separate;
151
- border-spacing: 2px;
152
- border-color: gray;
153
  }
154
  #woocommerce-order-files tbody.product_images td {
155
- border-top:0;
156
  }
1
  /*Copied from bootstrap */
2
 
3
  .woocommerce_order_items.front_end tbody td {
4
+ text-align: center;
5
  }
6
  .woocommerce_order_items.back_end {
7
+ width:100%;
8
  }
9
  .woocommerce_order_items.back_end th,
10
  .woocommerce_order_items.back_end td {
11
+ text-align:left;
12
+ line-height:26px;
13
  }
14
  .woocommerce_order_items.back_end th.column-actions {
15
+ padding: .75em 1em;
16
  }
17
  .woocommerce_order_items.back_end td.column-actions {
18
+ padding-right:1em;
19
  }
20
  .woocommerce_order_items.back_end .column-actions {
21
+ text-align:right;
22
  }
23
 
24
  .btn {
25
+ display: inline-block;
26
+ padding: 6px 12px;
27
+ margin-bottom: 0;
28
+ font-size: 14px;
29
+ font-weight: normal;
30
+ line-height: 1.42857143;
31
+ text-align: center;
32
+ white-space: nowrap;
33
+ vertical-align: middle;
34
+ cursor: pointer;
35
+ -webkit-user-select: none;
36
+ -moz-user-select: none;
37
+ -ms-user-select: none;
38
+ user-select: none;
39
+ background-image: none;
40
+ border: 1px solid transparent;
41
+ border-radius: 4px;
42
  }
43
  /*Also */
44
  .btn-success {
45
+ color: #fff;
46
+ background-color: #5cb85c;
47
+ border-color: #4cae4c;
48
  }
49
  /* This is copied from https://github.com/blueimp/jQuery-File-Upload/blob/master/css/jquery.fileupload.css */
50
  .fileinput-button {
51
+ position: relative;
52
+ overflow: hidden;
53
  }
54
  /*Also*/
55
  .fileinput-button input {
56
+ position: absolute;
57
+ top: 0;
58
+ right: 0;
59
+ margin: 0;
60
+ opacity: 0;
61
+ -ms-filter:'alpha(opacity=0)';
62
+ font-size: 200px;
63
+ direction: ltr;
64
+ cursor: pointer;
65
  }
66
 
67
  .image.wccm_filesli span {
68
+ text-align: center;
69
+ word-wrap: break-word;
70
  }
71
 
72
  .file_size_wccm {
73
+ display: inline-block;
74
+ width: 15%;
75
+ float: left;
76
  }
77
 
78
  .product_images.ui-sortable .image {
79
+ clear: both;
80
+ text-align: center;
81
  }
82
  .product_images.ui-sortable .image img {
83
+ width: 75px;
84
+ height: 75px;
85
  }
86
  .image.wccm_filesli li {
87
+ margin-left: 0;
88
  }
89
  .image.wccm_filesli {
90
+ clear: both;
91
+ margin-left: 0;
 
 
 
 
 
 
92
  }
93
+
94
  #wccm_name {
95
+ float: right;
96
  }
97
  .tips.wccm_delete {
98
+ cursor: pointer;
99
+ }
100
+ .add_product_images .button {
101
+ float: left;
102
+ margin: 10px 10px 0 0;
 
 
 
 
 
 
 
103
  }
104
  #wccm_align_right_file {
105
+ float:left;
106
  }
107
  #wccm_save_order_submit {
108
+ float: left;
109
+ margin-left: 10px;
110
+ margin-top: 10px;
111
  }
112
  .wccm_results {
113
+ float: left;
114
+ margin-left: 20px;
115
+ font-weight: bold;
116
+ margin-top: 13px;
117
  }
118
  .product_images.front_end {
119
+ margin: 0;
120
+ list-style: none;
121
  }
122
  .delete_action_wccm ul {
123
+ list-style: none;
124
+ margin: 0;
125
  }
126
  #wccm_save_order_submit.front_end {
127
+ clear: both;
128
+ margin-bottom: 20px;
129
  }
130
  .woocommerce_order_items_wrapper.front_end table.woocommerce_order_items thead th {
131
+ background: #f5f5f5;
132
+ padding: 8px;
133
+ font-size: 11px;
134
+ text-align: center;
135
+ font-weight: bold;
136
  }
137
  .woocommerce_order_items.front_end {
138
+ border-collapse: separate;
139
+ border-spacing: 2px;
140
+ border-color: gray;
141
  }
142
  #woocommerce-order-files tbody.product_images td {
143
+ border-top:0;
144
  }
includes/templates/admin/edit-order-uploads-file_editing_table.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .woocommerce_order_items.front_end tbody td{text-align:center}.woocommerce_order_items.back_end{width:100%}.woocommerce_order_items.back_end th,.woocommerce_order_items.back_end td{text-align:left;line-height:26px}.woocommerce_order_items.back_end th.column-actions{padding:.75em 1em}.woocommerce_order_items.back_end td.column-actions{padding-right:1em}.woocommerce_order_items.back_end .column-actions{text-align:right}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.fileinput-button{position:relative;overflow:hidden}.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:'alpha(opacity=0)';font-size:200px;direction:ltr;cursor:pointer}.image.wccm_filesli span{text-align:center;word-wrap:break-word}.file_size_wccm{display:inline-block;width:15%;float:left}.product_images.ui-sortable .image{clear:both;text-align:center}.product_images.ui-sortable .image img{width:75px;height:75px}.image.wccm_filesli li{margin-left:0}.image.wccm_filesli{clear:both;margin-left:0}#wccm_name{float:right}.tips.wccm_delete{cursor:pointer}.add_product_images .button{float:left;margin:10px 10px 0 0}#wccm_align_right_file{float:left}#wccm_save_order_submit{float:left;margin-left:10px;margin-top:10px}.wccm_results{float:left;margin-left:20px;font-weight:bold;margin-top:13px}.product_images.front_end{margin:0;list-style:none}.delete_action_wccm ul{list-style:none;margin:0}#wccm_save_order_submit.front_end{clear:both;margin-bottom:20px}.woocommerce_order_items_wrapper.front_end table.woocommerce_order_items thead th{background:#f5f5f5;padding:8px;font-size:11px;text-align:center;font-weight:bold}.woocommerce_order_items.front_end{border-collapse:separate;border-spacing:2px;border-color:gray}#woocommerce-order-files tbody.product_images td{border-top:0}
includes/templates/admin/woocheckout-billing.php CHANGED
@@ -1,90 +1,91 @@
1
  <table class="widefat billing-wccs-table billing-semi" style="display:none;" border="1" name="billing_table">
2
- <thead>
3
-
4
- <tr>
5
- <th style="width:3%;" class="billing-wccs-order" title="<?php esc_attr_e( 'Change the order of Checkout fields', 'woocommerce-checkout-manager' ); ?>">#</th>
6
-
7
- <?php require( WOOCCM_PLUGIN_DIR.'includes/templates/admin/woocheckout-billing-thead.php' ); ?>
8
-
9
- <th width="1%" scope="col" title="<?php esc_attr_e( 'Remove button', 'woocommerce-checkout-manager' ); ?>"><strong>X</strong><!-- remove --></th>
10
- </tr>
11
-
12
- </thead>
13
- <tbody>
14
-
15
- <?php
16
- if( isset( $options3['billing_buttons'] ) ) {
17
- $billing = array(
18
- 'country',
19
- 'first_name',
20
- 'last_name',
21
- 'company',
22
- 'address_1',
23
- 'address_2',
24
- 'city',
25
- 'state',
26
- 'postcode',
27
- 'email',
28
- 'phone'
29
- );
30
- $size = count( $options3['billing_buttons'] );
31
- // $size = max( array_keys( $options3['billing_buttons'] ) );
32
- for( $i = 0; $i < $size; $i++ ) {
33
-
34
- /*
35
- if( !isset( $options3['billing_buttons'][$i] ) )
36
- break;
37
- */
38
- ?>
39
-
40
- <tr valign="top" id="wccs-billing-id-<?php echo $i; ?>" class="billing-wccs-row">
41
-
42
- <td style="display:none;" class="billing-wccs-order-hidden" >
43
- <input type="hidden" name="wccs_settings3[billing_buttons][<?php echo $i; ?>][order]" value="<?php echo ( empty( $options3['billing_buttons'][$i]['order'] ) ) ? $i : $options3['billing_buttons'][$i]['order']; ?>" />
44
- </td>
45
- <td class="billing-wccs-order" title="<?php esc_attr_e( 'Drag-and-drop this Checkout field to adjust its ordering', 'woocommerce-checkout-manager' ); ?>"><?php echo $i+1; ?></td>
46
-
47
- <?php require( WOOCCM_PLUGIN_DIR.'includes/templates/admin/woocheckout-billing-tbody.php' ); ?>
48
-
49
- <?php if( in_array( $options3['billing_buttons'][$i]['cow'], $billing) ) { ?>
50
- <td style="text-align:center;">
51
- <input name="wccs_settings3[billing_buttons][<?php echo $i; ?>][disabled]" type="checkbox" value="true" <?php if( !empty( $options3['billing_buttons'][$i]['disabled'] ) ) echo "checked='checked'"; ?> />
52
- </td>
53
- <?php } else { ?>
54
- <td class="billing-wccs-remove"><a class="billing-wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Delete this Checkout field', 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
55
- <?php } ?>
56
-
57
- </tr>
58
- <!-- #wccs-billing-id-<?php echo $i; ?> .billing-wccs-row -->
59
-
60
- <?php
61
- }
62
- }
63
- ?>
64
-
65
- <?php
66
- $i = 999;
67
- ?>
68
-
69
- <tr valign="top" id="wccs-billing-id-<?php echo $i; ?>" class="billing-wccs-clone" >
70
-
71
- <td style="display:none;" class="billing-wccs-order-hidden">
72
- <input type="hidden" name="wccs_settings3[billing_buttons][<?php echo $i; ?>][order]" value="<?php echo $i; ?>" />
73
- </td>
74
-
75
- <td class="billing-wccs-order" title="<?php esc_attr_e( 'Drag-and-drop this Checkout field to adjust its ordering', 'woocommerce-checkout-manager' ); ?>"><?php echo $i; ?></td>
76
-
77
- <?php require( WOOCCM_PLUGIN_DIR.'includes/templates/admin/woocheckout-billing-clone.php' ); ?>
78
-
79
- <td class="billing-wccs-remove"><a class="billing-wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Delete this Checkout field', 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
80
-
81
- </tr>
82
- <!-- #wccs-billing-id-<?php echo $i; ?> .billing-wccs-clone -->
83
- </tbody>
 
84
  </table>
85
  <!-- .widefat -->
86
 
87
  <div class="billing-wccs-table-footer billing-semi" style="display:none;">
88
- <a href="javascript:;" id="billing-wccs-add-button" class="button-secondary"><?php _e( '+ Add New Field', 'woocommerce-checkout-manager' ); ?></a>
89
  </div>
90
  <!-- .billing-wccs-table-footer -->
1
  <table class="widefat billing-wccs-table billing-semi" style="display:none;" border="1" name="billing_table">
2
+ <thead>
3
+
4
+ <tr>
5
+ <th style="width:3%;" class="billing-wccs-order" title="<?php esc_attr_e('Change the order of Checkout fields', 'woocommerce-checkout-manager'); ?>">#</th>
6
+
7
+ <?php require( WOOCCM_PLUGIN_DIR . 'includes/templates/admin/woocheckout-billing-thead.php' ); ?>
8
+
9
+ <th width="1%" scope="col" title="<?php esc_attr_e('Remove button', 'woocommerce-checkout-manager'); ?>"><strong>X</strong><!-- remove --></th>
10
+ </tr>
11
+
12
+ </thead>
13
+ <tbody>
14
+
15
+ <?php
16
+ if (isset($options3['billing_buttons'])) {
17
+ $billing = array(
18
+ 'country',
19
+ 'first_name',
20
+ 'last_name',
21
+ 'company',
22
+ 'address_1',
23
+ 'address_2',
24
+ 'city',
25
+ 'state',
26
+ 'postcode',
27
+ 'email',
28
+ 'phone'
29
+ );
30
+ $size = count($options3['billing_buttons']);
31
+ // $size = max( array_keys( $options3['billing_buttons'] ) );
32
+ for ($i = 0; $i < $size; $i++) {
33
+
34
+ /*
35
+ if( !isset( $options3['billing_buttons'][$i] ) )
36
+ break;
37
+ */
38
+ ?>
39
+
40
+ <tr valign="top" id="wccs-billing-id-<?php echo $i; ?>" class="billing-wccs-row">
41
+
42
+ <td style="display:none;" class="billing-wccs-order-hidden" >
43
+ <input type="hidden" name="wccs_settings3[billing_buttons][<?php echo $i; ?>][order]" value="<?php echo ( empty($options3['billing_buttons'][$i]['order']) ) ? $i : $options3['billing_buttons'][$i]['order']; ?>" />
44
+ </td>
45
+ <td class="billing-wccs-order" title="<?php esc_attr_e('Drag-and-drop this Checkout field to adjust its ordering', 'woocommerce-checkout-manager'); ?>"><?php echo $i + 1; ?></td>
46
+
47
+ <?php require( WOOCCM_PLUGIN_DIR . 'includes/templates/admin/woocheckout-billing-tbody.php' ); ?>
48
+
49
+ <?php if (in_array($options3['billing_buttons'][$i]['cow'], $billing)) { ?>
50
+ <td style="text-align:center;">
51
+ <?php echo $i . '//' . @$options3['billing_buttons'][$i]['order']; ?>
52
+ <input name="wccs_settings3[billing_buttons][<?php echo $i; ?>][disabled]" type="checkbox" value="true" <?php if (!empty($options3['billing_buttons'][$i]['disabled'])) echo "checked='checked'"; ?> />
53
+ </td>
54
+ <?php } else { ?>
55
+ <td class="billing-wccs-remove"><a class="billing-wccs-remove-button" href="javascript:;" title="<?php esc_attr_e('Delete this Checkout field', 'woocommerce-checkout-manager'); ?>">&times;</a></td>
56
+ <?php } ?>
57
+
58
+ </tr>
59
+ <!-- #wccs-billing-id-<?php echo $i; ?> .billing-wccs-row -->
60
+
61
+ <?php
62
+ }
63
+ }
64
+ ?>
65
+
66
+ <?php
67
+ $i = 999;
68
+ ?>
69
+
70
+ <tr valign="top" id="wccs-billing-id-<?php echo $i; ?>" class="billing-wccs-clone" >
71
+
72
+ <td style="display:none;" class="billing-wccs-order-hidden">
73
+ <input type="hidden" name="wccs_settings3[billing_buttons][<?php echo $i; ?>][order]" value="<?php echo $i; ?>" />
74
+ </td>
75
+
76
+ <td class="billing-wccs-order" title="<?php esc_attr_e('Drag-and-drop this Checkout field to adjust its ordering', 'woocommerce-checkout-manager'); ?>"><?php echo $i; ?></td>
77
+
78
+ <?php require( WOOCCM_PLUGIN_DIR . 'includes/templates/admin/woocheckout-billing-clone.php' ); ?>
79
+
80
+ <td class="billing-wccs-remove"><a class="billing-wccs-remove-button" href="javascript:;" title="<?php esc_attr_e('Delete this Checkout field', 'woocommerce-checkout-manager'); ?>">&times;</a></td>
81
+
82
+ </tr>
83
+ <!-- #wccs-billing-id-<?php echo $i; ?> .billing-wccs-clone -->
84
+ </tbody>
85
  </table>
86
  <!-- .widefat -->
87
 
88
  <div class="billing-wccs-table-footer billing-semi" style="display:none;">
89
+ <a href="javascript:;" id="billing-wccs-add-button" class="button-secondary"><?php _e('+ Add New Field', 'woocommerce-checkout-manager'); ?></a>
90
  </div>
91
  <!-- .billing-wccs-table-footer -->
includes/templates/admin/woocheckout-general-uploads.php CHANGED
@@ -47,7 +47,7 @@
47
  <div class="section">
48
  <h3 class="heading"><?php _e('Upload Title', 'woocommerce-checkout-manager'); ?></h3>
49
  <div class="option">
50
- <input type="text" name="wccs_settings[checkness][upload_title]" class="full-width" placeholder="<?php _e( 'Order Uploaded Files', 'woocommerce-checkout-manager' ); ?>" value="<?php echo ( isset( $options['checkness']['upload_title'] ) ? esc_attr( $options['checkness']['upload_title'] ) : '' ); ?>" />
51
  </div>
52
  <!-- .option -->
53
  </div>
47
  <div class="section">
48
  <h3 class="heading"><?php _e('Upload Title', 'woocommerce-checkout-manager'); ?></h3>
49
  <div class="option">
50
+ <input type="text" name="wccs_settings[checkness][upload_title]" class="full-width" placeholder="<?php esc_html_e( 'Order Uploaded Files', 'woocommerce-checkout-manager' ); ?>" value="<?php echo ( isset( $options['checkness']['upload_title'] ) ? esc_attr( $options['checkness']['upload_title'] ) : '' ); ?>" />
51
  </div>
52
  <!-- .option -->
53
  </div>
includes/templates/functions/required/add_required.php CHANGED
@@ -1,148 +1,135 @@
1
  <?php
 
2
  function wooccm_custom_checkout_process() {
3
 
4
- global $woocommerce;
5
-
6
- $options = get_option( 'wccs_settings' );
7
- $buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : array() );
8
-
9
- // Check if we have any buttons
10
- if( empty( $buttons ) )
11
- return;
12
-
13
- $categoryarraycm = array();
14
- $productsarraycm = array();
15
-
16
- foreach( $buttons as $btn ) {
17
-
18
- foreach( $woocommerce->cart->cart_contents as $key => $values ) {
19
-
20
- $multiproductsx = ( isset( $btn['single_p'] ) ? $btn['single_p'] : '' );
21
- $show_field_single = ( isset( $btn['single_px'] ) ? $btn['single_px'] : '' );
22
- $multiproductsx_cat = ( isset( $btn['single_p_cat'] ) ? $btn['single_p_cat'] : '' );
23
- $show_field_single_cat = ( isset( $btn['single_px_cat'] ) ? $btn['single_px_cat'] : '' );
24
-
25
- $productsarraycm[] = $values['product_id'];
26
-
27
- // Products
28
- // hide field
29
-
30
- // show field without more
31
- if(
32
- !empty( $btn['single_px'] ) &&
33
- empty( $btn['more_content'] )
34
- ) {
35
- $show_field_array = explode('||',$show_field_single);
36
- if(
37
- in_array( $values['product_id'], $show_field_array ) &&
38
- ( count( $woocommerce->cart->cart_contents ) < 2 )
39
- ) {
40
- if(
41
- !empty( $btn['checkbox'] ) &&
42
- !empty( $btn['label'] ) &&
43
- ( $btn['type'] !== 'changename' )
44
- ) {
45
- if( empty( $_POST[$btn['cow']] ) ) {
46
- $message = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . wooccm_wpml_string( $btn['label'] ) . '</strong>' );
47
- wc_add_notice( $message, 'error' );
48
- }
49
- }
50
- }
51
- }
52
-
53
- // Category
54
- // hide field
55
- $terms = get_the_terms( $values['product_id'], 'product_cat' );
56
- if( !empty( $terms ) ) {
57
- foreach( $terms as $term ) {
58
-
59
- $categoryarraycm[] = $term->slug;
60
-
61
- // without more
62
-
63
- // show field without more
64
- if(
65
- !empty( $btn['single_px_cat'] ) &&
66
- empty( $btn['more_content'] )
67
- ) {
68
- $show_field_array_cat = explode('||',$show_field_single_cat);
69
- if(
70
- in_array( $term->slug, $show_field_array_cat ) &&
71
- ( count( $woocommerce->cart->cart_contents ) < 2 )
72
- ) {
73
- if(
74
- !empty( $btn['checkbox'] ) &&
75
- !empty( $btn['label'] ) &&
76
- ( $btn['type'] !== 'changename' )
77
- ) {
78
- if( empty( $_POST[$btn['cow']] ) ) {
79
- $message = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . wooccm_wpml_string( $btn['label'] ) . '</strong>' );
80
- wc_add_notice( $message, 'error' );
81
- }
82
- }
83
- }
84
- }
85
-
86
- }
87
- }
88
-
89
- }
90
- // end cart
91
-
92
- // ===========================================================================================
93
-
94
- // Products
95
- // hide field
96
-
97
- // show field with more
98
- if(
99
- !empty( $btn['single_px'] ) &&
100
- !empty( $btn['more_content'] )
101
- ) {
102
- $show_field_array = explode( '||', $show_field_single );
103
- if( array_intersect( $productsarraycm, $show_field_array ) ) {
104
- if(
105
- !empty( $btn['checkbox'] ) &&
106
- !empty( $btn['label'] ) &&
107
- ( $btn['type'] !== 'changename' )
108
- ) {
109
- if( empty( $_POST[$btn['cow']] ) ) {
110
- $message = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . wooccm_wpml_string( $btn['label'] ) . '</strong>' );
111
- wc_add_notice( $message, 'error' );
112
- }
113
- }
114
- }
115
- }
116
-
117
- // Category
118
- // hide field
119
-
120
- // with more
121
-
122
- // show field with more
123
- if(
124
- !empty( $btn['single_px_cat'] ) &&
125
- !empty( $btn['more_content'] )
126
- ) {
127
- $show_field_array_cat = explode( '||' , $show_field_single_cat );
128
- if( array_intersect( $categoryarraycm, $show_field_array_cat ) ) {
129
- if(
130
- !empty( $btn['checkbox'] ) &&
131
- !empty( $btn['label'] ) &&
132
- ( $btn['type'] !== 'changename' )
133
- ) {
134
- if( empty( $_POST[$btn['cow']] ) ) {
135
- $message = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . wooccm_wpml_string( $btn['label'] ) . '</strong>' );
136
- wc_add_notice( $message, 'error' );
137
- }
138
- }
139
- }
140
- }
141
-
142
- $categoryarraycm = array();
143
- $productsarraycm = array();
144
-
145
- }
146
 
 
 
 
147
  }
148
- ?>
1
  <?php
2
+
3
  function wooccm_custom_checkout_process() {
4
 
5
+ global $woocommerce;
6
+
7
+ $options = get_option('wccs_settings');
8
+ $buttons = ( isset($options['buttons']) ? $options['buttons'] : array() );
9
+
10
+ // Check if we have any buttons
11
+ if (empty($buttons))
12
+ return;
13
+
14
+ $categoryarraycm = array();
15
+ $productsarraycm = array();
16
+
17
+ foreach ($buttons as $btn) {
18
+
19
+ //error_log(json_encode($btn));
20
+
21
+ foreach ($woocommerce->cart->cart_contents as $key => $values) {
22
+ $multiproductsx = ( isset($btn['single_p']) ? $btn['single_p'] : '' );
23
+ $show_field_single = ( isset($btn['single_px']) ? $btn['single_px'] : '' );
24
+ $multiproductsx_cat = ( isset($btn['single_p_cat']) ? $btn['single_p_cat'] : '' );
25
+ $show_field_single_cat = ( isset($btn['single_px_cat']) ? $btn['single_px_cat'] : '' );
26
+
27
+ $productsarraycm[] = $values['product_id'];
28
+
29
+ // Products
30
+ // hide field
31
+ // show field without more
32
+ // -----------------------------------------------------------------------
33
+ if (!empty($btn['single_px']) && empty($btn['more_content'])) {
34
+
35
+ $show_field_array = explode('||', $show_field_single);
36
+
37
+ if (in_array($values['product_id'], $show_field_array) && ( count($woocommerce->cart->cart_contents) < 2 )) {
38
+
39
+ if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
40
+
41
+ if (empty($_POST[$btn['cow']])) {
42
+ $message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
43
+ wc_add_notice($message, 'error');
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ // Products
50
+ // hide field
51
+ // show field with more
52
+ // -------------------------------------------------------------------------
53
+
54
+ //error_log('test 1');
55
+ if (!empty($btn['single_px']) && !empty($btn['more_content'])) {
56
+
57
+ //error_log('test 2');
58
+ $show_field_array = explode('||', $show_field_single);
59
+
60
+ //error_log('test 3');
61
+ if (array_intersect($productsarraycm, $show_field_array)) {
62
+
63
+ //error_log('test 4');
64
+ if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
65
+
66
+ //error_log('test 5');
67
+ if (empty($_POST[$btn['cow']])) {
68
+ $message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
69
+ wc_add_notice($message, 'error');
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ // Category
76
+ // hide field
77
+ // with more
78
+ // show field without more
79
+ // -----------------------------------------------------------------------
80
+ $terms = get_the_terms($values['product_id'], 'product_cat');
81
+
82
+ if (!empty($terms)) {
83
+
84
+ foreach ($terms as $term) {
85
+
86
+ $categoryarraycm[] = $term->slug;
87
+
88
+ // without more
89
+ // show field without more
90
+ if (!empty($btn['single_px_cat']) && empty($btn['more_content'])) {
91
+
92
+ $show_field_array_cat = explode('||', $show_field_single_cat);
93
+
94
+ if (in_array($term->slug, $show_field_array_cat) && ( count($woocommerce->cart->cart_contents) < 2 )) {
95
+
96
+ if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
97
+
98
+ if (empty($_POST[$btn['cow']])) {
99
+
100
+ $message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
101
+
102
+ wc_add_notice($message, 'error');
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ // Category
112
+ // hide field
113
+ // with more
114
+ // show field with more
115
+ // -------------------------------------------------------------------------
116
+
117
+ if (!empty($btn['single_px_cat']) && !empty($btn['more_content'])) {
118
+
119
+ $show_field_array_cat = explode('||', $show_field_single_cat);
120
+
121
+ if (array_intersect($categoryarraycm, $show_field_array_cat)) {
122
+
123
+ if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
124
+ if (empty($_POST[$btn['cow']])) {
125
+ $message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
126
+ wc_add_notice($message, 'error');
127
+ }
128
+ }
129
+ }
130
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
+ $categoryarraycm = array();
133
+ $productsarraycm = array();
134
+ }
135
  }
 
new/admin.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('WOOCCM_Admin')) {
4
+
5
+ class WOOCCM_Admin {
6
+
7
+ protected static $instance;
8
+
9
+ function ajax_toggle_field_enabled() {
10
+
11
+ if (current_user_can('manage_woocommerce') && check_ajax_referer('wooccm_admin', 'nonce') && isset($_POST['field_id'])) {
12
+
13
+ $field_id = wc_clean(wp_unslash($_POST['field_id']));
14
+
15
+ if ($options = get_option('wccs_settings3')) {
16
+
17
+ if (array_key_exists('billing_buttons', $options)) {
18
+
19
+ $enabled = empty($options['billing_buttons'][$field_id]['enabled']);
20
+
21
+ $options['billing_buttons'][$field_id]['enabled'] = $enabled;
22
+
23
+ update_option('wccs_settings3', $options);
24
+
25
+ wp_send_json_success($enabled);
26
+ }
27
+ }
28
+ }
29
+
30
+ wp_send_json_error('invalid_field_id');
31
+ wp_die();
32
+ }
33
+
34
+ function add_sections($sections = array()) {
35
+
36
+ global $current_section;
37
+
38
+ $sections[''] = esc_html__('General', 'woocommerce-checkout-manager');
39
+ $sections['orders'] = esc_html__('Orders', 'woocommerce-checkout-manager');
40
+ $sections['billing'] = esc_html__('Billing', 'woocommerce-checkout-manager');
41
+ $sections['shipping'] = esc_html__('Shipping', 'woocommerce-checkout-manager');
42
+ $sections['additional'] = esc_html__('Additional', 'woocommerce-checkout-manager');
43
+ $sections['advanced'] = esc_html__('Advanced', 'woocommerce-checkout-manager');
44
+
45
+ echo '<ul class="subsubsub">';
46
+
47
+ $array_keys = array_keys($sections);
48
+
49
+ foreach ($sections as $id => $label) {
50
+ echo '<li><a href="' . admin_url('admin.php?page=wc-settings&tab=wooccm&section=' . sanitize_title($id)) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end($array_keys) == $id ? '' : '|' ) . ' </li>';
51
+ }
52
+
53
+ echo '</ul><br class="clear" />';
54
+ }
55
+
56
+ function add_tab($settings_tabs) {
57
+ $settings_tabs[WOOCCM_PREFIX] = esc_html__('Checkout', 'woocommerce-checkout-manager');
58
+ return $settings_tabs;
59
+ }
60
+
61
+ function add_section_general() {
62
+
63
+ global $current_section;
64
+
65
+ if ('' == $current_section) {
66
+ if ($options = get_option('wccs_settings', array())) {
67
+ include_once('admin/pages/general.php');
68
+ }
69
+ }
70
+ }
71
+
72
+ function add_section_orders() {
73
+
74
+ global $current_section;
75
+
76
+ if ('shipping' == $current_section) {
77
+ if ($options = get_option('wccs_settings', array())) {
78
+ include_once('admin/pages/orders.php');
79
+ }
80
+ }
81
+ }
82
+
83
+ function add_section_billing() {
84
+
85
+ global $current_section;
86
+
87
+ if ('billing' == $current_section) {
88
+ if ($options = get_option('wccs_settings3', array())) {
89
+ include_once('admin/pages/billing.php');
90
+ }
91
+ }
92
+ }
93
+
94
+ function add_section_shipping() {
95
+
96
+ global $current_section;
97
+
98
+ if ('' == $current_section) {
99
+ if ($options = get_option('wccs_settings', array())) {
100
+ include_once('admin/pages/shipping.php');
101
+ }
102
+ }
103
+ }
104
+
105
+ function add_section_additional() {
106
+
107
+ global $current_section;
108
+
109
+ if ('additional' == $current_section) {
110
+ if ($options = get_option('wccs_settings', array())) {
111
+ include_once('admin/pages/additional.php');
112
+ }
113
+ }
114
+ }
115
+
116
+ function add_section_advanced() {
117
+ global $current_section;
118
+ if ('advanced' == $current_section) {
119
+ if ($options = get_option('wccs_settings', array())) {
120
+ require_once('admin/pages/advanced.php');
121
+ }
122
+ }
123
+ }
124
+
125
+ function save_section_billing() {
126
+
127
+ global $current_section;
128
+
129
+ if ('billing' == $current_section) {
130
+
131
+ if (isset($_POST['gateway_order'])) {
132
+
133
+ $gateway_order = wc_clean(wp_unslash($_POST['gateway_order']));
134
+
135
+ if ($options = get_option('wccs_settings3')) {
136
+
137
+ if (array_key_exists('billing_buttons', $options)) {
138
+
139
+ foreach ($options['billing_buttons'] as $id => $custom_field) {
140
+
141
+ if (isset($gateway_order[$id])) {
142
+ $options['billing_buttons'][$id]['order'] = $gateway_order[$id];
143
+ }
144
+ }
145
+
146
+ update_option('wccs_settings3', $options);
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ function add_menu_page() {
154
+ add_submenu_page('woocommerce', esc_html__('Checkout', 'woocommerce-checkout-manager'), esc_html__('Checkout', 'woocommerce-checkout-manager'), 'manage_options', admin_url('admin.php?page=wc-settings&tab=' . sanitize_title(WOOCCM_PREFIX)));
155
+ }
156
+
157
+ function init() {
158
+ add_action('admin_menu', array($this, 'add_menu_page'));
159
+ add_filter('woocommerce_settings_tabs_array', array($this, 'add_tab'), 50);
160
+ add_filter('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_sections'));
161
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_general'), 99);
162
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_orders'), 99);
163
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_billing'), 99);
164
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_shipping'), 99);
165
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_additional'), 99);
166
+ add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section_advanced'), 99);
167
+ add_action('woocommerce_settings_save_' . WOOCCM_PREFIX, array($this, 'save_section_billing'));
168
+ add_action('wp_ajax_wooccm_toggle_field_enabled', array($this, 'ajax_toggle_field_enabled'));
169
+ }
170
+
171
+ public static function instance() {
172
+ if (!isset(self::$instance)) {
173
+ self::$instance = new self();
174
+ self::$instance->init();
175
+ }
176
+ return self::$instance;
177
+ }
178
+
179
+ }
180
+
181
+ WOOCCM_Admin::instance();
182
+ }
new/admin/meta-boxes/html-order-uploads.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="wooccm_order_attachment_inner" class="wc-metaboxes-wrapper">
2
+ <table class="woocommerce_order_items back_end">
3
+ <thead>
4
+ <tr>
5
+ <!--<th><?php _e('ID', 'woocommerce-checkout-manager'); ?></th>-->
6
+ <th><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
7
+ <th><?php _e('Filename', 'woocommerce-checkout-manager'); ?></th>
8
+ <th><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
9
+ <th><?php _e('Extension', ' woocommerce-checkout-manager'); ?></th>
10
+ <th class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody class="product_images">
14
+ <?php
15
+ if (!empty($attachments)) :
16
+ foreach ($attachments as $attachment_id) :
17
+ $image_attributes = wp_get_attachment_url($attachment_id);
18
+ $image_attributes2 = wp_get_attachment_image_src($attachment_id);
19
+ $filename = basename($image_attributes);
20
+ $wp_filetype = wp_check_filetype($filename);
21
+ ?>
22
+ <tr class="image wccm_filesli wccmv_<?php echo esc_attr($attachment_id); ?>">
23
+ <!--<td><?php echo esc_attr($attachment_id); ?></td>-->
24
+ <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), false)); ?></td>
25
+ <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)); ?></td>
26
+ <td>
27
+ <?php
28
+ if ($image_attributes2[1] == '') {
29
+ echo '-';
30
+ } else {
31
+ echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
32
+ }
33
+ ?>
34
+ </td>
35
+ <td><?php echo strtoupper($wp_filetype['ext']); ?></td>
36
+ <td class="column-actions" nowrap>
37
+ <!--<a href="<?php echo esc_url($image_attributes2[0]); ?>" target="_blank" class="button"><?php esc_html_e('Download', 'woocommerce-checkout-manager'); ?></a>-->
38
+ <a class="button wooccm_delete_attachment" data-attachment_id="<?php echo esc_attr($attachment_id); ?>" data-tip="<?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?></a>
39
+ </td>
40
+ </tr>
41
+ <?php endforeach; ?>
42
+ <?php else: ?>
43
+ <tr>
44
+ <td colspan="6" style="text-align:left;"><?php esc_html_e('No files have been uploaded to this Order.', 'woocommerce-checkout-manager'); ?></td>
45
+ </tr>
46
+ <?php endif; ?>
47
+ </tbody>
48
+ </table>
49
+ <input type="hidden" id="delete_attachments_ids" name="delete_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
50
+ <input type="hidden" id="all_attachments_ids" name="all_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
51
+ <div class="clear"></div>
52
+ <div class="add_product_images hide-if-no-js">
53
+ <a class="button button-primary wccm_add_order_link fileinput-button">
54
+ <span><?php _e('Add Order Files', 'woocommerce-checkout-manager'); ?></span>
55
+ <input data-order_id="<?php echo esc_attr($order->get_id()); ?>" type="file" name="wooccm_order_attachment_upload" id="wooccm_order_attachment_upload" multiple />
56
+ </a>
57
+ <input type="button" id="wooccm_order_attachment_update" class="button button-secondary" value="<?php _e('Save Changes', 'woocommerce-checkout-manager'); ?>" disabled="disabled">
58
+ </div>
59
+ <div class="wccm_results"></div>
60
+ <div class="clear"></div>
61
+ </div>
new/admin/pages/additional.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
new/admin/pages/advanced.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="widefat general-semi advanced" border="1">
2
+
3
+ <div class="section">
4
+ <h3 class="heading"><?php _e('Advanced', 'woocommerce-checkout-manager'); ?></h3>
5
+ </div>
6
+ <!-- .section -->
7
+
8
+ <div class="section">
9
+
10
+ <div class="option">
11
+ <div class="info-of"><?php _e('Administrator Actions', 'woocommerce-checkout-manager'); ?></div>
12
+ <?php if (current_user_can('manage_options')) { ?>
13
+ <ul>
14
+ <li><a href="<?php echo add_query_arg(array('action' => 'wooccm_reset_update_notice', '_wpnonce' => wp_create_nonce('wooccm_reset_update_notice'))); ?>"><?php _e('Reset <em>Run the updater</em> prompt', 'woocommerce-checkout-manager'); ?></a></li>
15
+ <li><a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_options', '_wpnonce' => wp_create_nonce('wooccm_nuke_options'))); ?>" class="confirm-button" data-confirm="<?php _e('This will permanently delete all WordPress Options associated with WooCommerce Checkout Manager. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php _e('Delete WooCommerce Checkout Manager WordPress Options', 'woocommerce-checkout-manager'); ?></a></li>
16
+ <li><a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_order_meta', '_wpnonce' => wp_create_nonce('wooccm_nuke_order_meta'))); ?>" class="confirm-button" data-confirm="<?php _e('This will permanently delete all WordPress Post meta associated with WooCommerce Checkout Manager that is linked to Orders. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php _e('Delete WooCommerce Checkout Manager Orders Post meta', 'woocommerce-checkout-manager'); ?></a></li>
17
+ <li><a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_user_meta', '_wpnonce' => wp_create_nonce('wooccm_nuke_user_meta'))); ?>" class="confirm-button" data-confirm="<?php _e('This will permanently delete all WordPress Post meta associated with WooCommerce Checkout Manager that is linked to Users. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php _e('Delete WooCommerce Checkout Manager Users Post meta', 'woocommerce-checkout-manager'); ?></a></li>
18
+ </ul>
19
+ <?php } else { ?>
20
+ <p><?php _e('These actions are available only to WordPress Users with the <em>manage_options</em> User Capability.', 'woocommerce-checkout-manager'); ?></p>
21
+ <?php } ?>
22
+ </div>
23
+ <!-- .option -->
24
+
25
+ </div>
26
+ <!-- .section -->
27
+
28
+ </div>
29
+ <!--.advanced -->
new/admin/pages/billing.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 class="screen-reader-text"><?php esc_html_e('Billing', 'woocommerce-checkout-manager'); ?></h1>
2
+ <h2><?php esc_html_e('Billing fields', 'woocommerce-checkout-manager'); ?></h2>
3
+ <div id="wooccm_billing_settings-description">
4
+ <p>Email notifications sent from WooCommerce are listed below. Click on an email to configure it.</p>
5
+ </div>
6
+ <table class="form-table">
7
+ <tbody>
8
+ <tr valign="top">
9
+ <td class="wooccm_billing_wrapper wc_payment_gateways_wrapper" colspan="2">
10
+ <table class="wooccm_billing_fields wc_gateways widefat" cellspacing="0" aria-describedby="wooccm_billing_settings-description">
11
+ <thead>
12
+ <tr>
13
+ <th class="sort"></th>
14
+ <th class="status"><?php esc_html_e('Enabled', 'woocommerce-checkout-manager'); ?></th>
15
+ <th class="label"><?php esc_html_e('Label', 'woocommerce-checkout-manager'); ?></th>
16
+ <th class="placeholder"><?php esc_html_e('Placeholder', 'woocommerce-checkout-manager'); ?></th>
17
+ <!--<th class="order"><?php esc_html_e('Order', 'woocommerce-checkout-manager'); ?></th>-->
18
+ <th class="required"><?php esc_html_e('Required', 'woocommerce-checkout-manager'); ?></th>
19
+ <th class="position"><?php esc_html_e('Position', 'woocommerce-checkout-manager'); ?></th>
20
+ <th class="clear"><?php esc_html_e('Clear', 'woocommerce-checkout-manager'); ?></th>
21
+ <th class="type"><?php esc_html_e('Type', 'woocommerce-checkout-manager'); ?></th>
22
+ <th class="action"></th>
23
+ <th class="delete"></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody class="ui-sortable">
27
+ <?php
28
+ if ($options) {
29
+
30
+ if (array_key_exists('billing_buttons', $options)) {
31
+
32
+ uasort($options['billing_buttons'], 'wooccm_sort_fields');
33
+
34
+ if ($custom_fields = $options['billing_buttons']) {
35
+
36
+ foreach ($custom_fields as $id => $custom_field) {
37
+ ?>
38
+ <tr data-field_id="<?php echo esc_attr($id); ?>" class="">
39
+ <td class="sort ui-sortable-handle" width="1%" style="width: 72px;">
40
+ <div class="wc-item-reorder-nav">
41
+ <button type="button" class="wc-move-up wc-move-disabled" tabindex="-1" aria-hidden="true" aria-label="<?php echo esc_attr(sprintf(__('Move the "%s" payment method up', 'woocommerce-checkout-manager'), $custom_field['label'])); ?>"><?php esc_html_e('Move up', 'woocommerce-checkout-manager'); ?></button>
42
+ <button type="button" class="wc-move-down" tabindex="0" aria-hidden="false" aria-label="<?php echo esc_attr(sprintf(__('Move the "%s" payment method down', 'woocommerce-checkout-manager'), $custom_field['label'])); ?>"><?php esc_html_e('Move down', 'woocommerce-checkout-manager'); ?></button>
43
+ <input type="hidden" name="gateway_order[]" value="<?php echo esc_attr($custom_field['order']); ?>">
44
+ </div>
45
+ </td>
46
+ <td class="status" width="1%" style="width: 51px;">
47
+ <a class="wooccm-field-toggle-enabled" href="#">
48
+ <?php
49
+ if (!empty($custom_field['enabled'])) {
50
+ /* Translators: %s Payment gateway name. */
51
+ echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled" aria-label="' . esc_attr(sprintf(__('The "%s" payment method is currently enabled', 'woocommerce-checkout-manager'), $custom_field['label'])) . '">' . esc_attr__('Yes', 'woocommerce-checkout-manager') . '</span>';
52
+ } else {
53
+ /* Translators: %s Payment gateway name. */
54
+ echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled" aria-label="' . esc_attr(sprintf(__('The "%s" payment method is currently disabled', 'woocommerce-checkout-manager'), $custom_field['label'])) . '">' . esc_attr__('No', 'woocommerce-checkout-manager') . '</span>';
55
+ }
56
+ ?>
57
+ </a>
58
+ </td>
59
+ <td class="label">
60
+ <strong><?php echo esc_html(@$custom_field['label']); ?></strong>
61
+ </td>
62
+ <td class="placeholder" width="" style="max-width: 152px;">
63
+ <?php echo esc_html(@$custom_field['placeholder']); ?>
64
+ </td>
65
+ <!--<td class="order">
66
+ <strong><?php echo esc_html(@$custom_field['order']); ?></strong>
67
+ </td>-->
68
+ <td class="required">
69
+ <?php echo esc_html(@$custom_field['checkbox']); ?>
70
+ </td>
71
+ <td class="position">
72
+ <?php echo esc_html(@$custom_field['position']); ?>
73
+ </td>
74
+ <td class="clear">
75
+ <?php //var_dump($custom_field); ?>
76
+ <?php echo esc_html(@$custom_field['clear_row']); ?>
77
+ </td>
78
+ <td class="type">
79
+ <?php echo esc_html(@$custom_field['type']); ?>
80
+ </td>
81
+ <td class="action" width="1%" style="width: 69px;">
82
+ <a class="button alignright" aria-label="Set up the &quot;Direct bank transfer&quot; payment method" href="http://localhost/woocommerce-checkout/wp-admin/admin.php?page=wc-settings&amp;tab=checkout&amp;section=bacs">Manage</a>
83
+ </td>
84
+ <td class="delete" width="1%">
85
+ <a class="" aria-label="Set up the &quot;Direct bank transfer&quot; payment method" href="http://localhost/woocommerce-checkout/wp-admin/admin.php?page=wc-settings&amp;tab=checkout&amp;section=bacs">Delete</a>
86
+ </td>
87
+ </tr>
88
+ <?php
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ?>
94
+ </tbody>
95
+ </table>
96
+ </td>
97
+ </tr>
98
+ </tbody>
99
+ </table>
new/admin/pages/general.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 class="screen-reader-text"><?php esc_html_e('General', 'woocommerce-checkout-manager'); ?></h1>
2
+ <h2><?php esc_html_e('General', 'woocommerce-checkout-manager'); ?></h2>
3
+ <div id="wooccm_billing_settings-description">
4
+ <p>Email notifications sent from WooCommerce are listed below. Click on an email to configure it.</p>
5
+ </div>
6
+ <table class="form-table" cellspacing="0">
7
+ <tbody>
8
+ <tr valign="top" class="">
9
+ <th scope="row" class="titledesc">
10
+ <?php esc_html_e('Hide shipping fields', 'woocommerce-checkout-manager'); ?>
11
+ </th>
12
+ <td class="forminp forminp-checkbox">
13
+ <fieldset>
14
+ <legend class="screen-reader-text">
15
+ <span>
16
+ <?php printf(__('Hide %s heading', 'woocommerce-checkout-manager'), __('Ship to a different address?', 'woocommerce-checkout-manager')); ?>
17
+ </span>
18
+ </legend>
19
+ <label for="woocommerce_allow_bulk_remove_personal_data">
20
+ <input type="checkbox" name="wccs_settings[checkness][additional_info]" value="true"<?php checked(!empty($options['checkness']['additional_info']), true); ?> />
21
+ <?php printf(__('Hide %s heading', 'woocommerce-checkout-manager'), __('Ship to a different address?', 'woocommerce-checkout-manager')); ?>
22
+ </label>
23
+ <!--<p class="description"><?php printf(__('Hide %s heading', 'woocommerce-checkout-manager'), __('Ship to a different address?', 'woocommerce-checkout-manager')); ?></p>-->
24
+ </fieldset>
25
+ </td>
26
+ </tr>
27
+
28
+ <tr valign="top" class="">
29
+ <th scope="row" class="titledesc">
30
+ <?php esc_html_e('Show shipping checkout fields', 'woocommerce-checkout-manager'); ?>
31
+ </th>
32
+ <td class="forminp forminp-checkbox">
33
+ <fieldset>
34
+ <legend class="screen-reader-text">
35
+ <span>
36
+ <?php esc_html_e('Show shipping checkout fields', 'woocommerce-checkout-manager'); ?>
37
+ </span>
38
+ </legend>
39
+ <label for="show_shipping_fields">
40
+ <input type="checkbox" name="wccs_settings[checkness][show_shipping_fields]" value="true"<?php checked(!empty($options['checkness']['show_shipping_fields']), true); ?> />
41
+ <?php printf(__(' Force show Shipping Checkout fields', 'woocommerce-checkout-manager'), sprintf(__('Hide %s heading', 'woocommerce-checkout-manager'), __('Ship to a different address?', 'woocommerce-checkout-manager'))); ?>
42
+ </label>
43
+ <p class="description"><?php printf(__('To be used in conjunction with %s', 'woocommerce-checkout-manager'), __('Ship to a different address?', 'woocommerce-checkout-manager')); ?></p>
44
+ </fieldset>
45
+ </td>
46
+ </tr>
47
+ <tr valign="top" class="">
48
+ <th scope="row" class="titledesc">
49
+ <?php esc_html_e('Hide create an account', 'woocommerce-checkout-manager'); ?>
50
+ </th>
51
+ <td class="forminp forminp-checkbox">
52
+ <fieldset>
53
+ <legend class="screen-reader-text">
54
+ <span>
55
+ <?php esc_html_e('Hide create an account', 'woocommerce-checkout-manager'); ?>
56
+ </span>
57
+ </legend>
58
+ <label for="auto_create_wccm_account">
59
+ <input type="checkbox" name="wccs_settings[checkness][auto_create_wccm_account]" value="true"<?php checked(!empty($options['checkness']['auto_create_wccm_account']), true); ?> />
60
+ <?php printf(__('Hide %s checkbox on Checkout page for guests', 'woocommerce-checkout-manager'), __('Create an account?', 'woocommerce-checkout-manager')); ?>
61
+ </label>
62
+ <p class="description"><?php printf(__('Hide %s checkbox on Checkout page for guests', 'woocommerce-checkout-manager'), __('Create an account?', 'woocommerce-checkout-manager')); ?></p>
63
+ </fieldset>
64
+ </td>
65
+ </tr>
66
+ <tr valign="top" class="">
67
+ <th scope="row" class="titledesc">
68
+ <?php _e('Retain Fields Information', 'woocommerce-checkout-manager'); ?>
69
+ </th>
70
+ <td class="forminp forminp-checkbox">
71
+ <fieldset>
72
+ <legend class="screen-reader-text">
73
+ <span>
74
+ <?php _e('Retain Fields Information', 'woocommerce-checkout-manager'); ?>
75
+ </span>
76
+ </legend>
77
+ <label for="retainval">
78
+ <input type="checkbox" name="wccs_settings[checkness][retainval]" value="true"<?php checked(!empty($options['checkness']['retainval']), true); ?> />
79
+ <?php _e('Retain Fields Information', 'woocommerce-checkout-manager'); ?>
80
+ </label>
81
+ <p class="description"><?php _e('Retain Fields Information', 'woocommerce-checkout-manager'); ?></p>
82
+ </fieldset>
83
+ </td>
84
+ </tr>
85
+ <tr valign="top" class="">
86
+ <th scope="row" class="titledesc">
87
+ <?php _e('Editing Of Abbreviation Fields', 'woocommerce-checkout-manager'); ?>
88
+ </th>
89
+ <td class="forminp forminp-checkbox">
90
+ <fieldset>
91
+ <legend class="screen-reader-text">
92
+ <span>
93
+ <?php _e('Editing Of Abbreviation Fields', 'woocommerce-checkout-manager'); ?>
94
+ </span>
95
+ </legend>
96
+ <label for="abbreviation">
97
+ <input type="checkbox" name="wccs_settings[checkness][abbreviation]" value="true"<?php checked(!empty($options['checkness']['abbreviation']), true); ?> />
98
+ <?php _e('Editing Of Abbreviation Fields', 'woocommerce-checkout-manager'); ?>
99
+ </label>
100
+ <p class="description"><?php _e('Editing Of Abbreviation Fields', 'woocommerce-checkout-manager'); ?></p>
101
+ </fieldset>
102
+ </td>
103
+ </tr>
104
+ <tr valign="top">
105
+ <th scope="row" class="titledesc">
106
+ <label for="position">
107
+ <?php _e('Additional fields position', 'woocommerce-checkout-manager'); ?>
108
+ <span class="woocommerce-help-tip"></span>
109
+ </label>
110
+ </th>
111
+ <td class="forminp forminp-select">
112
+ <select name="position" id="position" style="min-width:300px;" class="wc-enhanced-select enhanced" tabindex="-1" aria-hidden="true">
113
+ <option value="before_billing_form" <?php selected($options['checkness']['position'], 'before_billing_form'); ?>><?php _e('Before Billing fields', 'woocommerce-checkout-manager'); ?></option>
114
+ <option value="after_billing_form" <?php selected($options['checkness']['position'], 'after_billing_form'); ?>><?php _e('After Billing fields', 'woocommerce-checkout-manager'); ?></option>
115
+ <option value="before_shipping_form" <?php selected($options['checkness']['position'], 'before_shipping_form'); ?>><?php _e('Before Shipping fields', 'woocommerce-checkout-manager'); ?></option>
116
+ <option value="after_shipping_form" <?php selected($options['checkness']['position'], 'after_shipping_form'); ?>><?php _e('After Shipping fields', 'woocommerce-checkout-manager'); ?></option>
117
+ <option value="after_order_notes" <?php selected($options['checkness']['position'], 'after_order_notes'); ?>><?php _e('After Order Notes', 'woocommerce-checkout-manager'); ?></option>
118
+ </select>
119
+ </td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
123
+ <!--<div class="section">
124
+ <h3 class="heading checkbox">
125
+ <div class="option">
126
+ <label>
127
+ <input type="checkbox" name="wccs_settings[checkness][admin_translation]" value="true"<?php checked(!empty($options['checkness']['admin_translation']), true); ?> />
128
+ <div class="info-of"><?php _e('Translate WooCommerce Checkout Manager Options Panel', 'woocommerce-checkout-manager'); ?></div>
129
+ </label>
130
+ </div>
131
+ </h3>
132
+ </div>-->
133
+ <!-- section -->
new/admin/pages/orders.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
new/admin/pages/shipping.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
new/checkout.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!class_exists('WOOCCM_Checkout')) {
3
+
4
+ class WOOCCM_Checkout {
5
+
6
+ protected static $instance;
7
+
8
+ function ajax_checkout_attachment_upload() {
9
+
10
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_checkout_attachment_upload', 'nonce')) {
11
+
12
+ $upload_files = ( isset($_FILES['wooccm_checkout_attachment_upload']) ? $_FILES['wooccm_checkout_attachment_upload'] : false );
13
+
14
+ if (empty($upload_files)) {
15
+ wp_send_json_error(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'));
16
+ }
17
+
18
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
19
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
20
+ //require_once( ABSPATH . 'wp-admin/includes/image.php' );
21
+
22
+ $attachment_ids = array();
23
+
24
+ add_filter('upload_dir', function( $param ) {
25
+ $param['path'] = sprintf('%s/wooccm_uploads', $param['basedir']);
26
+ $param['url'] = sprintf('%s/wooccm_uploads', $param['baseurl']);
27
+ return $param;
28
+ }, 10);
29
+
30
+ foreach ($upload_files['name'] as $key => $value) {
31
+ if ($upload_files['name'][$key]) {
32
+ $file = array(
33
+ 'name' => $upload_files['name'][$key],
34
+ 'type' => $upload_files['type'][$key],
35
+ 'tmp_name' => $upload_files['tmp_name'][$key],
36
+ 'error' => $upload_files['error'][$key],
37
+ 'size' => $upload_files['size'][$key]
38
+ );
39
+
40
+ $upload = wp_handle_upload($file, array(
41
+ 'test_form' => false,
42
+ 'action' => 'wooccm_checkout_attachment_upload')
43
+ );
44
+
45
+ if (!isset($upload['error'])) {
46
+ $attachment_ids[] = wc_rest_set_uploaded_image_as_attachment($upload);
47
+ }
48
+ }
49
+ }
50
+
51
+ if (count($attachment_ids)) {
52
+ wp_send_json_success($attachment_ids);
53
+ }
54
+ }
55
+ }
56
+
57
+ function ajax_checkout_attachment_update() {
58
+
59
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_checkout_attachment_upload', 'nonce')) {
60
+
61
+ $array1 = explode(',', sanitize_text_field(isset($_POST['all_attachments_ids']) ? $_POST['all_attachments_ids'] : '' ));
62
+ $array2 = explode(',', sanitize_text_field(isset($_POST['delete_attachments_ids']) ? $_POST['delete_attachments_ids'] : '' ));
63
+
64
+ if (empty($array1) || empty($array2)) {
65
+ wp_send_json_error(esc_html__('No attachment selected.', 'woocommerce-checkout-manager'));
66
+ }
67
+
68
+ $attachment_ids = array_diff($array1, $array2);
69
+
70
+ if (!empty($attachment_ids)) {
71
+
72
+ foreach ($attachment_ids as $key => $attachtoremove) {
73
+
74
+ // Check the Attachment exists...
75
+ if (get_post_status($attachtoremove) == false)
76
+ continue;
77
+
78
+ // Check the Attachment is associated with an Order
79
+ $post_parent = get_post_field('post_parent', $attachtoremove);
80
+
81
+ if (empty($post_parent)) {
82
+ continue;
83
+ } else {
84
+ if (get_post_type($post_parent) <> 'shop_order')
85
+ continue;
86
+ }
87
+ wp_delete_attachment($attachtoremove);
88
+ }
89
+ }
90
+
91
+ wp_send_json_success('Deleted successfully.', 'woocommerce-checkout-manager');
92
+ }
93
+ }
94
+
95
+ function checkout_billing_attachment_update_ids($order_id = 0) {
96
+ $this->checkout_attachment_update_ids($order_id, 'wccs_settings3', 'billing_buttons', 'billing_');
97
+ }
98
+
99
+ function checkout_shipping_attachment_update_ids($order_id = 0) {
100
+ $this->checkout_attachment_update_ids($order_id, 'wccs_settings2', 'shipping_buttons', 'shipping_');
101
+ }
102
+
103
+ function checkout_additional_attachment_update_ids($order_id = 0) {
104
+ $this->checkout_attachment_update_ids($order_id, 'wccs_settings', 'buttons');
105
+ }
106
+
107
+ function checkout_attachment_update_ids($order_id = 0, $name, $key, $prefix = '') {
108
+
109
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
110
+
111
+ if ($options = get_option($name)) {
112
+
113
+ if (array_key_exists($key, $options)) {
114
+
115
+ if ($custom_fields = $options[$key]) {
116
+
117
+ foreach ($custom_fields as $id => $custom_field) {
118
+
119
+ if ($custom_field['type'] == 'wooccmupload') {
120
+
121
+ if ($prefix) {
122
+ $key = sprintf("_%s%s", $prefix, $custom_field['cow']);
123
+ } else {
124
+ $key = $custom_field['cow'];
125
+ }
126
+
127
+ if ($attachments = get_post_meta($order_id, $key, true)) {
128
+
129
+ if ($attachments = (array) explode(',', $attachments)) {
130
+
131
+ foreach ($attachments as $image_id) {
132
+
133
+ wp_update_post(array('ID' => $image_id, 'post_parent' => $order_id));
134
+
135
+ wp_update_attachment_metadata($image_id, wp_generate_attachment_metadata($image_id, get_attached_file($image_id)));
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+
146
+ function checkout_attachment_results() {
147
+ ?>
148
+ <div class="clear"></div>
149
+ <div style="margin: 16px 0 0 0; display: none;" id="wooccm_checkout_attachment_results" class="woocommerce-message"></div>
150
+ <?php
151
+ }
152
+
153
+ function init() {
154
+ add_action('wp_ajax_wooccm_checkout_attachment_upload', array($this, 'ajax_checkout_attachment_upload'));
155
+ add_action('wp_ajax_nopriv_wooccm_checkout_attachment_upload', array($this, 'ajax_checkout_attachment_upload'));
156
+ add_action('wp_ajax_wooccm_checkout_attachment_update', array($this, 'ajax_checkout_attachment_update'));
157
+ add_action('wp_ajax_nopriv_wooccm_checkout_attachment_update', array($this, 'ajax_checkout_attachment_update'));
158
+ add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_billing_attachment_update_ids'));
159
+ add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_shipping_attachment_update_ids'));
160
+ add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_additional_attachment_update_ids'));
161
+ add_action('woocommerce_review_order_after_submit', array($this, 'checkout_attachment_results'));
162
+ }
163
+
164
+ public static function instance() {
165
+ if (!isset(self::$instance)) {
166
+ self::$instance = new self();
167
+ self::$instance->init();
168
+ }
169
+ return self::$instance;
170
+ }
171
+
172
+ }
173
+
174
+ WOOCCM_Checkout::instance();
175
+ }
176
+
new/fields_filters.php ADDED
@@ -0,0 +1,961 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Checkout Manager
4
+ */
5
+ // Exit if accessed directly
6
+ if (!defined('ABSPATH'))
7
+ exit;
8
+
9
+ // File Picker
10
+ // -----------------------------------------------------------------------------
11
+
12
+ function wooccm_checkout_field_upload_handler($field = '', $key, $args, $value) {
13
+
14
+ global $current_user;
15
+
16
+ $user_roles = $current_user->roles;
17
+
18
+ $user_role = array_shift($user_roles);
19
+
20
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
21
+ $rolekeys = explode('||', $args['role_options']);
22
+ $rolekeys2 = explode('||', $args['role_options2']);
23
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
24
+ return;
25
+ }
26
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
27
+ return;
28
+ }
29
+ }
30
+
31
+ $upload_name = (!empty($args['placeholder']) ? esc_attr($args['placeholder']) : __('Upload Files', 'woocommerce-checkout-manager') );
32
+
33
+ if ($args['wooccm_required']) {
34
+ $args['class'][] = 'validate-required';
35
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
36
+ } else {
37
+ $required = '';
38
+ }
39
+
40
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
41
+
42
+ if (is_string($args['label_class'])) {
43
+ $args['label_class'] = array($args['label_class']);
44
+ }
45
+
46
+ if (is_null($value)) {
47
+ $value = $args['default'];
48
+ }
49
+
50
+ // Custom attribute handling
51
+ $custom_attributes = array();
52
+
53
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
54
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
55
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
56
+ }
57
+ }
58
+
59
+ if (!empty($args['validate'])) {
60
+ foreach ($args['validate'] as $validate) {
61
+ $args['class'][] = 'validate-' . $validate;
62
+ }
63
+ }
64
+
65
+ if (!empty($args['type'])) {
66
+ $args['class'][] = $args['type'] . '-field';
67
+ }
68
+
69
+ ob_start();
70
+ ?>
71
+ <p class="form-row <?php echo esc_attr(implode(' ', $args['class'])); ?>" id="<?php echo esc_attr($args['id']); ?>_field" data-cow="<?php echo esc_attr($args['cow']); ?>">
72
+ <?php if ($args['label']) : ?>
73
+ <label for="<?php echo esc_attr($args['id']); ?>" class="<?php echo esc_attr(implode(' ', $args['label_class'])); ?>">
74
+ <?php echo esc_html($args['label']) . $required; ?>
75
+ </label>
76
+ <?php endif; ?>
77
+ <button style="width:100%" class="wooccmupload_button button alt" type="button" class="button alt" id="<?php echo esc_attr($key); ?>_button"><?php echo esc_html($upload_name); ?></button>
78
+ <input style="display:none;" class="wooccmupload_field" type="hidden" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="" />
79
+ <input style="display:none;" class="fileinput-button" type="file" name="<?php echo esc_attr($key); ?>_file" id="<?php echo esc_attr($key); ?>_file" multiple="multiple" />
80
+ <span style="display:none;" class="wooccmupload_list"></span>
81
+ </p>
82
+ <?php if (!empty($args['clear'])) : ?>
83
+ <div class="clear"></div>
84
+ <?php
85
+ endif;
86
+ return ob_get_clean();
87
+ }
88
+
89
+ add_filter('woocommerce_form_field_wooccmupload', 'wooccm_checkout_field_upload_handler', 10, 4);
90
+
91
+ // Text Input
92
+ function wooccm_checkout_field_text_handler($field = '', $key, $args, $value) {
93
+
94
+ global $current_user;
95
+
96
+ $user_roles = $current_user->roles;
97
+ $user_role = array_shift($user_roles);
98
+
99
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
100
+ $rolekeys = explode('||', $args['role_options']);
101
+ $rolekeys2 = explode('||', $args['role_options2']);
102
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
103
+ return;
104
+ }
105
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
106
+ return;
107
+ }
108
+ }
109
+
110
+ if (!empty($args['clear']))
111
+ $after = '<div class="clear"></div>';
112
+ else
113
+ $after = '';
114
+
115
+ $required = false;
116
+ if ($args['wooccm_required']) {
117
+ $args['class'][] = 'validate-required';
118
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
119
+ }
120
+
121
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
122
+
123
+ if (is_string($args['label_class'])) {
124
+ $args['label_class'] = array($args['label_class']);
125
+ }
126
+
127
+ if (is_null($value)) {
128
+ $value = $args['default'];
129
+ }
130
+
131
+ // Custom attribute handling
132
+ $custom_attributes = array();
133
+
134
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
135
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
136
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
137
+ }
138
+ }
139
+
140
+ if (!empty($args['validate'])) {
141
+ foreach ($args['validate'] as $validate) {
142
+ $args['class'][] = 'validate-' . $validate;
143
+ }
144
+ }
145
+
146
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
147
+
148
+ if ($args['label'] || $required) {
149
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
150
+ }
151
+
152
+ $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) . ' />';
153
+
154
+ if ($args['description']) {
155
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
156
+ }
157
+
158
+ $field .= '</p>' . $after;
159
+
160
+ return $field;
161
+ }
162
+
163
+ add_filter('woocommerce_form_field_wooccmtext', 'wooccm_checkout_field_text_handler', 10, 4);
164
+
165
+ // Textarea
166
+ function wooccm_checkout_field_textarea_handler($field = '', $key, $args, $value) {
167
+
168
+ global $current_user;
169
+
170
+ $user_roles = $current_user->roles;
171
+ $user_role = array_shift($user_roles);
172
+
173
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
174
+ $rolekeys = explode('||', $args['role_options']);
175
+ $rolekeys2 = explode('||', $args['role_options2']);
176
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
177
+ return;
178
+ }
179
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
180
+ return;
181
+ }
182
+ }
183
+
184
+ if (!empty($args['clear']))
185
+ $after = '<div class="clear"></div>';
186
+ else
187
+ $after = '';
188
+
189
+ if ($args['wooccm_required']) {
190
+ $args['class'][] = 'validate-required';
191
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
192
+ } else {
193
+ $required = '';
194
+ }
195
+
196
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
197
+
198
+ if (is_string($args['label_class'])) {
199
+ $args['label_class'] = array($args['label_class']);
200
+ }
201
+
202
+ if (is_null($value)) {
203
+ $value = $args['default'];
204
+ }
205
+
206
+ // Custom attribute handling
207
+ $custom_attributes = array();
208
+
209
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
210
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
211
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
212
+ }
213
+ }
214
+
215
+ if (!empty($args['validate'])) {
216
+ foreach ($args['validate'] as $validate) {
217
+ $args['class'][] = 'validate-' . $validate;
218
+ }
219
+ }
220
+
221
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
222
+
223
+ if ($args['label']) {
224
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
225
+ }
226
+
227
+ // WordPress Filters to override default row and column counts
228
+ $rows = apply_filters('wooccm_checkout_field_texarea_rows', 2, $key, $args);
229
+ $columns = apply_filters('wooccm_checkout_field_texarea_columns', 5, $key, $args);
230
+
231
+ $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>';
232
+
233
+ if ($args['description']) {
234
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
235
+ }
236
+
237
+ $field .= '</p>' . $after;
238
+
239
+ return $field;
240
+ }
241
+
242
+ add_filter('woocommerce_form_field_wooccmtextarea', 'wooccm_checkout_field_textarea_handler', 10, 4);
243
+
244
+ // Password
245
+ function wooccm_checkout_field_password_handler($field = '', $key, $args, $value) {
246
+
247
+ global $current_user;
248
+
249
+ $user_roles = $current_user->roles;
250
+ $user_role = array_shift($user_roles);
251
+
252
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
253
+ $rolekeys = explode('||', $args['role_options']);
254
+ $rolekeys2 = explode('||', $args['role_options2']);
255
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
256
+ return;
257
+ }
258
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
259
+ return;
260
+ }
261
+ }
262
+
263
+ if (!empty($args['clear']))
264
+ $after = '<div class="clear"></div>';
265
+ else
266
+ $after = '';
267
+
268
+ if ($args['wooccm_required']) {
269
+ $args['class'][] = 'validate-required';
270
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
271
+ } else {
272
+ $required = '';
273
+ }
274
+
275
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
276
+
277
+ if (is_string($args['label_class'])) {
278
+ $args['label_class'] = array($args['label_class']);
279
+ }
280
+
281
+ if (is_null($value)) {
282
+ $value = $args['default'];
283
+ }
284
+
285
+ // Custom attribute handling
286
+ $custom_attributes = array();
287
+
288
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
289
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
290
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
291
+ }
292
+ }
293
+
294
+ if (!empty($args['validate'])) {
295
+ foreach ($args['validate'] as $validate) {
296
+ $args['class'][] = 'validate-' . $validate;
297
+ }
298
+ }
299
+
300
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
301
+
302
+ if ($args['label']) {
303
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
304
+ }
305
+
306
+ $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) . ' />';
307
+
308
+ if ($args['description']) {
309
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
310
+ }
311
+
312
+ $field .= '</p>' . $after;
313
+
314
+ return $field;
315
+ }
316
+
317
+ add_filter('woocommerce_form_field_wooccmpassword', 'wooccm_checkout_field_password_handler', 10, 4);
318
+
319
+ // Radio Buttons
320
+ function wooccm_checkout_field_radio_handler($field = '', $key, $args, $value) {
321
+
322
+ global $current_user;
323
+
324
+ $user_roles = $current_user->roles;
325
+ $user_role = array_shift($user_roles);
326
+
327
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
328
+ $rolekeys = explode('||', $args['role_options']);
329
+ $rolekeys2 = explode('||', $args['role_options2']);
330
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
331
+ return;
332
+ }
333
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
334
+ return;
335
+ }
336
+ }
337
+
338
+ if (!empty($args['clear']))
339
+ $after = '<div class="clear"></div>';
340
+ else
341
+ $after = '';
342
+
343
+ if ($args['wooccm_required']) {
344
+ $args['class'][] = 'validate-required';
345
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
346
+ } else {
347
+ $required = '';
348
+ }
349
+
350
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
351
+
352
+ $field = '<div class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '_field">';
353
+
354
+ $field .= '<fieldset><legend>' . $args['label'] . $required . '</legend>';
355
+
356
+ if (!empty($args['options'])) {
357
+ foreach (explode('||', $args['options']) as $option_key => $option_text) {
358
+ $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>';
359
+ }
360
+ }
361
+
362
+ $field .= '</fieldset></div>' . $after;
363
+
364
+ return $field;
365
+ }
366
+
367
+ add_filter('woocommerce_form_field_wooccmradio', 'wooccm_checkout_field_radio_handler', 10, 4);
368
+
369
+ // Select Options
370
+ function wooccm_checkout_field_select_handler($field = '', $key, $args, $value) {
371
+
372
+ global $current_user;
373
+
374
+ $user_roles = $current_user->roles;
375
+ $user_role = array_shift($user_roles);
376
+
377
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
378
+ $rolekeys = explode('||', $args['role_options']);
379
+ $rolekeys2 = explode('||', $args['role_options2']);
380
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
381
+ return;
382
+ }
383
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
384
+ return;
385
+ }
386
+ }
387
+
388
+ if (!empty($args['clear']))
389
+ $after = '<div class="clear"></div>';
390
+ else
391
+ $after = '';
392
+
393
+ if ($args['wooccm_required']) {
394
+ $args['class'][] = 'validate-required';
395
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
396
+ } else {
397
+ $required = '';
398
+ }
399
+
400
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
401
+
402
+ $options = '';
403
+
404
+ if (!empty($args['options'])) {
405
+ $options .= ( $args['default'] ? '<option value="">' . $args['default'] . '</option>' : '' );
406
+ foreach (explode('||', $args['options']) as $option_key => $option_text)
407
+ $options .= '<option ' . selected($value, $option_key, false) . '>' . wooccm_wpml_string(esc_attr($option_text)) . '</option>';
408
+ }
409
+
410
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '_field">';
411
+
412
+ if ($args['label'])
413
+ $field .= '<label for="' . esc_attr($key) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>';
414
+
415
+ $field .= '
416
+ <select class="' . esc_attr($args['fancy']) . '" data-placeholder="' . (!empty($args['default']) ? __($args['default'], 'woocommerce-checkout-manager') : '' ) . '" name="' . esc_attr($key) . '" id="' . esc_attr($key) . '" >
417
+ ' . $options . '
418
+ </select>
419
+ </p>' . $after;
420
+
421
+ return $field;
422
+ }
423
+
424
+ add_filter('woocommerce_form_field_wooccmselect', 'wooccm_checkout_field_select_handler', 10, 4);
425
+
426
+ // Check Box
427
+ function wooccm_checkout_field_checkbox_handler($field = '', $key, $args, $value) {
428
+
429
+ global $current_user;
430
+
431
+ $user_roles = $current_user->roles;
432
+ $user_role = array_shift($user_roles);
433
+
434
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
435
+ $rolekeys = explode('||', $args['role_options']);
436
+ $rolekeys2 = explode('||', $args['role_options2']);
437
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
438
+ return;
439
+ }
440
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
441
+ return;
442
+ }
443
+ }
444
+
445
+ $args['options'] = explode('||', $args['options']);
446
+
447
+ if (!empty($args['clear']))
448
+ $after = '<div class="clear"></div>';
449
+ else
450
+ $after = '';
451
+
452
+ if ($args['wooccm_required']) {
453
+ $args['class'][] = 'validate-required';
454
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
455
+ } else {
456
+ $required = '';
457
+ }
458
+
459
+ $field = '
460
+ <p class="form-row ' . implode(' ', $args['class']) . '" id="' . $key . '_field">
461
+ <label for="' . $key . '_checkbox" class="woocommerce-form__label woocommerce-form__label-for-checkbox ' . implode(' ', $args['label_class']) . '">
462
+ <input type="checkbox" id="' . $key . '_checkbox" name="' . $key . '" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" value="1" />
463
+ <span>' . $args['label'] . '</span>' . $required . '
464
+ </label>
465
+ </p>' . $after;
466
+
467
+ return $field;
468
+ }
469
+
470
+ add_filter('woocommerce_form_field_checkbox_wccm', 'wooccm_checkout_field_checkbox_handler', 10, 4);
471
+
472
+ // State
473
+ function wooccm_checkout_field_state_handler($field = '', $key, $args, $value) {
474
+
475
+ global $current_user;
476
+
477
+ $user_roles = $current_user->roles;
478
+ $user_role = array_shift($user_roles);
479
+
480
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
481
+ $rolekeys = explode('||', $args['role_options']);
482
+ $rolekeys2 = explode('||', $args['role_options2']);
483
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
484
+ return;
485
+ }
486
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
487
+ return;
488
+ }
489
+ }
490
+
491
+ if (!empty($args['clear']))
492
+ $after = '<div class="clear"></div>';
493
+ else
494
+ $after = '';
495
+
496
+ $args['class'][] = 'address-field';
497
+
498
+ $country_key = $key == 'billing_state' ? 'billing_country' : 'shipping_country';
499
+ $current_cc = WC()->checkout->get_value($country_key);
500
+ $states = WC()->countries->get_states($current_cc);
501
+
502
+ if ($args['wooccm_required']) {
503
+ if (!empty($states)) {
504
+ if (!in_array('validate-required', $args['class']))
505
+ $args['class'][] = 'validate-required';
506
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
507
+ } else {
508
+ $args['class'][] = 'woocommerce-validated';
509
+ }
510
+ } else {
511
+ $required = '';
512
+ $args['class'][] = 'woocommerce-validated';
513
+ }
514
+
515
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
516
+
517
+ if (is_string($args['label_class'])) {
518
+ $args['label_class'] = array($args['label_class']);
519
+ }
520
+
521
+ if (is_null($value)) {
522
+ $value = $args['default'];
523
+ }
524
+
525
+ // Custom attribute handling
526
+ $custom_attributes = array();
527
+
528
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
529
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
530
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
531
+ }
532
+ }
533
+
534
+ if (!empty($states) && !empty($args['validate'])) {
535
+ foreach ($args['validate'] as $validate) {
536
+ $args['class'][] = 'validate-' . $validate;
537
+ }
538
+ }
539
+
540
+ if (is_array($states) && empty($states)) {
541
+
542
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field" style="display: none">';
543
+
544
+ if ($args['label']) {
545
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
546
+ }
547
+ $field .= '<input type="hidden" class="hidden" name="' . esc_attr($key) . '" id="' . esc_attr($args['id']) . '" value="" ' . implode(' ', $custom_attributes) . ' placeholder="' . esc_attr($args['placeholder']) . '" />';
548
+
549
+ if ($args['description']) {
550
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
551
+ }
552
+
553
+ $field .= '</p>' . $after;
554
+ } elseif (is_array($states)) {
555
+
556
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
557
+
558
+ if ($args['label'])
559
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
560
+ $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']) . '">
561
+ <option value="">' . __('Select a state&hellip;', 'woocommerce-checkout-manager') . '</option>';
562
+
563
+ foreach ($states as $ckey => $cvalue) {
564
+ $field .= '<option value="' . esc_attr($ckey) . '" ' . selected($value, $ckey, false) . '>' . (!empty($cvalue) ? __($cvalue, 'woocommerce-checkout-manager') : '' ) . '</option>';
565
+ }
566
+
567
+ $field .= '</select>';
568
+
569
+ if ($args['description']) {
570
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
571
+ }
572
+
573
+ $field .= '</p>' . $after;
574
+ } else {
575
+
576
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
577
+
578
+ if ($args['label']) {
579
+ $field .= '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
580
+ }
581
+ $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) . ' />';
582
+
583
+ if ($args['description']) {
584
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
585
+ }
586
+
587
+ $field .= '</p>' . $after;
588
+ }
589
+
590
+ return $field;
591
+ }
592
+
593
+ add_filter('woocommerce_form_field_wooccmstate', 'wooccm_checkout_field_state_handler', 10, 4);
594
+
595
+ // Country
596
+ function wooccm_checkout_field_country_handler($field = '', $key, $args, $value) {
597
+
598
+ global $current_user;
599
+
600
+ $user_roles = $current_user->roles;
601
+ $user_role = array_shift($user_roles);
602
+
603
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
604
+ $rolekeys = explode('||', $args['role_options']);
605
+ $rolekeys2 = explode('||', $args['role_options2']);
606
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
607
+ return;
608
+ }
609
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
610
+ return;
611
+ }
612
+ }
613
+
614
+ if (!empty($args['clear']))
615
+ $after = '<div class="clear"></div>';
616
+ else
617
+ $after = '';
618
+
619
+ $args['class'][] = 'address-field';
620
+
621
+ if ($args['wooccm_required']) {
622
+ $args['class'][] = 'validate-required';
623
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
624
+ } else {
625
+ $required = '';
626
+ }
627
+
628
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
629
+
630
+ if (is_string($args['label_class'])) {
631
+ $args['label_class'] = array($args['label_class']);
632
+ }
633
+
634
+ if (is_null($value)) {
635
+ $value = $args['default'];
636
+ }
637
+
638
+ // Custom attribute handling
639
+ $custom_attributes = array();
640
+
641
+ if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
642
+ foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
643
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
644
+ }
645
+ }
646
+
647
+ if (!empty($args['validate'])) {
648
+ foreach ($args['validate'] as $validate) {
649
+ $args['class'][] = 'validate-' . $validate;
650
+ }
651
+ }
652
+
653
+ $countries = $key == 'shipping_country' ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries();
654
+
655
+ if (sizeof($countries) == 1) {
656
+
657
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">';
658
+
659
+ if ($args['label']) {
660
+ $field .= '<label class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . '</label>';
661
+ }
662
+
663
+ $field .= '<strong>' . current(array_values($countries)) . '</strong>';
664
+
665
+ $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" />';
666
+
667
+ if ($args['description']) {
668
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
669
+ }
670
+
671
+ $field .= '</p>' . $after;
672
+ } else {
673
+
674
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($args['id']) . '_field">'
675
+ . '<label for="' . esc_attr($args['id']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>'
676
+ . '<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) . '>'
677
+ . '<option value="">' . __('Select a country&hellip;', 'woocommerce-checkout-manager') . '</option>';
678
+
679
+ foreach ($countries as $ckey => $cvalue) {
680
+ $field .= '<option value="' . esc_attr($ckey) . '" ' . selected($value, $ckey, false) . '>' . (!empty($cvalue) ? __($cvalue, 'woocommerce-checkout-manager') : '' ) . '</option>';
681
+ }
682
+
683
+ $field .= '</select>';
684
+
685
+ $field .= '<noscript><input type="submit" name="woocommerce_checkout_update_totals" value="' . __('Update country', 'woocommerce-checkout-manager') . '" /></noscript>';
686
+
687
+ if ($args['description']) {
688
+ $field .= '<span class="description">' . esc_attr($args['description']) . '</span>';
689
+ }
690
+
691
+ $field .= '</p>' . $after;
692
+ }
693
+
694
+ return $field;
695
+ }
696
+
697
+ add_filter('woocommerce_form_field_wooccmcountry', 'wooccm_checkout_field_country_handler', 10, 4);
698
+
699
+ // Multi-Select
700
+ function wooccm_checkout_field_multiselect_handler($field = '', $key, $args, $value) {
701
+
702
+ global $current_user;
703
+
704
+ $user_roles = $current_user->roles;
705
+ $user_role = array_shift($user_roles);
706
+
707
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
708
+ $rolekeys = explode('||', $args['role_options']);
709
+ $rolekeys2 = explode('||', $args['role_options2']);
710
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
711
+ return;
712
+ }
713
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
714
+ return;
715
+ }
716
+ }
717
+
718
+ if (!empty($args['clear']))
719
+ $after = '<div class="clear"></div>';
720
+ else
721
+ $after = '';
722
+
723
+ if ($args['wooccm_required']) {
724
+ $args['class'][] = 'validate-required';
725
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
726
+ } else {
727
+ $required = '';
728
+ }
729
+
730
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
731
+
732
+ $options = '';
733
+
734
+ if (!empty($args['options']))
735
+ foreach (explode('||', $args['options']) as $option_key => $option_text)
736
+ $options .= '<option value="' . wooccm_wpml_string(esc_attr($option_text)) . '" ' . selected($value, $option_key, false) . '>' . wooccm_wpml_string(esc_attr($option_text)) . '</option>';
737
+
738
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '_field">';
739
+
740
+ if ($args['label'])
741
+ $field .= '<label for="' . esc_attr($key) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>';
742
+
743
+ $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">
744
+ ' . $options . '
745
+ </select>
746
+ </p>' . $after;
747
+
748
+ return $field;
749
+ }
750
+
751
+ add_filter('woocommerce_form_field_multiselect', 'wooccm_checkout_field_multiselect_handler', 10, 4);
752
+
753
+ // Multi-Checkbox
754
+ function wooccm_checkout_field_multicheckbox_handler($field = '', $key, $args, $value) {
755
+
756
+ global $current_user;
757
+
758
+ $user_roles = $current_user->roles;
759
+ $user_role = array_shift($user_roles);
760
+
761
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
762
+ $rolekeys = explode('||', $args['role_options']);
763
+ $rolekeys2 = explode('||', $args['role_options2']);
764
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
765
+ return;
766
+ }
767
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
768
+ return;
769
+ }
770
+ }
771
+
772
+ if (!empty($args['clear']))
773
+ $after = '<div class="clear"></div>';
774
+ else
775
+ $after = '';
776
+
777
+ if ($args['wooccm_required']) {
778
+ $args['class'][] = 'validate-required';
779
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
780
+ } else {
781
+ $required = '';
782
+ }
783
+
784
+ $args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint($args['maxlength']) . '"' : '';
785
+
786
+ $options = '';
787
+
788
+ if (!empty($args['options'])) {
789
+ foreach (explode('||', $args['options']) as $option_key => $option_text) {
790
+ $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>';
791
+ }
792
+ }
793
+
794
+ $field = '<p class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '_field">';
795
+
796
+ if ($args['label'])
797
+ $field .= '<label class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>';
798
+
799
+ $field .= $options . '
800
+ </p>' . $after;
801
+
802
+ return $field;
803
+ }
804
+
805
+ add_filter('woocommerce_form_field_multicheckbox', 'wooccm_checkout_field_multicheckbox_handler', 10, 4);
806
+
807
+ // Color Picker
808
+ function wooccm_checkout_field_colorpicker_handler($field = '', $key, $args, $value) {
809
+
810
+ global $current_user;
811
+
812
+ $user_roles = $current_user->roles;
813
+ $user_role = array_shift($user_roles);
814
+
815
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
816
+ $rolekeys = explode('||', $args['role_options']);
817
+ $rolekeys2 = explode('||', $args['role_options2']);
818
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
819
+ return;
820
+ }
821
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
822
+ return;
823
+ }
824
+ }
825
+
826
+ if (!empty($args['clear']))
827
+ $after = '<div class="clear"></div>';
828
+ else
829
+ $after = '';
830
+
831
+ if ($args['wooccm_required']) {
832
+ $args['class'][] = 'validate-required';
833
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
834
+ } else {
835
+ $required = '';
836
+ }
837
+
838
+ //if ( isset($value) ) {
839
+ $value = $args['color'];
840
+ //}
841
+
842
+ $field = '
843
+ <p class="form-row ' . implode(' ', $args['class']) . ' wccs_colorpicker" id="' . $key . '_field">
844
+ <label for="' . $key . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>
845
+ <input type="text" class="input-text" maxlength="7" size="6" name="' . $key . '" id="' . $key . '_colorpicker" placeholder="' . $args['placeholder'] . '" value="' . $value . '" />
846
+ <span id="' . $key . '_colorpickerdiv" class="spec_shootd"></span>
847
+ </p>' . $after;
848
+
849
+ return $field;
850
+ }
851
+
852
+ add_filter('woocommerce_form_field_colorpicker', 'wooccm_checkout_field_colorpicker_handler', 10, 4);
853
+
854
+ // Date Picker
855
+ function wooccm_checkout_field_datepicker_handler($field = '', $key, $args, $value) {
856
+
857
+ global $current_user;
858
+
859
+ $user_roles = $current_user->roles;
860
+ $user_role = array_shift($user_roles);
861
+
862
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
863
+ $rolekeys = explode('||', $args['role_options']);
864
+ $rolekeys2 = explode('||', $args['role_options2']);
865
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
866
+ return;
867
+ }
868
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
869
+ return;
870
+ }
871
+ }
872
+
873
+ if (!empty($args['clear']))
874
+ $after = '<div class="clear"></div>';
875
+ else
876
+ $after = '';
877
+
878
+ if ($args['wooccm_required']) {
879
+ $args['class'][] = 'validate-required';
880
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
881
+ } else {
882
+ $required = '';
883
+ }
884
+
885
+ $field = '<p class="form-row ' . implode(' ', $args['class']) . 'MyDate' . $args['cow'] . ' wccs-form-row-wide" id="' . $key . '_field">
886
+ <label for="' . $key . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>
887
+ <input type="text" class="input-text" name="' . $key . '" id="' . $key . '" placeholder="' . $args['placeholder'] . '" value="' . $value . '" />
888
+ </p>' . $after;
889
+
890
+ return $field;
891
+ }
892
+
893
+ add_filter('woocommerce_form_field_datepicker', 'wooccm_checkout_field_datepicker_handler', 10, 4);
894
+
895
+ // Time Picker
896
+ function wooccm_checkout_field_timepicker_handler($field = '', $key, $args, $value) {
897
+
898
+ global $current_user;
899
+
900
+ $user_roles = $current_user->roles;
901
+ $user_role = array_shift($user_roles);
902
+
903
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
904
+ $rolekeys = explode('||', $args['role_options']);
905
+ $rolekeys2 = explode('||', $args['role_options2']);
906
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
907
+ return;
908
+ }
909
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
910
+ return;
911
+ }
912
+ }
913
+
914
+ if (!empty($args['clear']))
915
+ $after = '<div class="clear"></div>';
916
+ else
917
+ $after = '';
918
+
919
+ if ($args['wooccm_required']) {
920
+ $args['class'][] = 'validate-required';
921
+ $required = '&nbsp;<abbr class="required" title="' . esc_attr__('required', 'woocommerce') . '">*</abbr>';
922
+ } else {
923
+ $required = '';
924
+ }
925
+
926
+ $field = '<p class="form-row ' . implode(' ', $args['class']) . 'MyTime' . $args['cow'] . ' wccs-form-row-wide" id="' . $key . '_field">
927
+ <label for="' . $key . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>
928
+ <input type="text" class="input-text" name="' . $key . '" id="' . $key . '" placeholder="' . $args['placeholder'] . '" value="' . $value . '" />
929
+ </p>' . $after;
930
+
931
+ return $field;
932
+ }
933
+
934
+ add_filter('woocommerce_form_field_time', 'wooccm_checkout_field_timepicker_handler', 10, 4);
935
+
936
+ // Heading
937
+ function wooccm_checkout_field_heading_handler($field = '', $key, $args, $value) {
938
+
939
+ global $current_user;
940
+
941
+ $user_roles = $current_user->roles;
942
+ $user_role = array_shift($user_roles);
943
+
944
+ if (!empty($args['user_role']) && (!empty($args['role_options']) || !empty($args['role_options2']))) {
945
+ $rolekeys = explode('||', $args['role_options']);
946
+ $rolekeys2 = explode('||', $args['role_options2']);
947
+ if (!empty($args['role_options']) && !in_array($user_role, $rolekeys)) {
948
+ return;
949
+ }
950
+ if (!empty($args['role_options2']) && in_array($user_role, $rolekeys2)) {
951
+ return;
952
+ }
953
+ }
954
+
955
+ $field = '<h3 class="form-row ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '_field">' . $args['label'] . '</h3>';
956
+
957
+ return $field;
958
+ }
959
+
960
+ add_filter('woocommerce_form_field_heading', 'wooccm_checkout_field_heading_handler', 10, 4);
961
+ ?>
new/fields_register.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('WOOCCM_Fields_Register')) {
4
+
5
+ class WOOCCM_Fields_Register {
6
+
7
+ protected static $instance;
8
+
9
+ function get_positioning($position = 'after_order_notes') {
10
+
11
+ if ($options = get_option('wccs_settings')) {
12
+
13
+ if (!empty($options['checkness']['position'])) {
14
+ $position = sanitize_text_field($options['checkness']['position']);
15
+ }
16
+
17
+ return $position;
18
+ }
19
+
20
+ return false;
21
+ }
22
+
23
+ function add_checkout_field_filter($key, $fields, $custom_field) {
24
+
25
+ $defaults = array(
26
+ 'address_1',
27
+ 'address_2',
28
+ 'city',
29
+ 'postcode',
30
+ 'state',
31
+ 'country'
32
+ );
33
+
34
+ if ($custom_field['cow'] == 'country') {
35
+ // Country override
36
+ $fields[$key]['type'] = 'wooccmcountry';
37
+ } elseif ($custom_field['cow'] == 'state') {
38
+ // State override
39
+ $fields[$key]['type'] = 'wooccmstate';
40
+ } else {
41
+ $fields[$key]['type'] = $custom_field['type'];
42
+ }
43
+
44
+ if ($custom_field['cow'] !== 'country' || $custom_field['cow'] !== 'state') {
45
+ $fields[$key]['placeholder'] = ( isset($custom_field['placeholder']) ? $custom_field['placeholder'] : '' );
46
+ }
47
+
48
+ // Default to Position wide
49
+ $custom_field['position'] = ( isset($custom_field['position']) ? $custom_field['position'] : 'form-row-wide' );
50
+ $fields[$key]['class'] = array($custom_field['position'] . ' ' . ( isset($custom_field['conditional_tie']) ? $custom_field['conditional_tie'] : '' ) . ' ' . ( isset($custom_field['extra_class']) ? $custom_field['extra_class'] : '' ));
51
+ $fields[$key]['label'] = wooccm_wpml_string($custom_field['label']);
52
+ $fields[$key]['clear'] = ( isset($custom_field['clear_row']) ? $custom_field['clear_row'] : '' );
53
+ $fields[$key]['default'] = ( isset($custom_field['force_title2']) ? $custom_field['force_title2'] : '' );
54
+ $fields[$key]['options'] = ( isset($custom_field['option_array']) ? $custom_field['option_array'] : '' );
55
+ $fields[$key]['user_role'] = ( isset($custom_field['user_role']) ? $custom_field['user_role'] : '' );
56
+ $fields[$key]['role_options'] = ( isset($custom_field['role_options']) ? $custom_field['role_options'] : '' );
57
+ $fields[$key]['role_options2'] = ( isset($custom_field['role_options2']) ? $custom_field['role_options2'] : '' );
58
+ $fields[$key]['required'] = ( isset($custom_field['checkbox']) ? $custom_field['checkbox'] : '' );
59
+ $fields[$key]['wooccm_required'] = ( isset($custom_field['checkbox']) ? $custom_field['checkbox'] : '' );
60
+ $fields[$key]['cow'] = ( isset($custom_field['cow']) ? $custom_field['cow'] : '' );
61
+ $fields[$key]['color'] = ( isset($custom_field['colorpickerd']) ? $custom_field['colorpickerd'] : '' );
62
+ $fields[$key]['colorpickertype'] = ( isset($custom_field['colorpickertype']) ? $custom_field['colorpickertype'] : '' );
63
+ $fields[$key]['order'] = ( isset($custom_field['order']) ? $custom_field['order'] : '' );
64
+ $fields[$key]['priority'] = ( isset($custom_field['priority']) ? $custom_field['priority'] : $fields[$key]['order'] );
65
+ $fields[$key]['fancy'] = ( isset($custom_field['fancy']) ? $custom_field['fancy'] : '' );
66
+
67
+ // Remove required for heading
68
+
69
+ if ($custom_field['type'] == 'heading') {
70
+ $fields[$key]['required'] = false;
71
+
72
+ //error_log(json_encode($fields[$key]));
73
+ }
74
+
75
+ // Check if Multi-checkbox has options assigned to it
76
+ if ($custom_field['type'] == 'multicheckbox' && empty($custom_field['option_array'])) {
77
+ $custom_field['disabled'] = true;
78
+ }
79
+
80
+ // Bolt on address-field for address-based fields
81
+ if (in_array($custom_field['cow'], $defaults)) {
82
+ $fields[$key]['class'][] = 'address-field';
83
+ }
84
+
85
+ // Override for State fields
86
+ if ($fields[$key]['type'] == 'wooccmstate') {
87
+ $country_key = false;
88
+ if ($key == 'billing_state') {
89
+ $country_key = 'billing_country';
90
+ }
91
+ if ($key == 'shipping_state') {
92
+ $country_key = 'shipping_country';
93
+ }
94
+ if (!empty($country_key)) {
95
+ $current_cc = WC()->checkout->get_value($country_key);
96
+ $states = WC()->countries->get_states($current_cc);
97
+ if (empty($states)) {
98
+ $fields[$key]['required'] = false;
99
+ $fields[$key]['wooccm_required'] = false;
100
+ }
101
+ }
102
+ }
103
+
104
+ return $fields[$key];
105
+ }
106
+
107
+ function add_checkout_fields_filter($fields, $name, $key, $prefix = '') {
108
+
109
+ if ($options = get_option($name)) {
110
+
111
+ if (array_key_exists($key, $options)) {
112
+
113
+ if ($custom_fields = $options[$key]) {
114
+
115
+ foreach ($custom_fields as $id => $custom_field) {
116
+
117
+ if (!empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
118
+
119
+ $key = sprintf("%s%s", $prefix, $custom_field['cow']);
120
+
121
+ $fields[$key] = $this->add_checkout_field_filter($key, $fields, $custom_field);
122
+
123
+ // Remove disabled fields
124
+ if (!empty($custom_field['disabled'])) {
125
+ unset($fields[$key]);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ // Resort the fields by order
133
+ $fields[] = uasort($fields, 'wooccm_sort_fields');
134
+
135
+ if ($fields[0]) {
136
+ unset($fields[0]);
137
+ }
138
+ }
139
+
140
+ return $fields;
141
+ }
142
+
143
+ function add_checkout_additional_fields($checkout) {
144
+
145
+ if ($options = get_option('wccs_settings')) {
146
+
147
+ if (array_key_exists('buttons', $options)) {
148
+
149
+ if ($buttons = $options['buttons']) {
150
+
151
+ foreach ($buttons as $key => $custom_field) {
152
+ woocommerce_form_field($custom_field['cow'], $this->add_checkout_field_filter($key, $custom_field, $custom_field), $checkout->get_value($custom_field['cow']));
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ function add_checkout_shipping_fields($fields) {
160
+ return $this->add_checkout_fields_filter($fields, 'wccs_settings2', 'shipping_buttons', 'shipping_');
161
+ }
162
+
163
+ function add_checkout_billing_fields($fields) {
164
+ return $this->add_checkout_fields_filter($fields, 'wccs_settings3', 'billing_buttons', 'billing_');
165
+ }
166
+
167
+ function init() {
168
+
169
+ // Billing fields
170
+ // -----------------------------------------------------------------------
171
+ add_filter('woocommerce_billing_fields', array($this, 'add_checkout_billing_fields'));
172
+
173
+ // Shipping fields
174
+ // -----------------------------------------------------------------------
175
+
176
+ add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
177
+ // Additional fields
178
+ // -----------------------------------------------------------------------
179
+ switch ($this->get_positioning()) {
180
+ case 'before_shipping_form':
181
+ add_action('woocommerce_before_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
182
+ break;
183
+
184
+ case 'after_shipping_form':
185
+ add_action('woocommerce_after_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
186
+ break;
187
+
188
+ case 'before_billing_form':
189
+ add_action('woocommerce_before_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
190
+ break;
191
+
192
+ case 'after_billing_form':
193
+ add_action('woocommerce_after_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
194
+ break;
195
+
196
+ case 'after_order_notes':
197
+ add_action('woocommerce_after_order_notes', array($this, 'add_checkout_additional_fields'));
198
+ break;
199
+ }
200
+ }
201
+
202
+ public static function instance() {
203
+ if (!isset(self::$instance)) {
204
+ self::$instance = new self();
205
+ self::$instance->init();
206
+ }
207
+ return self::$instance;
208
+ }
209
+
210
+ }
211
+
212
+ WOOCCM_Fields_Register::instance();
213
+ }
new/fields_required.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('WOOCCM_Fields_Required')) {
4
+
5
+ class WOOCCM_Fields_Required extends WOOCCM_Fields_Register {
6
+
7
+ protected static $instance;
8
+
9
+ function add_checkout_fields_required($fields, $name, $key, $prefix = '') {
10
+
11
+ if ($options = get_option($name)) {
12
+
13
+ if (array_key_exists($key, $options)) {
14
+
15
+ if ($custom_fields = $options[$key]) {
16
+
17
+ foreach ($custom_fields as $id => $custom_field) {
18
+
19
+ $key = sprintf("%s%s", $prefix, $custom_field['cow']);
20
+
21
+ $custom_field = $this->add_checkout_field_filter($key, $custom_fields, $custom_field);
22
+
23
+ if (!empty($custom_field['required']) && !empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
24
+
25
+ if (empty($_POST[$custom_field['cow']])) {
26
+ $message = sprintf(__('%s is a required field.', 'woocommerce-checkout-manager'), '<strong>' . wooccm_wpml_string($custom_field['label']) . '</strong>');
27
+ wc_add_notice($message, 'error');
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ return $fields;
36
+ }
37
+
38
+ function add_checkout_additional_required($fields) {
39
+ return $this->add_checkout_fields_required($fields, 'wccs_settings', 'buttons');
40
+ }
41
+
42
+ //function add_checkout_shipping_required($fields) {
43
+ // return $this->add_checkout_fields_required($fields, 'wccs_settings2', 'shipping_buttons', 'shipping_');
44
+ //}
45
+ //function add_checkout_billing_required($fields) {
46
+ // return $this->add_checkout_fields_required($fields, 'wccs_settings3', 'billing_buttons', 'billing_');
47
+ //}
48
+
49
+ function init() {
50
+ add_action('woocommerce_checkout_process', array($this, 'add_checkout_additional_required'));
51
+ //add_action('woocommerce_checkout_process', array($this, 'add_checkout_billing_required'));
52
+ //add_action('woocommerce_checkout_process', array($this, 'add_checkout_shipping_required'));
53
+ }
54
+
55
+ public static function instance() {
56
+ if (!isset(self::$instance)) {
57
+ self::$instance = new self();
58
+ self::$instance->init();
59
+ }
60
+ return self::$instance;
61
+ }
62
+
63
+ }
64
+
65
+ WOOCCM_Fields_Required::instance();
66
+ }
new/orders.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('WOOCCM_Orders')) {
4
+
5
+ class WOOCCM_Orders {
6
+
7
+ protected static $instance;
8
+
9
+ static function is_frontend_ajax() {
10
+ $script_filename = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
11
+
12
+ //Try to figure out if frontend AJAX request... If we are DOING_AJAX; let's look closer
13
+ if ((defined('DOING_AJAX') && DOING_AJAX)) {
14
+ //From wp-includes/functions.php, wp_get_referer() function.
15
+ //Required to fix: https://core.trac.wordpress.org/ticket/25294
16
+ $ref = '';
17
+ if (!empty($_REQUEST['_wp_http_referer']))
18
+ $ref = wp_unslash($_REQUEST['_wp_http_referer']);
19
+ elseif (!empty($_SERVER['HTTP_REFERER']))
20
+ $ref = wp_unslash($_SERVER['HTTP_REFERER']);
21
+
22
+ //If referer does not contain admin URL and we are using the admin-ajax.php endpoint, this is likely a frontend AJAX request
23
+ if (((strpos($ref, admin_url()) === false) && (basename($script_filename) === 'admin-ajax.php')))
24
+ return true;
25
+ }
26
+
27
+ //If no checks triggered, we end up here - not an AJAX request.
28
+ return false;
29
+ }
30
+
31
+ function ajax_order_attachment_upload() {
32
+
33
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_admin', 'nonce')) {
34
+
35
+ $upload_files = ( isset($_FILES['wooccm_order_attachment_upload']) ? $_FILES['wooccm_order_attachment_upload'] : false );
36
+
37
+ if (empty($upload_files)) {
38
+ wp_send_json_error(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'));
39
+ }
40
+
41
+ $order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
42
+
43
+ if (empty($order_id)) {
44
+ wp_send_json_error(esc_html__('Empty order id.', 'woocommerce-checkout-manager'));
45
+ }
46
+
47
+ if (!$post = get_post($order_id)) {
48
+ wp_send_json_error(esc_html__('Invalid order id.', 'woocommerce-checkout-manager'));
49
+ }
50
+
51
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
52
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
53
+ //require_once( ABSPATH . 'wp-admin/includes/image.php' );
54
+
55
+ $attachment_ids = array();
56
+
57
+ add_filter('upload_dir', function( $param ) {
58
+ $param['path'] = sprintf('%s/wooccm_uploads', $param['basedir']);
59
+ $param['url'] = sprintf('%s/wooccm_uploads', $param['baseurl']);
60
+ return $param;
61
+ }, 10);
62
+
63
+ foreach ($upload_files['name'] as $key => $value) {
64
+ if ($upload_files['name'][$key]) {
65
+ $file = array(
66
+ 'name' => $upload_files['name'][$key],
67
+ 'type' => $upload_files['type'][$key],
68
+ 'tmp_name' => $upload_files['tmp_name'][$key],
69
+ 'error' => $upload_files['error'][$key],
70
+ 'size' => $upload_files['size'][$key]
71
+ );
72
+
73
+ $upload = wp_handle_upload($file, array(
74
+ 'test_form' => false,
75
+ 'action' => 'wooccm_order_attachment_upload')
76
+ );
77
+
78
+ if (!isset($upload['error'])) {
79
+ $attachment_ids[] = wc_rest_set_uploaded_image_as_attachment($upload, $order_id);
80
+ }
81
+ }
82
+ }
83
+
84
+ if (count($attachment_ids)) {
85
+
86
+ ob_start();
87
+
88
+ if (!self::is_frontend_ajax()) {
89
+ $this->order_uploads_metabox_content($post);
90
+ } else {
91
+ $this->order_uploads($post->ID);
92
+ }
93
+
94
+ wp_send_json_success(ob_get_clean());
95
+ /* send email
96
+ $email_recipients = $options['checkness']['wooccm_notification_email'];
97
+ if (empty($email_recipients))
98
+ $email_recipients = get_option('admin_email');
99
+ $email_heading = __('Files Uploaded by Customer', 'woocommerce-checkout-manager');
100
+ $subject = sprintf(__('WooCommerce Checkout Manager - %s [%s]', 'woocommerce-checkout-manager'), $email_heading, $order->billing_first_name . ' ' . $order->billing_last_name);
101
+
102
+ $mailer = WC()->mailer();
103
+
104
+ // Buffer
105
+ ob_start();
106
+ ?>
107
+ <p>This is an automatic message from WooCommerce Checkout Manager, reporting that files have been uploaded by <?php echo $order->billing_first_name; ?> <?php echo $order->billing_last_name; ?>.</p>
108
+ <h3>Customer Details</h3>
109
+ <ul>
110
+ <li>Name: <?php echo $order->billing_first_name; ?> <?php $order->billing_last_name; ?></li>
111
+ <li>E-mail: <?php echo $order->billing_email; ?></li>
112
+ <li>Order Number: <?php echo $order_id; ?></li>
113
+ </ul>
114
+ <p>You can view the files and order details via back-end by following this <a href="<?php echo admin_url('/post.php?post=' . $order_id . '&action=edit'); ?>" target="_blank">link</a>.</p>
115
+ <?php
116
+ // Get contents
117
+ $message = ob_get_clean();
118
+
119
+ $message = $mailer->wrap_message($email_heading, $message);
120
+
121
+ // add_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
122
+ // wc_mail( $email_recipients, $subject, $message );
123
+ $mailer->send($email_recipients, strip_tags($subject), $message);
124
+ // remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' ); */
125
+ }
126
+ }
127
+ }
128
+
129
+ function ajax_order_attachment_update() {
130
+
131
+ if (!empty($_REQUEST) && check_admin_referer('wooccm_admin', 'nonce')) {
132
+
133
+ $array1 = explode(',', sanitize_text_field(isset($_POST['all_attachments_ids']) ? $_POST['all_attachments_ids'] : '' ));
134
+ $array2 = explode(',', sanitize_text_field(isset($_POST['delete_attachments_ids']) ? $_POST['delete_attachments_ids'] : '' ));
135
+
136
+ if (empty($array1) || empty($array2)) {
137
+ wp_send_json_error(esc_html__('No attachment selected.', 'woocommerce-checkout-manager'));
138
+ }
139
+
140
+ $attachment_ids = array_diff($array1, $array2);
141
+
142
+ if (!empty($attachment_ids)) {
143
+
144
+ foreach ($attachment_ids as $key => $attachtoremove) {
145
+
146
+ // Check the Attachment exists...
147
+ if (get_post_status($attachtoremove) == false)
148
+ continue;
149
+
150
+ // Check the Attachment is associated with an Order
151
+ $post_parent = get_post_field('post_parent', $attachtoremove);
152
+
153
+ if (empty($post_parent)) {
154
+ continue;
155
+ } else {
156
+ if (get_post_type($post_parent) <> 'shop_order')
157
+ continue;
158
+ }
159
+ wp_delete_attachment($attachtoremove);
160
+ }
161
+ }
162
+
163
+ wp_send_json_success(esc_html__('Deleted successfully.', 'woocommerce-checkout-manager'));
164
+ }
165
+ }
166
+
167
+ function order_uploads_metabox_content($post) {
168
+
169
+ if ($order = wc_get_order($post->ID)) {
170
+
171
+ $attachments = get_posts(array(
172
+ 'fields' => 'ids',
173
+ 'post_type' => 'attachment',
174
+ 'numberposts' => -1,
175
+ 'post_status' => null,
176
+ 'post_parent' => $order->get_id()
177
+ ));
178
+ ?>
179
+
180
+ <?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
181
+
182
+ <?php include WOOCCM_PLUGIN_DIR . 'new/admin/meta-boxes/html-order-uploads.php'; ?>
183
+
184
+ <?php
185
+
186
+ }
187
+ }
188
+
189
+ function order_uploads($order_id) {
190
+ if ($order = wc_get_order($order_id)) {
191
+
192
+ $options = get_option('wccs_settings');
193
+
194
+ if (empty($options['checkness']['upload_os']) || ( $order->get_status() == "wc-{$options['checkness']['upload_os']}" )) {
195
+
196
+
197
+ $attachments = get_posts(array(
198
+ 'fields' => 'ids',
199
+ 'post_type' => 'attachment',
200
+ 'numberposts' => -1,
201
+ 'post_status' => null,
202
+ 'post_parent' => $order->get_id())
203
+ );
204
+
205
+ wc_get_template('templates/order/order-uploads.php', array('order' => $order, 'attachments' => $attachments), '', WOOCCM_PLUGIN_DIR);
206
+ }
207
+ }
208
+ }
209
+
210
+ function order_uploads_metabox() {
211
+ add_meta_box('woocommerce-order-files', esc_html__('Order Uploaded Files', 'woocommerce-checkout-manager'), array($this, 'order_uploads_metabox_content'), 'shop_order', 'normal', 'default');
212
+ }
213
+
214
+ function init() {
215
+
216
+ add_action('wp_ajax_wooccm_order_attachment_upload', array($this, 'ajax_order_attachment_upload'));
217
+ add_action('wp_ajax_nopriv_wooccm_order_attachment_upload', array($this, 'ajax_order_attachment_upload'));
218
+ add_action('wp_ajax_wooccm_order_attachment_update', array($this, 'ajax_order_attachment_update'));
219
+ add_action('wp_ajax_nopriv_wooccm_order_attachment_update', array($this, 'ajax_order_attachment_update'));
220
+
221
+ if ($options = get_option('wccs_settings')) {
222
+ if (!empty($options['checkness']['enable_file_upload'])) {
223
+ add_action('woocommerce_view_order', array($this, 'order_uploads'));
224
+ }
225
+ }
226
+
227
+ add_action('add_meta_boxes', array($this, 'order_uploads_metabox'));
228
+ }
229
+
230
+ public static function instance() {
231
+ if (!isset(self::$instance)) {
232
+ self::$instance = new self();
233
+ self::$instance->init();
234
+ }
235
+ return self::$instance;
236
+ }
237
+
238
+ }
239
+
240
+ WOOCCM_Orders::instance();
241
+ }
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.2
7
- Stable tag: 4.3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -137,6 +137,14 @@ Example:
137
 
138
  == Changelog ==
139
 
 
 
 
 
 
 
 
 
140
  = 4.3.2 =
141
  * New: Settings and support action links
142
 
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.2
7
+ Stable tag: 4.3.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
137
 
138
  == Changelog ==
139
 
140
+ = 4.3.3 =
141
+ * Improvement: woocommerce order upload rebuilt
142
+ * Improvement: woocommerce checkout upload rebuilt
143
+ * Improvement: woocommerce order admin upload rebuilt
144
+ * Improvement: woocommerce register fields rebuilt
145
+ * Improvement: woocommerce register fields rebuilt
146
+ * Fix: woocommerce checkout additional fields required
147
+
148
  = 4.3.2 =
149
  * New: Settings and support action links
150
 
templates/order/order-uploads.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="wooccm_order_attachment_inner">
2
+ <table class="woocommerce_order_items shop_table">
3
+ <thead>
4
+ <tr>
5
+ <!--<th><?php _e('ID', 'woocommerce-checkout-manager'); ?></th>-->
6
+ <th><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
7
+ <th><?php _e('Filename', 'woocommerce-checkout-manager'); ?></th>
8
+ <th><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
9
+ <th><?php _e('Extension', ' woocommerce-checkout-manager'); ?></th>
10
+ <th class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody class="product_images">
14
+ <?php
15
+ if (!empty($attachments)) :
16
+ foreach ($attachments as $attachment_id) :
17
+ $image_attributes = wp_get_attachment_url($attachment_id);
18
+ $image_attributes2 = wp_get_attachment_image_src($attachment_id);
19
+ $filename = basename($image_attributes);
20
+ $wp_filetype = wp_check_filetype($filename);
21
+ ?>
22
+ <tr class="image wccm_filesli wccmv_<?php echo esc_attr($attachment_id); ?>">
23
+ <!--<td><?php echo esc_attr($attachment_id); ?></td>-->
24
+ <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), false)); ?></td>
25
+ <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)); ?></td>
26
+ <td>
27
+ <?php
28
+ if ($image_attributes2[1] == '') {
29
+ echo '-';
30
+ } else {
31
+ echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
32
+ }
33
+ ?>
34
+ </td>
35
+ <td><?php echo strtoupper($wp_filetype['ext']); ?></td>
36
+ <td class="column-actions">
37
+ <!--<a href="<?php echo esc_url($image_attributes2[0]); ?>" target="_blank" class="button"><?php esc_html_e('Download', 'woocommerce-checkout-manager'); ?></a>-->
38
+ <a class="button wooccm_delete_attachment" data-attachment_id="<?php echo esc_attr($attachment_id); ?>" data-tip="<?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?></a>
39
+ </td>
40
+ </tr>
41
+ <?php endforeach; ?>
42
+ <?php else: ?>
43
+ <tr>
44
+ <td colspan="6" style="text-align:left;"><?php esc_html_e('No files have been uploaded to this Order.', 'woocommerce-checkout-manager'); ?></td>
45
+ </tr>
46
+ <?php endif; ?>
47
+ </tbody>
48
+ </table>
49
+ <input type="hidden" id="delete_attachments_ids" name="delete_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
50
+ <input type="hidden" id="all_attachments_ids" name="all_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
51
+ <!--<input type="file" id="wooccm_order_attachment_upload" name="wooccm_order_attachment_upload" class="button button-primary" value="<?php _e('Add Order Files', 'woocommerce-checkout-manager'); ?>" multiple />-->
52
+ <p class="order-upload">
53
+ <a style="float: left; margin: 0 10px 0 0;" class="button alt fileinput-button">
54
+ <span><?php _e('Add Order Files', 'woocommerce-checkout-manager'); ?></span>
55
+ <input data-order_id="<?php echo esc_attr($order->get_id()); ?>" type="file" name="wooccm_order_attachment_upload" id="wooccm_order_attachment_upload" multiple />
56
+ </a>
57
+ <input type="button" id="wooccm_order_attachment_update" class="button button-secondary" value="<?php _e('Save Changes', 'woocommerce-checkout-manager'); ?>" disabled="disabled">
58
+ <span class="wccm_results"></span>
59
+ </p>
60
+ </div>
woocommerce-checkout-manager.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: WooCommerce Checkout Manager
4
  * Description: Manages WooCommerce Checkout, the advanced way.
5
- * Version: 4.3.2
6
  * Author: QuadLayers
7
  * Author URI: https://www.quadlayers.com
8
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
@@ -16,7 +16,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
16
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
17
  }
18
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
19
- define('WOOCCM_PLUGIN_VERSION', '4.3.2');
20
  }
21
  if (!defined('WOOCCM_PLUGIN_FILE')) {
22
  define('WOOCCM_PLUGIN_FILE', __FILE__);
@@ -33,6 +33,9 @@ if (!defined('WOOCCM_WORDPRESS_URL')) {
33
  if (!defined('WOOCCM_REVIEW_URL')) {
34
  define('WOOCCM_REVIEW_URL', 'https://wordpress.org/support/plugin/woocommerce-checkout-manager/reviews/?filter=5#new-post');
35
  }
 
 
 
36
  if (!defined('WOOCCM_DEMO_URL')) {
37
  define('WOOCCM_DEMO_URL', 'https://quadlayers.com/portfolio/woocommerce-checkout-manager/?utm_source=wooccm_admin');
38
  }
@@ -69,7 +72,6 @@ if (!class_exists('WOOCCM')) {
69
  }
70
 
71
  function add_notices() {
72
-
73
  if (!get_transient('wooccm-first-rating') && !get_user_meta(get_current_user_id(), 'wooccm-user-rating', true)) {
74
  ?>
75
  <div id="wooccm-admin-rating" class="wooccm-notice notice is-dismissible" data-notice_id="wooccm-user-rating">
@@ -95,28 +97,55 @@ if (!class_exists('WOOCCM')) {
95
  </div>
96
  </div>
97
  </div>
98
- <script>
99
- (function ($) {
100
- $('.wooccm-notice').on('click', '.notice-dismiss', function (e) {
101
- e.preventDefault();
102
- var notice_id = $(e.delegateTarget).data('notice_id');
103
- $.ajax({
104
- type: 'POST',
105
- url: ajaxurl,
106
- data: {
107
- notice_id: notice_id,
108
- action: 'wooccm_dismiss_notice',
109
- nonce: '<?php echo wp_create_nonce('wooccm_dismiss_notice'); ?>'
110
- },
111
- success: function (response) {
112
- console.log(response);
113
- },
114
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  });
116
- })(jQuery);
117
- </script>
118
- <?php
119
- }
120
  }
121
 
122
  function add_action_links($links) {
@@ -127,16 +156,70 @@ if (!class_exists('WOOCCM')) {
127
  return $links;
128
  }
129
 
130
- function add_scripts() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
  $i18n = substr(get_user_locale(), 0, 2);
133
 
 
 
134
  if (is_account_page()) {
 
135
  wp_enqueue_style('dashicons');
136
- wp_enqueue_style('wooccm-button-style', plugins_url('includes/templates/admin/edit-order-uploads-button_style.css', WOOCCM_PLUGIN_FILE), false, '1.0', 'all');
137
  }
138
 
139
  if (is_checkout()) {
 
 
 
140
  // UI
141
  // ---------------------------------------------------------------------
142
  wp_enqueue_style('jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), WC_VERSION);
@@ -190,36 +273,50 @@ if (!class_exists('WOOCCM')) {
190
  }
191
 
192
  function includes() {
 
 
193
  include( WOOCCM_PLUGIN_DIR . 'includes/install.php' );
194
  include( WOOCCM_PLUGIN_DIR . 'includes/functions.php' );
195
  include( WOOCCM_PLUGIN_DIR . 'includes/checkout.php' );
196
- include( WOOCCM_PLUGIN_DIR . 'includes/checkout-billing.php' );
197
- include( WOOCCM_PLUGIN_DIR . 'includes/checkout-shipping.php' );
198
- include( WOOCCM_PLUGIN_DIR . 'includes/checkout-additional.php' );
 
199
  include( WOOCCM_PLUGIN_DIR . 'includes/email.php' );
200
  include( WOOCCM_PLUGIN_DIR . 'includes/formatting.php' );
201
  include( WOOCCM_PLUGIN_DIR . 'includes/admin.php' );
202
  include( WOOCCM_PLUGIN_DIR . 'includes/template.php' );
203
  include( WOOCCM_PLUGIN_DIR . 'includes/export.php' );
204
  include( WOOCCM_PLUGIN_DIR . 'includes/classes/main.php' );
205
- include( WOOCCM_PLUGIN_DIR . 'includes/classes/field_filters.php' );
206
-
207
  // @mod - We need to load the templates conditionally
208
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/add_functions.php' );
209
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/billing_functions.php' );
210
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/shipping_functions.php' );
211
- include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/add_wooccmupload.php' );
212
- include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/billing_wooccmupload.php' );
213
- include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/shipping_wooccmupload.php' );
 
214
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/add_required.php' );
215
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/billing_required.php' );
216
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/shipping_required.php' );
217
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/wooccm_editing_wrapper.php' );
 
 
 
 
 
 
 
 
 
218
  }
219
 
220
  function init() {
221
  add_action('wp_ajax_wooccm_dismiss_notice', array($this, 'ajax_dismiss_notice'));
222
- add_action('wp_enqueue_scripts', array($this, 'add_scripts'));
 
223
  add_action('admin_notices', array($this, 'add_notices'));
224
  add_filter('plugin_action_links_' . plugin_basename(WOOCCM_PLUGIN_FILE), array($this, 'add_action_links'));
225
  }
@@ -266,9 +363,9 @@ add_action('wp_head', 'wooccm_shipping_hide_required');
266
  // @mod - wooccm_run_color_inner does not exist
267
  // add_action( 'wooccm_run_color_innerpicker', 'wooccm_run_color_inner' ); run color inside options page (proto)
268
  add_action('woocommerce_before_checkout_form', 'wooccm_override_this');
269
- add_filter('woocommerce_billing_fields', 'wooccm_checkout_billing_fields');
270
  add_filter('woocommerce_default_address_fields', 'wooccm_checkout_default_address_fields');
271
- add_filter('woocommerce_shipping_fields', 'wooccm_checkout_shipping_fields');
272
  add_filter('wcdn_order_info_fields', 'wooccm_woocommerce_delivery_notes_compat', 10, 2);
273
  add_filter('wc_customer_order_csv_export_order_row', 'wooccm_csv_export_modify_row_data', 10, 3);
274
  add_filter('wc_customer_order_csv_export_order_headers', 'wooccm_csv_export_modify_column_headers');
@@ -283,41 +380,45 @@ add_action('woocommerce_checkout_process', 'wooccm_custom_checkout_process');
283
  add_action('woocommerce_checkout_process', 'wooccm_billing_custom_checkout_process');
284
  add_action('woocommerce_checkout_process', 'wooccm_shipping_custom_checkout_process');
285
 
286
- add_action('woocommerce_before_checkout_form', 'wooccm_upload_billing_scripts');
287
- add_action('woocommerce_before_checkout_form', 'wooccm_upload_shipping_scripts');
 
 
288
  add_action('woocommerce_before_checkout_form', 'wooccm_billing_scripts');
289
  add_action('woocommerce_before_checkout_form', 'wooccm_shipping_scripts');
290
  add_action('woocommerce_before_checkout_form', 'wooccm_billing_override_this');
291
  add_action('woocommerce_before_checkout_form', 'wooccm_shipping_override_this');
292
  add_action('woocommerce_before_checkout_form', 'wooccm_scripts');
293
- add_action('woocommerce_before_checkout_form', 'wooccm_upload_scripts');
294
 
295
  add_action('woocommerce_checkout_fields', 'wooccm_order_notes');
296
  add_filter('parse_query', 'wooccm_query_list');
297
  add_action('restrict_manage_posts', 'woooccm_restrict_manage_posts');
298
 
299
- switch (wooccm_checkout_additional_positioning()) {
 
 
300
 
301
  case 'before_shipping_form':
302
- add_action('woocommerce_before_checkout_shipping_form', 'wooccm_checkout_additional_fields');
303
- break;
304
 
305
  case 'after_shipping_form':
306
- add_action('woocommerce_after_checkout_shipping_form', 'wooccm_checkout_additional_fields');
307
- break;
308
 
309
  case 'before_billing_form':
310
- add_action('woocommerce_before_checkout_billing_form', 'wooccm_checkout_additional_fields');
311
- break;
312
 
313
  case 'after_billing_form':
314
- add_action('woocommerce_after_checkout_billing_form', 'wooccm_checkout_additional_fields');
315
- break;
316
 
317
  case 'after_order_notes':
318
- add_action('woocommerce_after_order_notes', 'wooccm_checkout_additional_fields');
319
- break;
320
- }
321
 
322
  if (wooccm_validator_changename()) {
323
 
2
  /**
3
  * Plugin Name: WooCommerce Checkout Manager
4
  * Description: Manages WooCommerce Checkout, the advanced way.
5
+ * Version: 4.3.3
6
  * Author: QuadLayers
7
  * Author URI: https://www.quadlayers.com
8
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
16
  define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
17
  }
18
  if (!defined('WOOCCM_PLUGIN_VERSION')) {
19
+ define('WOOCCM_PLUGIN_VERSION', '4.3.3');
20
  }
21
  if (!defined('WOOCCM_PLUGIN_FILE')) {
22
  define('WOOCCM_PLUGIN_FILE', __FILE__);
33
  if (!defined('WOOCCM_REVIEW_URL')) {
34
  define('WOOCCM_REVIEW_URL', 'https://wordpress.org/support/plugin/woocommerce-checkout-manager/reviews/?filter=5#new-post');
35
  }
36
+ if (!defined('WOOCCM_DOCUMENTATION_URL')) {
37
+ define('WOOCCM_DOCUMENTATION_URL', 'https://quadlayers.com/documentation/woocommerce-checkout-manager/?utm_source=wooccm_admin');
38
+ }
39
  if (!defined('WOOCCM_DEMO_URL')) {
40
  define('WOOCCM_DEMO_URL', 'https://quadlayers.com/portfolio/woocommerce-checkout-manager/?utm_source=wooccm_admin');
41
  }
72
  }
73
 
74
  function add_notices() {
 
75
  if (!get_transient('wooccm-first-rating') && !get_user_meta(get_current_user_id(), 'wooccm-user-rating', true)) {
76
  ?>
77
  <div id="wooccm-admin-rating" class="wooccm-notice notice is-dismissible" data-notice_id="wooccm-user-rating">
97
  </div>
98
  </div>
99
  </div>
100
+ <?php }
101
+ ?>
102
+ <?php /* if (!get_user_meta(get_current_user_id(), 'wooccm-user-beta', true)) {
103
+ ?>
104
+ <div id="wooccm-admin-rating" class="wooccm-notice notice is-dismissible" data-notice_id="wooccm-user-beta">
105
+ <div class="notice-container" style="padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
106
+ <div class="notice-image">
107
+ <img style="border-radius:50%;max-width: 90px;" src="<?php echo plugins_url('/assets/img/logo.jpg', WOOCCM_PLUGIN_FILE); ?>" alt="<?php echo esc_html(WOOCCM_PLUGIN_NAME); ?>>">
108
+ </div>
109
+ <div class="notice-content" style="margin-left: 15px;">
110
+ <p>
111
+ <?php printf(esc_html__('Hello! We\'ve launched a new beta version!', 'woocommerce-checkout-manager'), WOOCCM_PLUGIN_NAME); ?>
112
+ <br/>
113
+ <?php esc_html_e(' We urgently need developers, integrators and interested store owners to test this plugin release and provide feedback to help stabilise the 4.4+ version. We\'ve rebuilt the entire file picker field and the upload fields option inside user orders and admin backend. Can you help?', 'woocommerce-checkout-manager'); ?>
114
+ </p>
115
+ <a href="https://drive.google.com/uc?id=1THj7zm-2NOTURandd1IuiibZvP4XL-vw&export=download" class="button-primary" target="_blank">
116
+ <?php esc_html_e('Download Now!', 'woocommerce-checkout-manager'); ?>
117
+ </a>
118
+ <a href="<?php echo esc_url(WOOCCM_SUPPORT_URL); ?>" class="button-secondary" target="_blank">
119
+ <?php esc_html_e('Report a bug', 'woocommerce-checkout-manager'); ?>
120
+ </a>
121
+ <a style="margin-left: 10px;" href="https://quadlayers.com/documentation/woocommerce-checkout-manager/changelog/" target="_blank">
122
+ <?php esc_html_e('Changelog', 'woocommerce-checkout-manager'); ?>
123
+ </a>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ <?php } */ ?>
128
+ <script>
129
+ (function ($) {
130
+ $('.wooccm-notice').on('click', '.notice-dismiss', function (e) {
131
+ e.preventDefault();
132
+ var notice_id = $(e.delegateTarget).data('notice_id');
133
+ $.ajax({
134
+ type: 'POST',
135
+ url: ajaxurl,
136
+ data: {
137
+ notice_id: notice_id,
138
+ action: 'wooccm_dismiss_notice',
139
+ nonce: '<?php echo wp_create_nonce('wooccm_dismiss_notice'); ?>'
140
+ },
141
+ success: function (response) {
142
+ console.log(response);
143
+ },
144
  });
145
+ });
146
+ })(jQuery);
147
+ </script>
148
+ <?php
149
  }
150
 
151
  function add_action_links($links) {
156
  return $links;
157
  }
158
 
159
+ function register_scripts() {
160
+
161
+ wp_register_script('wooccm-admin', plugins_url('assets/js/wooccm-admin.js', WOOCCM_PLUGIN_FILE), array('jquery'), WOOCCM_PLUGIN_VERSION, true);
162
+
163
+ wp_localize_script('wooccm-admin', 'wooccm', array(
164
+ 'ajaxurl' => admin_url('admin-ajax.php'),
165
+ 'nonce' => wp_create_nonce('wooccm_admin'),
166
+ 'uploading' => esc_html__('Uploading, please wait...', 'woocommerce-checkout-manager'),
167
+ 'saving' => esc_html__('Saving, please wait...', 'woocommerce-checkout-manager'),
168
+ 'success' => esc_html__('Files uploaded successfully.', 'woocommerce-checkout-manager'),
169
+ 'deleted' => esc_html__('Deleted successfully.', 'woocommerce-checkout-manager'),
170
+ 'icons' => array(
171
+ 'interactive' => site_url('wp-includes/images/media/interactive.png'),
172
+ 'spreadsheet' => site_url('wp-includes/images/media/spreadsheet.png'),
173
+ 'archive' => site_url('wp-includes/images/media/archive.png'),
174
+ 'audio' => site_url('wp-includes/images/media/audio.png'),
175
+ 'text' => site_url('wp-includes/images/media/text.png'),
176
+ 'video' => site_url('wp-includes/images/media/video.png')
177
+ )
178
+ ));
179
+
180
+ wp_register_script('wooccm-order-upload', plugins_url('assets/js/wooccm-order-upload.js', WOOCCM_PLUGIN_FILE), array('wooccm-admin'), WOOCCM_PLUGIN_VERSION, true);
181
+
182
+ wp_register_script('wooccm-checkout-upload', plugins_url('assets/js/wooccm-checkout-upload.js', WOOCCM_PLUGIN_FILE), array('jquery'), WOOCCM_PLUGIN_VERSION, true);
183
+
184
+ wp_localize_script('wooccm-checkout-upload', 'wooccm', array(
185
+ 'ajaxurl' => admin_url('admin-ajax.php'),
186
+ 'nonce' => wp_create_nonce('wooccm_checkout_attachment_upload'),
187
+ 'uploading' => esc_html__('Uploading, please wait...', 'woocommerce-checkout-manager'),
188
+ 'saving' => esc_html__('Saving, please wait...', 'woocommerce-checkout-manager'),
189
+ 'success' => esc_html__('Files uploaded successfully.', 'woocommerce-checkout-manager'),
190
+ 'deleted' => esc_html__('Deleted successfully.', 'woocommerce-checkout-manager')
191
+ ));
192
+ }
193
+
194
+ function add_admin_scripts() {
195
+
196
+ $this->register_scripts();
197
+
198
+ // 1326
199
+ // only for orders
200
+ wp_enqueue_script('wooccm-admin');
201
+ // only for backend maybe orders
202
+ wp_enqueue_script('wooccm-order-upload');
203
+ }
204
+
205
+ function add_frontend_scripts() {
206
+
207
+ $this->register_scripts();
208
 
209
  $i18n = substr(get_user_locale(), 0, 2);
210
 
211
+ wp_enqueue_style('wooccm', plugins_url('assets/css/wooccm.css', WOOCCM_PLUGIN_FILE), false, WOOCCM_PLUGIN_VERSION, 'all');
212
+
213
  if (is_account_page()) {
214
+ wp_enqueue_script('wooccm-order-upload');
215
  wp_enqueue_style('dashicons');
216
+ wp_enqueue_style('wooccm-button-style', plugins_url('includes/templates/admin/edit-order-uploads-button_style.css', WOOCCM_PLUGIN_FILE), false, WOOCCM_PLUGIN_VERSION, 'all');
217
  }
218
 
219
  if (is_checkout()) {
220
+
221
+ wp_enqueue_script('wooccm-checkout-upload');
222
+
223
  // UI
224
  // ---------------------------------------------------------------------
225
  wp_enqueue_style('jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), WC_VERSION);
273
  }
274
 
275
  function includes() {
276
+ // Old
277
+ // -----------------------------------------------------------------------
278
  include( WOOCCM_PLUGIN_DIR . 'includes/install.php' );
279
  include( WOOCCM_PLUGIN_DIR . 'includes/functions.php' );
280
  include( WOOCCM_PLUGIN_DIR . 'includes/checkout.php' );
281
+ //1326
282
+ //include( WOOCCM_PLUGIN_DIR . 'includes/checkout-billing.php' );
283
+ //include( WOOCCM_PLUGIN_DIR . 'includes/checkout-shipping.php' );
284
+ //include( WOOCCM_PLUGIN_DIR . 'includes/checkout-additional.php' );
285
  include( WOOCCM_PLUGIN_DIR . 'includes/email.php' );
286
  include( WOOCCM_PLUGIN_DIR . 'includes/formatting.php' );
287
  include( WOOCCM_PLUGIN_DIR . 'includes/admin.php' );
288
  include( WOOCCM_PLUGIN_DIR . 'includes/template.php' );
289
  include( WOOCCM_PLUGIN_DIR . 'includes/export.php' );
290
  include( WOOCCM_PLUGIN_DIR . 'includes/classes/main.php' );
291
+ //1326
292
+ //include( WOOCCM_PLUGIN_DIR . 'includes/classes/field_filters.php' );
293
  // @mod - We need to load the templates conditionally
294
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/add_functions.php' );
295
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/billing_functions.php' );
296
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/shipping_functions.php' );
297
+ //1326
298
+ //include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/add_wooccmupload.php' );
299
+ //include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/billing_wooccmupload.php' );
300
+ //include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/shipping_wooccmupload.php' );
301
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/add_required.php' );
302
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/billing_required.php' );
303
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/required/shipping_required.php' );
304
  include( WOOCCM_PLUGIN_DIR . 'includes/templates/functions/wooccm_editing_wrapper.php' );
305
+
306
+ // New
307
+ // -----------------------------------------------------------------------
308
+ //include( WOOCCM_PLUGIN_DIR . 'new/admin.php' );
309
+ include( WOOCCM_PLUGIN_DIR . 'new/checkout.php' );
310
+ include( WOOCCM_PLUGIN_DIR . 'new/orders.php' );
311
+ include( WOOCCM_PLUGIN_DIR . 'new/fields_register.php' );
312
+ include( WOOCCM_PLUGIN_DIR . 'new/fields_required.php' );
313
+ include( WOOCCM_PLUGIN_DIR . 'new/fields_filters.php' );
314
  }
315
 
316
  function init() {
317
  add_action('wp_ajax_wooccm_dismiss_notice', array($this, 'ajax_dismiss_notice'));
318
+ add_action('wp_enqueue_scripts', array($this, 'add_frontend_scripts'));
319
+ add_action('admin_enqueue_scripts', array($this, 'add_admin_scripts'));
320
  add_action('admin_notices', array($this, 'add_notices'));
321
  add_filter('plugin_action_links_' . plugin_basename(WOOCCM_PLUGIN_FILE), array($this, 'add_action_links'));
322
  }
363
  // @mod - wooccm_run_color_inner does not exist
364
  // add_action( 'wooccm_run_color_innerpicker', 'wooccm_run_color_inner' ); run color inside options page (proto)
365
  add_action('woocommerce_before_checkout_form', 'wooccm_override_this');
366
+ //add_filter('woocommerce_billing_fields', 'wooccm_checkout_billing_fields');
367
  add_filter('woocommerce_default_address_fields', 'wooccm_checkout_default_address_fields');
368
+ //add_filter('woocommerce_shipping_fields', 'wooccm_checkout_shipping_fields');
369
  add_filter('wcdn_order_info_fields', 'wooccm_woocommerce_delivery_notes_compat', 10, 2);
370
  add_filter('wc_customer_order_csv_export_order_row', 'wooccm_csv_export_modify_row_data', 10, 3);
371
  add_filter('wc_customer_order_csv_export_order_headers', 'wooccm_csv_export_modify_column_headers');
380
  add_action('woocommerce_checkout_process', 'wooccm_billing_custom_checkout_process');
381
  add_action('woocommerce_checkout_process', 'wooccm_shipping_custom_checkout_process');
382
 
383
+ //1326
384
+ //add_action('woocommerce_before_checkout_form', 'wooccm_upload_billing_scripts');
385
+ //add_action('woocommerce_before_checkout_form', 'wooccm_upload_shipping_scripts');
386
+ //add_action('woocommerce_before_checkout_form', 'wooccm_upload_scripts');
387
  add_action('woocommerce_before_checkout_form', 'wooccm_billing_scripts');
388
  add_action('woocommerce_before_checkout_form', 'wooccm_shipping_scripts');
389
  add_action('woocommerce_before_checkout_form', 'wooccm_billing_override_this');
390
  add_action('woocommerce_before_checkout_form', 'wooccm_shipping_override_this');
391
  add_action('woocommerce_before_checkout_form', 'wooccm_scripts');
392
+ //add_action('woocommerce_before_checkout_form', 'wooccm_upload_scripts');
393
 
394
  add_action('woocommerce_checkout_fields', 'wooccm_order_notes');
395
  add_filter('parse_query', 'wooccm_query_list');
396
  add_action('restrict_manage_posts', 'woooccm_restrict_manage_posts');
397
 
398
+ /*
399
+ * 1326
400
+ * switch (wooccm_checkout_additional_positioning()) {
401
 
402
  case 'before_shipping_form':
403
+ add_action('woocommerce_before_checkout_shipping_form', 'wooccm_checkout_additional_fields');
404
+ break;
405
 
406
  case 'after_shipping_form':
407
+ add_action('woocommerce_after_checkout_shipping_form', 'wooccm_checkout_additional_fields');
408
+ break;
409
 
410
  case 'before_billing_form':
411
+ add_action('woocommerce_before_checkout_billing_form', 'wooccm_checkout_additional_fields');
412
+ break;
413
 
414
  case 'after_billing_form':
415
+ add_action('woocommerce_after_checkout_billing_form', 'wooccm_checkout_additional_fields');
416
+ break;
417
 
418
  case 'after_order_notes':
419
+ add_action('woocommerce_after_order_notes', 'wooccm_checkout_additional_fields');
420
+ break;
421
+ } */
422
 
423
  if (wooccm_validator_changename()) {
424