Version Description
- Fix: small CSS changes
- Fix: security issue related with upload files types
- Improvement: woocommerce checkout upload rebuilt
Download this release
Release Info
Developer | quadlayers |
Plugin | WooCommerce Checkout Manager |
Version | 4.4.4 |
Comparing to | |
See all releases |
Code changes from version 4.4.3 to 4.4.4
- assets/css/wooccm.css +32 -3
- assets/js/wooccm-checkout-upload.funciona.js +0 -221
- assets/js/wooccm-checkout-upload.min.js +0 -1
- assets/js/{wooccm-checkout-upload.js → wooccm-checkout.js} +94 -45
- assets/js/wooccm-checkout.min.js +1 -0
- assets/less/wooccm.less +38 -4
- changelog.txt +25 -0
- includes/admin.php +1 -701
- includes/classes/main.php +885 -914
- includes/template.php +0 -290
- new/admin.php +3 -1
- new/admin/pages/billing.php +49 -14
- new/checkout.php +48 -38
- new/fields_additional.php +111 -0
- new/fields_display.php +190 -0
- new/fields_handler.php +0 -161
- new/fields_register.php +0 -54
- new/fields_required.php +0 -66
- new/install.php +1 -1
- new/orders.php +7 -38
- readme.txt +6 -1
- woocommerce-checkout-manager.php +47 -6
assets/css/wooccm.css
CHANGED
@@ -39,10 +39,10 @@
|
|
39 |
box-sizing: border-box;
|
40 |
padding: 10px 5px 0 5px;
|
41 |
width: 25%;
|
42 |
-
max-height: 90px;
|
43 |
position: relative;
|
44 |
}
|
45 |
.wooccmupload_list .wooccmupload_file .wooccmupload_file_delete {
|
|
|
46 |
position: absolute;
|
47 |
top: 2px;
|
48 |
right: -3px;
|
@@ -50,16 +50,45 @@
|
|
50 |
height: 16px;
|
51 |
background-color: #222;
|
52 |
display: block;
|
53 |
-
line-height:
|
54 |
text-align: center;
|
55 |
color: #fefefe;
|
56 |
font-weight: 900;
|
57 |
border-radius: 50%;
|
58 |
-
font-size:
|
59 |
cursor: pointer;
|
|
|
60 |
}
|
61 |
.wooccmupload_list .wooccmupload_file .wooccmupload_file_container {
|
62 |
width: 100%;
|
63 |
overflow: hidden;
|
64 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/*# sourceMappingURL=wooccm.css.map */
|
39 |
box-sizing: border-box;
|
40 |
padding: 10px 5px 0 5px;
|
41 |
width: 25%;
|
|
|
42 |
position: relative;
|
43 |
}
|
44 |
.wooccmupload_list .wooccmupload_file .wooccmupload_file_delete {
|
45 |
+
z-index: 1;
|
46 |
position: absolute;
|
47 |
top: 2px;
|
48 |
right: -3px;
|
50 |
height: 16px;
|
51 |
background-color: #222;
|
52 |
display: block;
|
53 |
+
line-height: 16px;
|
54 |
text-align: center;
|
55 |
color: #fefefe;
|
56 |
font-weight: 900;
|
57 |
border-radius: 50%;
|
58 |
+
font-size: 12px;
|
59 |
cursor: pointer;
|
60 |
+
font-family: code;
|
61 |
}
|
62 |
.wooccmupload_list .wooccmupload_file .wooccmupload_file_container {
|
63 |
width: 100%;
|
64 |
overflow: hidden;
|
65 |
}
|
66 |
+
.wooccmupload_list .wooccmupload_file .wooccmupload_file_image_container {
|
67 |
+
display: flex;
|
68 |
+
justify-content: center;
|
69 |
+
align-items: center;
|
70 |
+
overflow: hidden;
|
71 |
+
width: 100%;
|
72 |
+
padding-top: 100%;
|
73 |
+
position: relative;
|
74 |
+
background: #eee;
|
75 |
+
}
|
76 |
+
.wooccmupload_list .wooccmupload_file .wooccmupload_file_image_container > img {
|
77 |
+
overflow: hidden;
|
78 |
+
object-fit: cover;
|
79 |
+
position: absolute;
|
80 |
+
top: 30%;
|
81 |
+
bottom: auto;
|
82 |
+
height: 40%;
|
83 |
+
opacity: 0.8;
|
84 |
+
}
|
85 |
+
.wooccmupload_list .wooccmupload_file .wooccmupload_file_image_container > img.image {
|
86 |
+
top: 0;
|
87 |
+
bottom: 0;
|
88 |
+
left: 0;
|
89 |
+
right: 0;
|
90 |
+
max-height: 100%;
|
91 |
+
height: 100%;
|
92 |
+
width: 100%;
|
93 |
+
}
|
94 |
/*# sourceMappingURL=wooccm.css.map */
|
assets/js/wooccm-checkout-upload.funciona.js
DELETED
@@ -1,221 +0,0 @@
|
|
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.min.js
DELETED
@@ -1 +0,0 @@
|
|
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-checkout-upload.js → wooccm-checkout.js}
RENAMED
@@ -20,35 +20,43 @@
|
|
20 |
|
21 |
var append_image = function (list, i, source, name, filetype) {
|
22 |
|
23 |
-
var $
|
|
|
24 |
|
25 |
-
if (
|
26 |
-
|
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 |
-
$
|
52 |
|
53 |
}
|
54 |
|
@@ -56,41 +64,56 @@
|
|
56 |
// Field
|
57 |
// ---------------------------------------------------------------------------
|
58 |
|
|
|
|
|
59 |
$('.wooccmupload-field').each(function (i, field) {
|
60 |
|
61 |
var $field = $(field),
|
62 |
-
$
|
63 |
-
$
|
64 |
-
$
|
|
|
|
|
65 |
|
66 |
// Simulate click
|
67 |
// -------------------------------------------------------------------------
|
68 |
|
69 |
-
$
|
70 |
e.preventDefault();
|
71 |
-
$
|
72 |
});
|
73 |
|
74 |
// Delete images
|
75 |
// ---------------------------------------------------------------------------
|
76 |
|
77 |
-
$
|
78 |
-
|
79 |
});
|
80 |
|
81 |
// Append images
|
82 |
// -------------------------------------------------------------------------
|
83 |
|
84 |
-
$
|
85 |
|
86 |
-
var
|
87 |
-
$files = $field.find('[type=file]'),
|
88 |
-
files = $files[0].files;
|
89 |
|
90 |
if (files.length) {
|
91 |
-
$.each(files, function (i, file) {
|
92 |
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
reader = new FileReader();
|
96 |
|
@@ -98,18 +121,19 @@
|
|
98 |
return function (e) {
|
99 |
|
100 |
setTimeout(function () {
|
101 |
-
append_image($
|
102 |
}, 200);
|
103 |
|
|
|
104 |
};
|
105 |
})(file);
|
106 |
|
|
|
107 |
reader.readAsDataURL(file);
|
108 |
-
}
|
109 |
|
110 |
-
|
|
|
111 |
}
|
112 |
-
|
113 |
});
|
114 |
});
|
115 |
|
@@ -145,12 +169,10 @@
|
|
145 |
$fields.each(function (i, field) {
|
146 |
|
147 |
var $field = $(field),
|
148 |
-
$
|
149 |
-
$
|
150 |
-
$list = $field.find('.wooccmupload_list'),
|
151 |
-
files = $files[0].files;
|
152 |
|
153 |
-
if (window.FormData &&
|
154 |
|
155 |
if (!is_blocked($form)) {
|
156 |
$place_order.html(wooccm.uploading);
|
@@ -159,16 +181,33 @@
|
|
159 |
|
160 |
var data = new FormData();
|
161 |
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
-
if ($
|
165 |
-
console.log('
|
166 |
-
|
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 |
|
@@ -187,9 +226,11 @@
|
|
187 |
$results.removeClass('woocommerce-message');
|
188 |
if (response.success) {
|
189 |
//console.log(response.data);
|
190 |
-
$
|
191 |
} else {
|
192 |
-
$
|
|
|
|
|
193 |
}
|
194 |
},
|
195 |
complete: function (response) {
|
@@ -217,4 +258,12 @@
|
|
217 |
//}
|
218 |
});
|
219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
})(jQuery);
|
20 |
|
21 |
var append_image = function (list, i, source, name, filetype) {
|
22 |
|
23 |
+
var $field_list = $(list),
|
24 |
+
source_class;
|
25 |
|
26 |
+
if (filetype.match('image.*')) {
|
27 |
+
source_class = 'image';
|
28 |
+
} else if (filetype.match('application/ms.*')) {
|
|
|
29 |
source = wooccm.icons.spreadsheet;
|
30 |
+
source_class = 'spreadsheet';
|
31 |
+
} else if (filetype.match('application/x.*')) {
|
32 |
source = wooccm.icons.archive;
|
33 |
+
source_class = 'application';
|
34 |
+
} else if (filetype.match('audio.*')) {
|
35 |
source = wooccm.icons.audio;
|
36 |
+
source_class = 'audio';
|
37 |
+
} else if (filetype.match('text.*')) {
|
38 |
source = wooccm.icons.text;
|
39 |
+
source_class = 'text';
|
40 |
+
} else if (filetype.match('video.*')) {
|
41 |
source = wooccm.icons.video;
|
42 |
+
source_class = 'video';
|
43 |
+
} else {
|
44 |
+
//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)) {
|
45 |
+
source = wooccm.icons.interactive;
|
46 |
+
source_class = 'interactive';
|
47 |
}
|
48 |
|
49 |
+
|
50 |
var html = '<span data-file_id="' + i + '" title="' + name + '" class="wooccmupload_file">\n\
|
51 |
<span class="wooccmupload_file_container">\n\
|
|
|
52 |
<a title="' + name + '" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n\
|
53 |
+
<span class="wooccmupload_file_image_container">\n\
|
54 |
+
<img class="' + source_class + '" alt="' + name + '" src="' + source + '"/>\n\
|
55 |
+
</span>\n\
|
56 |
</span>\n\
|
57 |
</span>';
|
58 |
|
59 |
+
$field_list.append(html).fadeIn();
|
60 |
|
61 |
}
|
62 |
|
64 |
// Field
|
65 |
// ---------------------------------------------------------------------------
|
66 |
|
67 |
+
var fileList = [];
|
68 |
+
|
69 |
$('.wooccmupload-field').each(function (i, field) {
|
70 |
|
71 |
var $field = $(field),
|
72 |
+
$button_file = $field.find('[type=file]'),
|
73 |
+
$button_click = $field.find('.wooccmupload_button'),
|
74 |
+
$field_list = $field.find('.wooccmupload_list');
|
75 |
+
|
76 |
+
fileList[$field.attr('id')] = [];
|
77 |
|
78 |
// Simulate click
|
79 |
// -------------------------------------------------------------------------
|
80 |
|
81 |
+
$button_click.on('click', function (e) {
|
82 |
e.preventDefault();
|
83 |
+
$button_file.trigger('click');
|
84 |
});
|
85 |
|
86 |
// Delete images
|
87 |
// ---------------------------------------------------------------------------
|
88 |
|
89 |
+
$field_list.on('click', '.wooccmupload_file_delete', function (e) {
|
90 |
+
$(this).closest('.wooccmupload_file').remove();
|
91 |
});
|
92 |
|
93 |
// Append images
|
94 |
// -------------------------------------------------------------------------
|
95 |
|
96 |
+
$button_file.on('change', function (e) {
|
97 |
|
98 |
+
var files = $(this)[0].files;
|
|
|
|
|
99 |
|
100 |
if (files.length) {
|
|
|
101 |
|
102 |
+
if (window.FileReader) {
|
103 |
+
|
104 |
+
$.each(files, function (i, file) {
|
105 |
+
|
106 |
+
var count = $field_list.find('span[data-file_id]').length + i;
|
107 |
+
|
108 |
+
if (count >= wooccm.limit.max_files) {
|
109 |
+
alert('Exeeds max files limit of ' + wooccm.limit.max_files);
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
|
113 |
+
if (file.size > wooccm.limit.max_file_size) {
|
114 |
+
alert('Exeeds max file size of ' + wooccm.limit.max_file_size);
|
115 |
+
return true;
|
116 |
+
}
|
117 |
|
118 |
reader = new FileReader();
|
119 |
|
121 |
return function (e) {
|
122 |
|
123 |
setTimeout(function () {
|
124 |
+
append_image($field_list, fileList[$field.attr('id')].push(file) - 1, e.target.result, theFile.name, theFile.type);
|
125 |
}, 200);
|
126 |
|
127 |
+
|
128 |
};
|
129 |
})(file);
|
130 |
|
131 |
+
console.log(file.name);
|
132 |
reader.readAsDataURL(file);
|
|
|
133 |
|
134 |
+
});
|
135 |
+
}
|
136 |
}
|
|
|
137 |
});
|
138 |
});
|
139 |
|
169 |
$fields.each(function (i, field) {
|
170 |
|
171 |
var $field = $(field),
|
172 |
+
$attachment_ids = $field.find('.wooccmupload_field'),
|
173 |
+
$field_list = $field.find('.wooccmupload_list');//,
|
|
|
|
|
174 |
|
175 |
+
if (window.FormData && fileList[$field.attr('id')].length) {
|
176 |
|
177 |
if (!is_blocked($form)) {
|
178 |
$place_order.html(wooccm.uploading);
|
181 |
|
182 |
var data = new FormData();
|
183 |
|
184 |
+
$field_list.find('span[data-file_id]').each(function (i, file) {
|
185 |
+
|
186 |
+
var file_id = $(file).data('file_id');
|
187 |
+
|
188 |
+
if (i > wooccm.limit.max_files) {
|
189 |
+
console.log('Exeeds max files limit of ' + wooccm.limit.max_files);
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
|
193 |
+
if (fileList[$field.attr('id')][file_id] === undefined) {
|
194 |
+
console.log('Undefined ' + file_id);
|
195 |
+
return true;
|
196 |
+
}
|
197 |
|
198 |
+
if (fileList[$field.attr('id')][file_id].size > wooccm.limit.max_file_size) {
|
199 |
+
console.log('Exeeds max file size of ' + wooccm.limit.max_files);
|
200 |
+
return true;
|
|
|
|
|
201 |
}
|
202 |
+
|
203 |
+
console.log('We\'re ready to upload ' + fileList[$field.attr('id')][file_id].name);
|
204 |
+
|
205 |
+
data.append('wooccm_checkout_attachment_upload[]', fileList[$field.attr('id')][file_id]);
|
206 |
+
|
207 |
});
|
208 |
|
209 |
+
//return;
|
210 |
+
|
211 |
data.append('action', 'wooccm_checkout_attachment_upload');
|
212 |
data.append('nonce', wooccm.nonce);
|
213 |
|
226 |
$results.removeClass('woocommerce-message');
|
227 |
if (response.success) {
|
228 |
//console.log(response.data);
|
229 |
+
$attachment_ids.val(response.data);
|
230 |
} else {
|
231 |
+
$('body').trigger('update_checkout');
|
232 |
+
//console.log(response.data);
|
233 |
+
//$results.addClass('woocommerce-error').html(response.data).show();
|
234 |
}
|
235 |
},
|
236 |
complete: function (response) {
|
258 |
//}
|
259 |
});
|
260 |
|
261 |
+
|
262 |
+
// Update checkout fees
|
263 |
+
// ---------------------------------------------------------------------------
|
264 |
+
|
265 |
+
$(document).on('change', '.wooccm-add-checkout-fees', function (e) {
|
266 |
+
$('body').trigger('update_checkout');
|
267 |
+
});
|
268 |
+
|
269 |
})(jQuery);
|
assets/js/wooccm-checkout.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(function(d){var e=function(g){return g.is(".processing")||g.parents(".processing").length};var f=function(g){if(!e(g)){g.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(g){g.removeClass("processing").unblock()};var c=function(m,k,l,g,j){var n=d(m),o;if(j.match("image.*")){o="image"}else{if(j.match("application/ms.*")){l=wooccm.icons.spreadsheet;o="spreadsheet"}else{if(j.match("application/x.*")){l=wooccm.icons.archive;o="application"}else{if(j.match("audio.*")){l=wooccm.icons.audio;o="audio"}else{if(j.match("text.*")){l=wooccm.icons.text;o="text"}else{if(j.match("video.*")){l=wooccm.icons.video;o="video"}else{l=wooccm.icons.interactive;o="interactive"}}}}}}var h='<span data-file_id="'+k+'" title="'+g+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <a title="'+g+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n <span class="wooccmupload_file_image_container">\n <img class="'+o+'" alt="'+g+'" src="'+l+'"/>\n </span>\n </span>\n </span>';n.append(h).fadeIn()};var b=[];d(".wooccmupload-field").each(function(h,l){var j=d(l),k=j.find("[type=file]"),g=j.find(".wooccmupload_button"),m=j.find(".wooccmupload_list");b[j.attr("id")]=[];g.on("click",function(i){i.preventDefault();k.trigger("click")});m.on("click",".wooccmupload_file_delete",function(i){d(this).closest(".wooccmupload_file").remove()});k.on("change",function(n){var i=d(this)[0].files;if(i.length){if(window.FileReader){d.each(i,function(p,o){var q=m.find("span[data-file_id]").length+p;if(q>=wooccm.limit.max_files){alert("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(o.size>wooccm.limit.max_file_size){alert("Exeeds max file size of "+wooccm.limit.max_file_size);return true}reader=new FileReader();reader.onload=(function(r){return function(s){setTimeout(function(){c(m,b[j.attr("id")].push(o)-1,s.target.result,r.name,r.type)},200)}})(o);console.log(o.name);reader.readAsDataURL(o)})}}})});d("#order_review").on("ajaxSuccess",function(k){var j=d(k.target),i=j.find("#place_order"),h=d(".wooccmupload-field"),g=h.length;if(g){i.addClass("wooccm-upload-process")}});d(document).on("click","#place_order.wooccm-upload-process",function(l){l.preventDefault();var i=d("form.checkout"),k=d(this),h=d("#wooccm_checkout_attachment_results"),j=d(".wooccmupload-field"),g=j.length;j.each(function(m,p){var n=d(p),r=n.find(".wooccmupload_field"),q=n.find(".wooccmupload_list");if(window.FormData&&b[n.attr("id")].length){if(!e(i)){k.html(wooccm.uploading);f(i)}var o=new FormData();q.find("span[data-file_id]").each(function(t,s){var u=d(s).data("file_id");if(t>wooccm.limit.max_files){console.log("Exeeds max files limit of "+wooccm.limit.max_files);return false}if(b[n.attr("id")][u]===undefined){console.log("Undefined "+u);return true}if(b[n.attr("id")][u].size>wooccm.limit.max_file_size){console.log("Exeeds max file size of "+wooccm.limit.max_files);return true}console.log("We're ready to upload "+b[n.attr("id")][u].name);o.append("wooccm_checkout_attachment_upload[]",b[n.attr("id")][u])});o.append("action","wooccm_checkout_attachment_upload");o.append("nonce",wooccm.nonce);d.ajax({async:false,url:wooccm.ajaxurl,type:"POST",cache:false,data:o,processData:false,contentType:false,beforeSend:function(s){},success:function(s){h.removeClass("woocommerce-message");if(s.success){r.val(s.data)}else{d("body").trigger("update_checkout")}},complete:function(s){g=g-1}})}else{g=g-1}if(g==0){a(i);k.removeClass("wooccm-upload-process").trigger("click")}})});d(document).on("change",".wooccm-add-checkout-fees",function(g){d("body").trigger("update_checkout")})})(jQuery);
|
assets/less/wooccm.less
CHANGED
@@ -46,11 +46,12 @@
|
|
46 |
box-sizing: border-box;
|
47 |
padding: 10px 5px 0 5px;
|
48 |
width: 25%;
|
49 |
-
max-height: 90px;
|
50 |
position: relative;
|
51 |
|
52 |
|
53 |
.wooccmupload_file_delete {
|
|
|
54 |
position: absolute;
|
55 |
top: 2px;
|
56 |
right: -3px;
|
@@ -58,20 +59,53 @@
|
|
58 |
height: 16px;
|
59 |
background-color: #222;
|
60 |
display: block;
|
61 |
-
line-height:
|
62 |
text-align: center;
|
63 |
color: #fefefe;
|
64 |
font-weight: 900;
|
65 |
border-radius: 50%;
|
66 |
-
font-size:
|
67 |
cursor: pointer;
|
68 |
-
|
69 |
}
|
70 |
|
71 |
.wooccmupload_file_container {
|
72 |
width: 100%;
|
73 |
overflow: hidden;
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
}
|
46 |
box-sizing: border-box;
|
47 |
padding: 10px 5px 0 5px;
|
48 |
width: 25%;
|
49 |
+
//max-height: 90px;
|
50 |
position: relative;
|
51 |
|
52 |
|
53 |
.wooccmupload_file_delete {
|
54 |
+
z-index: 1;
|
55 |
position: absolute;
|
56 |
top: 2px;
|
57 |
right: -3px;
|
59 |
height: 16px;
|
60 |
background-color: #222;
|
61 |
display: block;
|
62 |
+
line-height: 16px;
|
63 |
text-align: center;
|
64 |
color: #fefefe;
|
65 |
font-weight: 900;
|
66 |
border-radius: 50%;
|
67 |
+
font-size: 12px;
|
68 |
cursor: pointer;
|
69 |
+
font-family: code;
|
70 |
}
|
71 |
|
72 |
.wooccmupload_file_container {
|
73 |
width: 100%;
|
74 |
overflow: hidden;
|
75 |
}
|
76 |
+
|
77 |
+
.wooccmupload_file_image_container {
|
78 |
+
display: flex;
|
79 |
+
justify-content: center;
|
80 |
+
align-items: center;
|
81 |
+
overflow: hidden;
|
82 |
+
width: 100%;
|
83 |
+
padding-top: 100%;
|
84 |
+
position: relative;
|
85 |
+
background: #eee;
|
86 |
+
|
87 |
+
> img {
|
88 |
+
overflow: hidden;
|
89 |
+
object-fit: cover;
|
90 |
+
position: absolute;
|
91 |
+
top: 30%;
|
92 |
+
bottom: auto;
|
93 |
+
height: 40%;
|
94 |
+
opacity: 0.8;
|
95 |
+
|
96 |
+
&.image {
|
97 |
+
top: 0;
|
98 |
+
bottom: 0;
|
99 |
+
left: 0;
|
100 |
+
right: 0;
|
101 |
+
max-height: 100%;
|
102 |
+
max-height: 100%;
|
103 |
+
height: 100%;
|
104 |
+
width: 100%;
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
}
|
109 |
}
|
110 |
|
111 |
}
|
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
@@ -1425,711 +1425,11 @@ function wooccm_admin_edit_order_shipping_details($order) {
|
|
1425 |
}
|
1426 |
}
|
1427 |
|
1428 |
-
/* function wooccm_validate_upload_process_customer() {
|
1429 |
-
|
1430 |
-
$options = get_option('wccs_settings');
|
1431 |
-
|
1432 |
-
if (!empty($options['checkness']['enable_file_upload'])) {
|
1433 |
-
return true;
|
1434 |
-
} else {
|
1435 |
-
return false;
|
1436 |
-
}
|
1437 |
-
} */
|
1438 |
-
|
1439 |
-
// Check if the customer can upload images
|
1440 |
-
// @mod - This disables the Order Uploaded Files meta box even for Administrators...?
|
1441 |
-
/*
|
1442 |
-
* 1326
|
1443 |
-
* if (wooccm_validate_upload_process_customer()) {
|
1444 |
-
add_action('woocommerce_view_order', 'wooccm_file_uploader_front_end');
|
1445 |
-
add_action('add_meta_boxes', 'wooccm_admin_edit_order_metaboxes');
|
1446 |
-
} */
|
1447 |
-
|
1448 |
-
/* function wooccm_admin_edit_order_metaboxes() {
|
1449 |
-
|
1450 |
-
global $post;
|
1451 |
-
|
1452 |
-
$post_type = 'shop_order';
|
1453 |
-
add_meta_box('woocommerce-order-files', __('Order Uploaded Files', 'woocommerce-checkout-manager'), 'wooccm_admin_edit_order_uploaded_files_meta_box', $post_type, 'normal', 'default');
|
1454 |
-
} */
|
1455 |
-
/*
|
1456 |
-
function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
1457 |
-
|
1458 |
-
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
1459 |
-
|
1460 |
-
$order_id = ( isset($post->ID) ? $post->ID : false );
|
1461 |
-
|
1462 |
-
$options = get_option('wccs_settings');
|
1463 |
-
|
1464 |
-
$upload_dir = wp_upload_dir();
|
1465 |
-
|
1466 |
-
$array = array();
|
1467 |
-
$default_wccm_values = '';
|
1468 |
-
$product_image_gallery = '';
|
1469 |
-
|
1470 |
-
$post_type = 'attachment';
|
1471 |
-
$args = array(
|
1472 |
-
'post_type' => $post_type,
|
1473 |
-
'numberposts' => -1,
|
1474 |
-
'post_status' => null,
|
1475 |
-
'post_parent' => $order_id
|
1476 |
-
);
|
1477 |
-
$posts = get_posts($args);
|
1478 |
-
// wooccm_error_log( 'posts: ' . print_r( $posts, true ) );
|
1479 |
-
// @mod - Legacy versions were not correctly saving Post Parent so let's do a search if no results were returned
|
1480 |
-
if (empty($posts)) {
|
1481 |
-
|
1482 |
-
$meta_keys = array();
|
1483 |
-
|
1484 |
-
// Additional section
|
1485 |
-
$options = get_option('wccs_settings');
|
1486 |
-
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
1487 |
-
if (!empty($buttons)) {
|
1488 |
-
foreach ($buttons as $btn) {
|
1489 |
-
if ($btn['type'] == 'wooccmupload')
|
1490 |
-
$meta_keys[] = $btn['cow'];
|
1491 |
-
}
|
1492 |
-
}
|
1493 |
-
// Billing section
|
1494 |
-
$options = get_option('wccs_settings3');
|
1495 |
-
$buttons = ( isset($options['billing_buttons']) ? $options['billing_buttons'] : false );
|
1496 |
-
if (!empty($buttons)) {
|
1497 |
-
foreach ($buttons as $btn) {
|
1498 |
-
if ($btn['type'] == 'wooccmupload')
|
1499 |
-
$meta_keys[] = sprintf('_billing_%s', $btn['cow']);
|
1500 |
-
}
|
1501 |
-
}
|
1502 |
-
// Shipping section
|
1503 |
-
$options = get_option('wccs_settings2');
|
1504 |
-
$buttons = ( isset($options['shipping_buttons']) ? $options['shipping_buttons'] : false );
|
1505 |
-
if (!empty($buttons)) {
|
1506 |
-
foreach ($buttons as $btn) {
|
1507 |
-
if ($btn['type'] == 'wooccmupload')
|
1508 |
-
$meta_keys[] = sprintf('_shipping_%s', $btn['cow']);
|
1509 |
-
}
|
1510 |
-
}
|
1511 |
-
|
1512 |
-
if (!empty($meta_keys)) {
|
1513 |
-
$values = array();
|
1514 |
-
// Check the Order for these meta keys
|
1515 |
-
foreach ($meta_keys as $meta_key) {
|
1516 |
-
$value = get_post_meta($order_id, $meta_key, true);
|
1517 |
-
if (!empty($value)) {
|
1518 |
-
if (is_array($value))
|
1519 |
-
$array[] = implode(',', $value);
|
1520 |
-
else
|
1521 |
-
$array[] = $value;
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
}
|
1525 |
-
}
|
1526 |
-
// Check if there are any attachments
|
1527 |
-
if (!empty($posts) || !empty($array)) {
|
1528 |
-
if (!empty($posts)) {
|
1529 |
-
foreach ($posts as $attachment) {
|
1530 |
-
$array[] = $attachment->ID;
|
1531 |
-
}
|
1532 |
-
}
|
1533 |
-
$default_wccm_values = implode(',', $array);
|
1534 |
-
$product_image_gallery = implode(',', $array);
|
1535 |
-
// wooccm_error_log( 'default_wccm_values: ' . print_r( $default_wccm_values, true ) );
|
1536 |
-
// wooccm_error_log( 'product_image_gallery: ' . print_r( $product_image_gallery, true ) );
|
1537 |
-
}
|
1538 |
-
|
1539 |
-
$attachments = array_filter(explode(',', $product_image_gallery));
|
1540 |
-
// wooccm_error_log( 'attachments: ' . print_r( $attachments, true ) );
|
1541 |
-
?>
|
1542 |
-
|
1543 |
-
<script type="text/javascript">
|
1544 |
-
jQuery(document).ready(function ($) {
|
1545 |
-
|
1546 |
-
$('#wccm_save_order_submit').click(function () {
|
1547 |
-
$(".wccm_results").html("<?php _e('Saving, please wait...', 'woocommerce-checkout-manager'); ?>");
|
1548 |
-
var data = {
|
1549 |
-
action: 'update_attachment_wccm',
|
1550 |
-
post_id: '<?php echo $post->ID; ?>',
|
1551 |
-
product_image_gallery: $('#product_image_gallery').val(),
|
1552 |
-
wccm_default_keys_load: $('#wccm_default_keys_load').val()
|
1553 |
-
};
|
1554 |
-
|
1555 |
-
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
1556 |
-
$.post(ajaxurl, data, function (response) {
|
1557 |
-
$(".wccm_results").html(response);
|
1558 |
-
});
|
1559 |
-
});
|
1560 |
-
|
1561 |
-
});
|
1562 |
-
</script>
|
1563 |
-
|
1564 |
-
<?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
|
1565 |
-
|
1566 |
-
<div class="woocommerce_order_items_wrapper">
|
1567 |
-
<table class="woocommerce_order_items back_end">
|
1568 |
-
|
1569 |
-
<thead>
|
1570 |
-
<tr>
|
1571 |
-
<th nowrap>
|
1572 |
-
<attr title="<?php _e('Attachment ID', 'woocommerce-checkout-manager'); ?>"><?php _e('ID', 'woocommerce-checkout-manager'); ?></attr>
|
1573 |
-
</th>
|
1574 |
-
<th><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
|
1575 |
-
<th><?php _e('Filename', 'woocommerce-checkout-manager'); ?></th>
|
1576 |
-
<th><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
|
1577 |
-
<th><?php _e('Extension', ' woocommerce-checkout-manager'); ?></th>
|
1578 |
-
<th class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
|
1579 |
-
</tr>
|
1580 |
-
</thead>
|
1581 |
-
|
1582 |
-
<tbody class="product_images">
|
1583 |
-
<?php
|
1584 |
-
if (!empty($attachments)) {
|
1585 |
-
foreach ($attachments as $attachment_id) {
|
1586 |
-
|
1587 |
-
$image_attributes = wp_get_attachment_url($attachment_id);
|
1588 |
-
$image_attributes2 = wp_get_attachment_image_src($attachment_id);
|
1589 |
-
$filename = basename($image_attributes);
|
1590 |
-
$wp_filetype = wp_check_filetype($filename);
|
1591 |
-
|
1592 |
-
$value_declear = array_diff(explode(',', $default_wccm_values), explode(',', $attachment_id));
|
1593 |
-
|
1594 |
-
echo '
|
1595 |
-
<tr class="image wccm_filesli wccmv_' . esc_attr($attachment_id) . '">
|
1596 |
-
<script type="text/javascript">
|
1597 |
-
jQuery(document).ready(function(){
|
1598 |
-
jQuery(".wccmx_' . esc_attr($attachment_id) . '").click(function(){
|
1599 |
-
|
1600 |
-
jQuery(".wccmv_' . esc_attr($attachment_id) . '").hide();
|
1601 |
-
jQuery("#product_image_gallery").val(jQuery("#product_image_gallery").val().replace("' . esc_attr($attachment_id) . '", ""));
|
1602 |
-
|
1603 |
-
});
|
1604 |
-
});
|
1605 |
-
</script>
|
1606 |
-
<td>' . $attachment_id . '</td>
|
1607 |
-
<td>' . wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), false)) . '</td>
|
1608 |
-
<td>' . wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)) . '</td>
|
1609 |
-
<td>';
|
1610 |
-
if ($image_attributes2[1] == '') {
|
1611 |
-
echo '-';
|
1612 |
-
} else {
|
1613 |
-
echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
|
1614 |
-
}
|
1615 |
-
echo '</td>
|
1616 |
-
<td>' . strtoupper($wp_filetype['ext']) . '</td>
|
1617 |
-
<td class="column-actions" nowrap>
|
1618 |
-
<a href="' . $image_attributes2[0] . '" target="_blank" class="button">' . __('Download', 'woocommerce-checkout-manager') . '</a>
|
1619 |
-
<a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
|
1620 |
-
</td>
|
1621 |
-
</tr>
|
1622 |
-
';
|
1623 |
-
}
|
1624 |
-
} else {
|
1625 |
-
echo '
|
1626 |
-
<tr>
|
1627 |
-
<td colspan="6" style="text-align:left;">' . __('No files have been uploaded to this Order.', 'woocommerce-checkout-manager') . '</td>
|
1628 |
-
</tr>';
|
1629 |
-
}
|
1630 |
-
?>
|
1631 |
-
</tbody>
|
1632 |
-
</table>
|
1633 |
-
<input type="hidden" class="wccm_add_to_list" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr($product_image_gallery); ?>" />
|
1634 |
-
<input type="hidden" id="wccm_default_keys_load" name="wccm_default_keys_load" value="<?php echo esc_attr($default_wccm_values); ?>" />
|
1635 |
-
<!-- .woocommerce_order_items -->
|
1636 |
-
|
1637 |
-
<p class="add_product_images hide-if-no-js">
|
1638 |
-
<form method="POST" action="">
|
1639 |
-
<span class="btn button-primary wccm_add_order_link fileinput-button">
|
1640 |
-
<span><?php _e('Add Order Files', 'woocommerce-checkout-manager'); ?></span>
|
1641 |
-
<input type="file" name="files_wccm" id="files_wccm" multiple />
|
1642 |
-
<button type="button" id="files_button_wccm"><?php _e('Upload Files!', 'woocommerce-checkout-manager'); ?></button>
|
1643 |
-
</span>
|
1644 |
-
</form>
|
1645 |
-
</p>
|
1646 |
-
|
1647 |
-
<!-- Edit Order: File upload -->
|
1648 |
-
<script type="text/javascript">
|
1649 |
-
jQuery(document).ready(function ($) {
|
1650 |
-
(
|
1651 |
-
function post_image_content() {
|
1652 |
-
|
1653 |
-
var input = document.getElementById("files_wccm"), formdata = false;
|
1654 |
-
|
1655 |
-
if (window.FormData) {
|
1656 |
-
formdata = new FormData();
|
1657 |
-
document.getElementById("files_button_wccm").style.display = "none";
|
1658 |
-
}
|
1659 |
-
|
1660 |
-
input.addEventListener("change", function (evt) {
|
1661 |
-
|
1662 |
-
$(".wccm_results").html("Uploading, please wait....");
|
1663 |
-
|
1664 |
-
var i = 0, len = this.files.length, img, reader, file;
|
1665 |
-
|
1666 |
-
for (; i < len; i++) {
|
1667 |
-
file = this.files[i];
|
1668 |
-
if (formdata) {
|
1669 |
-
formdata.append("files_wccm[]", file);
|
1670 |
-
}
|
1671 |
-
}
|
1672 |
-
|
1673 |
-
if (formdata) {
|
1674 |
-
$.ajax({
|
1675 |
-
url: "<?php echo admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm'); ?>",
|
1676 |
-
type: "POST",
|
1677 |
-
data: formdata,
|
1678 |
-
processData: false,
|
1679 |
-
contentType: false,
|
1680 |
-
success: function (res) {
|
1681 |
-
$('#files_wccm').show();
|
1682 |
-
$(".wccm_results").html("Files uploaded successfully.");
|
1683 |
-
|
1684 |
-
|
1685 |
-
$.ajax({
|
1686 |
-
url: '<?php echo admin_url('/post.php?post=' . $post->ID . '&action=edit'); ?>',
|
1687 |
-
data: {},
|
1688 |
-
success: function (data) {
|
1689 |
-
$("div#product_images_container").html($(data).find("div#product_images_container"));
|
1690 |
-
$(".wccm_results").html("Files uploaded successfully.");
|
1691 |
-
|
1692 |
-
},
|
1693 |
-
dataType: 'html'
|
1694 |
-
});
|
1695 |
-
}
|
1696 |
-
});
|
1697 |
-
}
|
1698 |
-
}, false);
|
1699 |
-
}
|
1700 |
-
|
1701 |
-
());
|
1702 |
-
|
1703 |
-
});
|
1704 |
-
</script>
|
1705 |
-
|
1706 |
-
<input type="button" id="wccm_save_order_submit" class="button button-primary" value="<?php _e('Save Changes', 'woocommerce-checkout-manager'); ?>">
|
1707 |
-
<div class="wccm_results"></div>
|
1708 |
-
<div class="clear"></div>
|
1709 |
-
|
1710 |
-
</div>
|
1711 |
-
<!-- .woocommerce_order_items_wrapper -->
|
1712 |
-
<?php
|
1713 |
-
} */
|
1714 |
-
|
1715 |
-
/*
|
1716 |
-
* 1326
|
1717 |
-
* front end for user
|
1718 |
-
function wooccm_file_uploader_front_end($order_id) {
|
1719 |
-
|
1720 |
-
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
1721 |
-
|
1722 |
-
$order = new WC_Order($order_id);
|
1723 |
-
|
1724 |
-
$options = get_option('wccs_settings');
|
1725 |
-
$length = ( empty($options['checkness']['file_upload_number']) ) ? 'this.files.length' : $options['checkness']['file_upload_number'];
|
1726 |
-
|
1727 |
-
$file_types = (!empty($options['checkness']['file_types']) ? explode(",", $options['checkness']['file_types']) : array() );
|
1728 |
-
$number_of_types = count($file_types);
|
1729 |
-
|
1730 |
-
$prefix = 'wc-';
|
1731 |
-
|
1732 |
-
if (empty($options['checkness']['upload_os']) || ( $order->post_status == $prefix . $options['checkness']['upload_os'] )) {
|
1733 |
-
|
1734 |
-
$post_type = 'attachment';
|
1735 |
-
$upload_dir = wp_upload_dir();
|
1736 |
-
$args = array(
|
1737 |
-
'post_type' => $post_type,
|
1738 |
-
'numberposts' => -1,
|
1739 |
-
'post_status' => null,
|
1740 |
-
'post_parent' => $order_id
|
1741 |
-
);
|
1742 |
-
$default_wccm_values = false;
|
1743 |
-
$product_image_gallery = false;
|
1744 |
-
$posts = get_posts($args);
|
1745 |
-
// wooccm_error_log( 'posts: ' . print_r( $posts, true ) );
|
1746 |
-
if (!empty($posts)) {
|
1747 |
-
foreach ($posts as $attachment)
|
1748 |
-
$array[] = $attachment->ID;
|
1749 |
-
$default_wccm_values = implode(',', $array);
|
1750 |
-
$product_image_gallery = implode(',', $array);
|
1751 |
-
}
|
1752 |
-
// wooccm_error_log( 'default_wccm_values: ' . print_r( $default_wccm_values, true ) );
|
1753 |
-
// wooccm_error_log( 'product_image_gallery: ' . print_r( $product_image_gallery, true ) );
|
1754 |
-
if (!empty($product_image_gallery))
|
1755 |
-
$attachments = array_filter(explode(',', $product_image_gallery));
|
1756 |
-
// wooccm_error_log( 'attachments: ' . print_r( $attachments, true ) );
|
1757 |
-
?>
|
1758 |
-
|
1759 |
-
<script type="text/javascript">
|
1760 |
-
jQuery(document).ready(function ($) {
|
1761 |
-
|
1762 |
-
$('#wccm_save_order_submit').click(function () {
|
1763 |
-
$(".wccm_results").html("Deleting files, please wait....");
|
1764 |
-
var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
|
1765 |
-
data = {
|
1766 |
-
action: 'update_attachment_wccm',
|
1767 |
-
product_image_gallery: $('#product_image_gallery').val(),
|
1768 |
-
wccm_default_keys_load: $('#wccm_default_keys_load').val()
|
1769 |
-
};
|
1770 |
-
|
1771 |
-
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
1772 |
-
$.post(ajaxurl, data, function (response) {
|
1773 |
-
$(".wccm_results").html(response);
|
1774 |
-
});
|
1775 |
-
});
|
1776 |
-
|
1777 |
-
});
|
1778 |
-
</script>
|
1779 |
-
|
1780 |
-
<?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
|
1781 |
-
|
1782 |
-
<h2><?php echo ( empty($options['checkness']['upload_title']) ? 'Order Uploaded Files' : esc_attr($options['checkness']['upload_title']) ); ?></h2>
|
1783 |
-
<div class="woocommerce_order_items_wrapper front_end">
|
1784 |
-
<table class="shop_table woocommerce_order_items front_end">
|
1785 |
-
|
1786 |
-
<thead>
|
1787 |
-
<tr>
|
1788 |
-
<th style="width:15%;text-align: center;"><?php _e('Attachment ID', 'woocommerce-checkout-manager'); ?></th>
|
1789 |
-
<th style="width:12%"><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
|
1790 |
-
<th style="width:30%;text-align: center;"><?php _e('Name', 'woocommerce-checkout-manager'); ?></th>
|
1791 |
-
<th style="width:12%"><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
|
1792 |
-
<th style="width:8%"><?php _e('Extension', 'woocommerce-checkout-manager'); ?></th>
|
1793 |
-
<th style="width:10%" class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
|
1794 |
-
</tr>
|
1795 |
-
</thead>
|
1796 |
-
|
1797 |
-
<tbody class="product_images front_end">
|
1798 |
-
<?php
|
1799 |
-
if (!empty($attachments)) {
|
1800 |
-
foreach ($attachments as $attachment_id) {
|
1801 |
-
|
1802 |
-
$image_attributes = wp_get_attachment_url($attachment_id);
|
1803 |
-
$image_attributes2 = wp_get_attachment_image_src($attachment_id);
|
1804 |
-
$filename = basename($image_attributes);
|
1805 |
-
$wp_filetype = wp_check_filetype($filename);
|
1806 |
-
|
1807 |
-
$value_declear = array_diff(explode(',', $default_wccm_values), explode(',', $attachment_id));
|
1808 |
-
|
1809 |
-
echo '
|
1810 |
-
<tr class="image wccm_filesli wccmv_' . esc_attr($attachment_id) . '">
|
1811 |
-
|
1812 |
-
<td style="display:none;">
|
1813 |
-
<script type="text/javascript">
|
1814 |
-
|
1815 |
-
jQuery(document).ready(function(){
|
1816 |
-
|
1817 |
-
jQuery(".wccmx_' . esc_attr($attachment_id) . '").click(function(){
|
1818 |
-
jQuery(".wccmv_' . esc_attr($attachment_id) . '").hide();
|
1819 |
-
jQuery("#product_image_gallery").val(jQuery("#product_image_gallery").val().replace("' . esc_attr($attachment_id) . '", ""));
|
1820 |
-
|
1821 |
-
});
|
1822 |
-
});
|
1823 |
-
|
1824 |
-
</script>
|
1825 |
-
</td>
|
1826 |
-
<td>' . $attachment_id . '</td>
|
1827 |
-
<td>' . wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), true)) . '</td>
|
1828 |
-
<td>' . wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)) . '</td>
|
1829 |
-
<td>';
|
1830 |
-
if ($image_attributes2[1] == '') {
|
1831 |
-
echo '-';
|
1832 |
-
} else {
|
1833 |
-
echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
|
1834 |
-
}
|
1835 |
-
echo '
|
1836 |
-
</td>
|
1837 |
-
<td>' . strtoupper($wp_filetype['ext']) . '</td>
|
1838 |
-
<td class="column-actions" nowrap>
|
1839 |
-
<a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
|
1840 |
-
</td>
|
1841 |
-
</tr>';
|
1842 |
-
}
|
1843 |
-
} else {
|
1844 |
-
echo '
|
1845 |
-
<tr>
|
1846 |
-
<td colspan="7">' . __('No uploaded files have been assigned to this Order.', 'woocommerce-checkout-manager') . '</td>
|
1847 |
-
</tr>
|
1848 |
-
';
|
1849 |
-
}
|
1850 |
-
?>
|
1851 |
-
</tbody>
|
1852 |
-
</table>
|
1853 |
-
<input type="hidden" class="wccm_add_to_list" id="product_image_gallery" name="product_image_gallery" value="<?php echo (!empty($product_image_gallery) ? esc_attr($product_image_gallery) : '' ); ?>" />
|
1854 |
-
<input type="hidden" id="wccm_default_keys_load" name="wccm_default_keys_load" value="<?php echo (!empty($default_wccm_values) ? esc_attr($default_wccm_values) : '' ); ?>" />
|
1855 |
-
<!-- .woocommerce_order_items -->
|
1856 |
-
</div>
|
1857 |
-
<!-- .woocommerce_order_items_wrapper -->
|
1858 |
-
|
1859 |
-
<button type="button" id="wccm_save_order_submit" class="file_upload_delete wooccm-btn wooccm-btn-danger delete"><?php _e('Confirm Delete', 'woocommerce-checkout-manager'); ?></button>
|
1860 |
-
|
1861 |
-
<span id="wccm_uploader_select">
|
1862 |
-
<input type="file" style="display:none;" name="files_wccm" id="files_wccm" multiple />
|
1863 |
-
<button type="button" class="file_upload_account wooccm-btn wooccm-btn-primary start" id="files_button_wccm"><?php _e('Upload Files', 'woocommerce-checkout-manager'); ?></button>
|
1864 |
-
</span>
|
1865 |
-
<!-- #wccm_uploader_select -->
|
1866 |
-
|
1867 |
-
<div class="wccm_results front_end"></div>
|
1868 |
-
|
1869 |
-
<div class="clear"></div>
|
1870 |
-
<?php
|
1871 |
-
// script for uploading the files
|
1872 |
-
echo '
|
1873 |
-
<!-- Edit Order: File upload -->
|
1874 |
-
<script type="text/javascript">
|
1875 |
-
jQuery(document).ready(function($){
|
1876 |
-
|
1877 |
-
(function post_image_content() {
|
1878 |
-
|
1879 |
-
var input = document.getElementById("files_wccm"), formdata = false;
|
1880 |
-
|
1881 |
-
$("#files_button_wccm").click( function(){
|
1882 |
-
$("#wccm_uploader_select input[type=file]").click();
|
1883 |
-
return false;
|
1884 |
-
});
|
1885 |
-
|
1886 |
-
if (window.FormData) {
|
1887 |
-
formdata = new FormData();
|
1888 |
-
}
|
1889 |
-
|
1890 |
-
input.addEventListener("change", function (evt) {
|
1891 |
-
$("#wccm_uploader_select").block({
|
1892 |
-
message: null,
|
1893 |
-
overlayCSS: {
|
1894 |
-
background: "#fff",
|
1895 |
-
opacity: 0.6
|
1896 |
-
}
|
1897 |
-
});
|
1898 |
-
|
1899 |
-
$("#wccm_uploader_select").block({
|
1900 |
-
message: null,
|
1901 |
-
overlayCSS: {
|
1902 |
-
background: "#fff",
|
1903 |
-
opacity: 0.6
|
1904 |
-
}
|
1905 |
-
});
|
1906 |
-
|
1907 |
-
var length = ' . $length . ';
|
1908 |
-
var file_array = ' . wooccm_js_array($file_types) . ';
|
1909 |
-
var wooempt = "' . implode(',', $file_types) . '";
|
1910 |
-
|
1911 |
-
for ( i = 0; i < length; i++ ) {
|
1912 |
-
file = this.files[i];
|
1913 |
-
for(x=0; x < ' . $number_of_types . '; x++){
|
1914 |
-
if( !wooempt || file.type.match(file_array[x]) ) {
|
1915 |
-
if (formdata) {
|
1916 |
-
formdata.append("files_wccm[]",file);
|
1917 |
-
}
|
1918 |
-
}
|
1919 |
-
}
|
1920 |
-
}
|
1921 |
-
|
1922 |
-
if (formdata) {
|
1923 |
-
$.ajax({
|
1924 |
-
url: "' . admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm') . '",
|
1925 |
-
type: "POST",
|
1926 |
-
data: formdata,
|
1927 |
-
processData: false,
|
1928 |
-
contentType: false,
|
1929 |
-
success: function (res) {
|
1930 |
-
$("#files_wccm").show();
|
1931 |
-
|
1932 |
-
$.ajax({
|
1933 |
-
url: "' . $order->get_view_order_url() . '",
|
1934 |
-
data: {},
|
1935 |
-
success: function (data) {
|
1936 |
-
$("div.woocommerce_order_items_wrapper.front_end").html($(data).find("div.woocommerce_order_items_wrapper.front_end"));
|
1937 |
-
jQuery("#wccm_uploader_select").unblock();
|
1938 |
-
},
|
1939 |
-
dataType: "html"
|
1940 |
-
});
|
1941 |
-
|
1942 |
-
}
|
1943 |
-
});
|
1944 |
-
}
|
1945 |
-
}, false);
|
1946 |
-
}
|
1947 |
-
());
|
1948 |
-
});
|
1949 |
-
</script>';
|
1950 |
-
// end script
|
1951 |
-
// ------------
|
1952 |
-
}
|
1953 |
-
}
|
1954 |
-
*/
|
1955 |
-
/* function wccs_upload_file_func_callback($order_id) {
|
1956 |
-
|
1957 |
-
$name = ( isset($_REQUEST['name']) ? $_REQUEST['name'] : false );
|
1958 |
-
$order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
|
1959 |
-
|
1960 |
-
if (empty($name)) {
|
1961 |
-
echo ' ' . __('Upload failed. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
1962 |
-
die();
|
1963 |
-
}
|
1964 |
-
|
1965 |
-
if (empty($order_id)) {
|
1966 |
-
echo ' ' . __('Invalid Order. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
1967 |
-
die();
|
1968 |
-
}
|
1969 |
-
|
1970 |
-
global $wpdb, $woocommerce, $post; // this is how you get access to the database
|
1971 |
-
// load files
|
1972 |
-
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
1973 |
-
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
1974 |
-
|
1975 |
-
$upload_dir = wp_upload_dir();
|
1976 |
-
|
1977 |
-
$options = get_option('wccs_settings');
|
1978 |
-
|
1979 |
-
$has_uploads = false;
|
1980 |
-
|
1981 |
-
$order = new WC_Order($order_id);
|
1982 |
-
|
1983 |
-
$files = $_FILES['' . $name . ''];
|
1984 |
-
// $upload_overrides = array( 'test_form' => false );
|
1985 |
-
|
1986 |
-
if (!empty($files['name'])) {
|
1987 |
-
foreach ($files['name'] as $key => $value) {
|
1988 |
-
if ($files['name'][$key]) {
|
1989 |
-
|
1990 |
-
$file = array(
|
1991 |
-
'name' => $files['name'][$key],
|
1992 |
-
'type' => $files['type'][$key],
|
1993 |
-
'tmp_name' => $files['tmp_name'][$key],
|
1994 |
-
'error' => $files['error'][$key],
|
1995 |
-
'size' => $files['size'][$key]
|
1996 |
-
);
|
1997 |
-
|
1998 |
-
if (!empty($options['checkness']['cat_file_upload'])) {
|
1999 |
-
add_filter('upload_dir', function( $param ) use ( $order_id ) {
|
2000 |
-
$param['path'] = sprintf('%s/wooccm_uploads/%d', $param['basedir'], $order_id);
|
2001 |
-
$param['url'] = sprintf('%s/wooccm_uploads/%d', $param['baseurl'], $order_id);
|
2002 |
-
return $param;
|
2003 |
-
}, 10, 1);
|
2004 |
-
}
|
2005 |
-
|
2006 |
-
// $movefile = wp_handle_upload($file, $upload_overrides);
|
2007 |
-
$movefile = wp_handle_upload($file);
|
2008 |
-
|
2009 |
-
// Check if the save process failed
|
2010 |
-
if (isset($movefile['error'])) {
|
2011 |
-
echo 'Could not save uploaded file. Files were not uploaded.';
|
2012 |
-
die();
|
2013 |
-
}
|
2014 |
-
|
2015 |
-
$attachment = array(
|
2016 |
-
'guid' => $movefile['url'],
|
2017 |
-
'post_mime_type' => $movefile['type'],
|
2018 |
-
'post_title' => preg_replace('/\.[^.]+$/', '', basename($movefile['file'])),
|
2019 |
-
'post_content' => '',
|
2020 |
-
'post_status' => 'inherit',
|
2021 |
-
'post_parent' => $order_id
|
2022 |
-
);
|
2023 |
-
|
2024 |
-
$attach_id = wp_insert_attachment($attachment, $movefile['url'], $order_id);
|
2025 |
-
|
2026 |
-
// you must first include the image.php file
|
2027 |
-
// for the function wp_generate_attachment_metadata() to work
|
2028 |
-
|
2029 |
-
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
2030 |
-
$attach_data = wp_generate_attachment_metadata($attach_id, $movefile['url']);
|
2031 |
-
wp_update_attachment_metadata($attach_id, $attach_data);
|
2032 |
-
|
2033 |
-
$has_uploads = true;
|
2034 |
-
}
|
2035 |
-
}
|
2036 |
-
if ($has_uploads) {
|
2037 |
-
|
2038 |
-
// send email
|
2039 |
-
$email_recipients = $options['checkness']['wooccm_notification_email'];
|
2040 |
-
if (empty($email_recipients))
|
2041 |
-
$email_recipients = get_option('admin_email');
|
2042 |
-
$email_heading = __('Files Uploaded by Customer', 'woocommerce-checkout-manager');
|
2043 |
-
$subject = sprintf(__('WooCommerce Checkout Manager - %s [%s]', 'woocommerce-checkout-manager'), $email_heading, $order->billing_first_name . ' ' . $order->billing_last_name);
|
2044 |
-
|
2045 |
-
$mailer = WC()->mailer();
|
2046 |
-
|
2047 |
-
// Buffer
|
2048 |
-
ob_start();
|
2049 |
-
?>
|
2050 |
-
<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>
|
2051 |
-
<h3>Customer Details</h3>
|
2052 |
-
<ul>
|
2053 |
-
<li>Name: <?php echo $order->billing_first_name; ?> <?php $order->billing_last_name; ?></li>
|
2054 |
-
<li>E-mail: <?php echo $order->billing_email; ?></li>
|
2055 |
-
<li>Order Number: <?php echo $order_id; ?></li>
|
2056 |
-
</ul>
|
2057 |
-
<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>
|
2058 |
-
<?php
|
2059 |
-
// Get contents
|
2060 |
-
$message = ob_get_clean();
|
2061 |
-
|
2062 |
-
$message = $mailer->wrap_message($email_heading, $message);
|
2063 |
-
|
2064 |
-
// add_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
|
2065 |
-
// wc_mail( $email_recipients, $subject, $message );
|
2066 |
-
$mailer->send($email_recipients, strip_tags($subject), $message);
|
2067 |
-
// remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
|
2068 |
-
}
|
2069 |
-
echo ' ' . __('Files were uploaded successfully.', 'woocommerce-checkout-manager') . '';
|
2070 |
-
} else {
|
2071 |
-
echo ' ' . __('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
2072 |
-
}
|
2073 |
-
die();
|
2074 |
-
} */
|
2075 |
-
|
2076 |
-
//1326
|
2077 |
-
//add_action("wp_ajax_wccs_upload_file_func", "wccs_upload_file_func_callback");
|
2078 |
-
|
2079 |
-
/*
|
2080 |
-
* 1326
|
2081 |
-
* function wooccm_set_html_content_type() {
|
2082 |
-
|
2083 |
-
return 'text/html';
|
2084 |
-
} */
|
2085 |
-
|
2086 |
function wooccm_js_str($s) {
|
2087 |
-
|
2088 |
return '"' . addcslashes($s, "\0..\37\"\\") . '"';
|
2089 |
}
|
2090 |
|
2091 |
function wooccm_js_array($array) {
|
2092 |
-
|
2093 |
$temp = array_map('wooccm_js_str', $array);
|
2094 |
return '[' . implode(',', $temp) . ']';
|
2095 |
-
}
|
2096 |
-
|
2097 |
-
/*function update_attachment_wccm_callback() {
|
2098 |
-
|
2099 |
-
global $post, $wpdb, $woocommerce;
|
2100 |
-
|
2101 |
-
// Check the User has the manage_woocommerce capability
|
2102 |
-
if (current_user_can('manage_woocommerce') == false)
|
2103 |
-
die();
|
2104 |
-
|
2105 |
-
$array1 = explode(',', sanitize_text_field(isset($_POST['wccm_default_keys_load']) ? $_POST['wccm_default_keys_load'] : '' ));
|
2106 |
-
$array2 = explode(',', sanitize_text_field(isset($_POST['product_image_gallery']) ? $_POST['product_image_gallery'] : '' ));
|
2107 |
-
$attachment_ids = array_diff($array1, $array2);
|
2108 |
-
|
2109 |
-
if (isset($_POST['wccm_default_keys_load'])) {
|
2110 |
-
if (!empty($attachment_ids)) {
|
2111 |
-
foreach ($attachment_ids as $key => $attachtoremove) {
|
2112 |
-
|
2113 |
-
// Check the Attachment exists...
|
2114 |
-
if (get_post_status($attachtoremove) == false)
|
2115 |
-
continue;
|
2116 |
-
|
2117 |
-
// Check the Attachment is associated with an Order
|
2118 |
-
$post_parent = get_post_field('post_parent', $attachtoremove);
|
2119 |
-
if (empty($post_parent)) {
|
2120 |
-
continue;
|
2121 |
-
} else {
|
2122 |
-
if (get_post_type($post_parent) <> 'shop_order')
|
2123 |
-
continue;
|
2124 |
-
}
|
2125 |
-
|
2126 |
-
// Delete the Attachment
|
2127 |
-
wp_delete_attachment($attachtoremove);
|
2128 |
-
}
|
2129 |
-
}
|
2130 |
-
echo __('Deleted successfully.', 'woocommerce-checkout-manager');
|
2131 |
-
}
|
2132 |
-
die();
|
2133 |
-
}*/
|
2134 |
-
|
2135 |
-
//add_action('wp_ajax_update_attachment_wccm', 'update_attachment_wccm_callback');
|
1425 |
}
|
1426 |
}
|
1427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1428 |
function wooccm_js_str($s) {
|
|
|
1429 |
return '"' . addcslashes($s, "\0..\37\"\\") . '"';
|
1430 |
}
|
1431 |
|
1432 |
function wooccm_js_array($array) {
|
|
|
1433 |
$temp = array_map('wooccm_js_str', $array);
|
1434 |
return '[' . implode(',', $temp) . ']';
|
1435 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/classes/main.php
CHANGED
@@ -1,49 +1,47 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
* WooCommerce Checkout Manager
|
4 |
*
|
5 |
* MAIN
|
6 |
*
|
7 |
*/
|
8 |
-
|
9 |
// Exit if accessed directly
|
10 |
-
if (
|
11 |
-
|
12 |
-
if( wooccm_validator_changename() ) {
|
13 |
-
|
14 |
-
function wooccm_before_checkout() {
|
15 |
|
16 |
-
|
17 |
-
$buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : false );
|
18 |
|
19 |
-
|
20 |
-
if( empty( $buttons ) )
|
21 |
-
return;
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
ob_start();
|
26 |
-
}
|
27 |
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
$buttons = ( isset( $options['buttons'] ) ? $options['buttons'] : false );
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
return;
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
echo str_replace( $btn['changenamep'], $btn['changename'], $content );
|
43 |
-
}
|
44 |
-
}
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
}
|
49 |
|
@@ -54,946 +52,919 @@ if( wooccm_validator_changename() ) {
|
|
54 |
|
55 |
function wooccm_validator_changename() {
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
72 |
-
if(
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
?>
|
80 |
-
<header>
|
81 |
-
|
82 |
-
</header>
|
83 |
|
84 |
-
<dl class="customer_details">
|
85 |
-
<?php
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
?>
|
95 |
-
</dl>
|
96 |
|
97 |
-
<?php if(
|
98 |
|
99 |
-
<div class="col2-set addresses">
|
100 |
|
101 |
-
|
102 |
|
103 |
-
<?php } ?>
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
<?php if(
|
114 |
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
|
129 |
-
|
130 |
|
131 |
-
</div>
|
132 |
-
<!-- .col2-set -->
|
133 |