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 | |
| 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 |
|
| 134 |
-
<?php } ?>
|
| 135 |
|
| 136 |
-
<div class="clear"></div>
|
| 137 |
|
| 138 |
-
<script type="text/javascript">
|
| 139 |
-
|
| 140 |
-
<?php foreach(
|
| 141 |
-
|
| 142 |
-
<?php } ?>
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
</script>
|
| 150 |
|
| 151 |
-
<?php
|
| 152 |
-
|
| 153 |
|
| 154 |
}
|
| 155 |
|
| 156 |
-
if(
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
?>
|
| 169 |
-
|
| 170 |
-
<script type="text/javascript">
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
<?php
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
?>
|
| 187 |
-
|
| 188 |
-
<?php
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
?>
|
| 208 |
-
|
| 209 |
-
<?php
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
?>
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
WC()->session->set('wooccm_retain', $saved );
|
| 378 |
-
|
| 379 |
-
die();
|
| 380 |
-
|
| 381 |
-
}
|
| 382 |
-
add_action( 'wp_ajax_retain_val_wccs', 'wooccm_retain_val_callback' );
|
| 383 |
-
add_action('wp_ajax_nopriv_retain_val_wccs', 'wooccm_retain_val_callback');
|
| 384 |
-
|
| 385 |
}
|
| 386 |
|
| 387 |
function wooccm_enable_auto_complete() {
|
| 388 |
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
if( !empty( $options['checkness']['retainval'] ) ) {
|
| 392 |
-
return true;
|
| 393 |
-
} else {
|
| 394 |
-
return false;
|
| 395 |
-
}
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
}
|
| 398 |
|
| 399 |
-
function wooccm_remove_tax_wccm() {
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
add_action(
|
| 410 |
-
add_action(
|
| 411 |
-
|
| 412 |
-
function wooccm_custom_user_charge_man(
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
add_action(
|
| 478 |
-
|
| 479 |
-
function wooccm_remove_tax_for_exempt(
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
add_action(
|
| 523 |
|
| 524 |
function wooccm_state_default_switch() {
|
| 525 |
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
if( !empty( $options['checkness']['per_state'] ) && !empty( $options['checkness']['per_state_check'] ) ) {
|
| 529 |
-
return $options['checkness']['per_state'];
|
| 530 |
-
}
|
| 531 |
|
|
|
|
|
|
|
|
|
|
| 532 |
}
|
| 533 |
|
| 534 |
-
function wooccm_woocommerce_delivery_notes_compat(
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
}
|
| 705 |
-
}
|
| 706 |
-
|
| 707 |
-
return array_merge( $fields, $new_fields );
|
| 708 |
-
|
| 709 |
}
|
| 710 |
|
| 711 |
-
function wooccm_order_notes(
|
| 712 |
|
| 713 |
-
|
| 714 |
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
return $fields;
|
| 726 |
|
|
|
|
| 727 |
}
|
| 728 |
|
| 729 |
function woooccm_restrict_manage_posts() {
|
| 730 |
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
?>
|
| 814 |
-
<select name="wooccm_abbreviation">
|
| 815 |
-
<?php if(
|
| 816 |
-
|
| 817 |
-
<?php } else { ?>
|
| 818 |
-
|
| 819 |
-
<?php } ?>
|
| 820 |
-
<?php
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
</select>
|
| 834 |
-
<?php
|
| 835 |
-
|
| 836 |
-
}
|
| 837 |
-
|
| 838 |
}
|
| 839 |
|
| 840 |
-
function wooccm_query_list(
|
| 841 |
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
$wooccm_abbreviation = ( isset( $_GET['wooccm_abbreviation'] ) ? sanitize_text_field( $_GET['wooccm_abbreviation'] ) : '' );
|
| 845 |
-
if( is_admin() && $pagenow == 'edit.php' && $wooccm_abbreviation != '' ) {
|
| 846 |
-
$query->query_vars[ 'meta_key' ] = $wooccm_abbreviation;
|
| 847 |
-
}
|
| 848 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 849 |
}
|
| 850 |
|
| 851 |
// ========================================
|
| 852 |
// Remove conditional notices
|
| 853 |
// ========================================
|
| 854 |
|
| 855 |
-
function wooccm_remove_notices_conditional(
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
}
|
| 986 |
-
|
| 987 |
-
}
|
| 988 |
-
}
|
| 989 |
-
|
| 990 |
-
}
|
| 991 |
-
|
| 992 |
-
}
|
| 993 |
-
}
|
| 994 |
-
|
| 995 |
-
WC()->session->set( 'wc_notices', $notice );
|
| 996 |
-
|
| 997 |
}
|
| 998 |
-
|
|
|
|
| 999 |
?>
|
| 1 |
+
<?php
|
| 2 |
/**
|
| 3 |
* WooCommerce Checkout Manager
|
| 4 |
*
|
| 5 |
* MAIN
|
| 6 |
*
|
| 7 |
*/
|
|
|
|
| 8 |
// Exit if accessed directly
|
| 9 |
+
if (!defined('ABSPATH'))
|
| 10 |
+
exit;
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
if (wooccm_validator_changename()) {
|
|
|
|
| 13 |
|
| 14 |
+
function wooccm_before_checkout() {
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
$options = get_option('wccs_settings');
|
| 17 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
// Check if the buttons exist
|
| 20 |
+
if (empty($buttons))
|
| 21 |
+
return;
|
| 22 |
|
| 23 |
+
foreach ($buttons as $btn) {
|
| 24 |
+
$label = ( isset($btn['label']) ) ? $btn['label'] : '';
|
| 25 |
+
ob_start();
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
|
| 29 |
+
function wooccm_after_checkout() {
|
|
|
|
| 30 |
|
| 31 |
+
$options = get_option('wccs_settings');
|
| 32 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
|
|
|
| 33 |
|
| 34 |
+
// Check if the buttons exist
|
| 35 |
+
if (empty($buttons))
|
| 36 |
+
return;
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
foreach ($buttons as $btn) {
|
| 39 |
+
if ($btn['type'] == 'changename') {
|
| 40 |
+
$content = ob_get_clean();
|
| 41 |
+
echo str_replace($btn['changenamep'], $btn['changename'], $content);
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
|
| 46 |
}
|
| 47 |
|
| 52 |
|
| 53 |
function wooccm_validator_changename() {
|
| 54 |
|
| 55 |
+
$options = get_option('wccs_settings');
|
| 56 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
| 57 |
+
|
| 58 |
+
if (!empty($buttons)) {
|
| 59 |
+
foreach ($buttons as $btn) {
|
| 60 |
+
if (!empty($btn['type'])) {
|
| 61 |
+
if ($btn['type'] == 'changename' && !empty($btn['label'])) {
|
| 62 |
+
return true;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
+
if (wooccm_validator_changename()) {
|
| 70 |
|
| 71 |
+
// @mod - This function isn't referenced anywhere
|
| 72 |
+
function wooccm_string_replacer($order) {
|
| 73 |
|
| 74 |
+
$options = get_option('wccs_settings');
|
| 75 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
| 76 |
+
?>
|
| 77 |
+
<header>
|
| 78 |
+
<h2><?php _e('Customer details', 'woocommerce-checkout-manager'); ?></h2>
|
| 79 |
+
</header>
|
| 80 |
|
| 81 |
+
<dl class="customer_details">
|
| 82 |
+
<?php
|
| 83 |
+
if ($order->billing_email) {
|
| 84 |
+
echo '<dt>' . __('E-mail:', 'woocommerce-checkout-manager') . '</dt>';
|
| 85 |
+
echo '<dd>' . $order->billing_email . '</dd>';
|
| 86 |
+
}
|
| 87 |
+
if ($order->billing_phone) {
|
| 88 |
+
echo '<dt>' . __('Telephone:', 'woocommerce-checkout-manager') . '</dt>';
|
| 89 |
+
echo '<dd>' . $order->billing_phone . '</dd>';
|
| 90 |
+
}
|
| 91 |
+
?>
|
| 92 |
+
</dl>
|
| 93 |
|
| 94 |
+
<?php if (get_option('woocommerce_ship_to_billing_address_only') == 'no') { ?>
|
| 95 |
|
| 96 |
+
<div class="col2-set addresses">
|
| 97 |
|
| 98 |
+
<div class="col-1">
|
| 99 |
|
| 100 |
+
<?php } ?>
|
| 101 |
|
| 102 |
+
<header class="title">
|
| 103 |
+
<h3><?php _e('Billing Address', 'woocommerce-checkout-manager'); ?></h3>
|
| 104 |
+
</header>
|
| 105 |
|
| 106 |
+
<address>
|
| 107 |
+
<p><?php if (!$order->get_formatted_billing_address())
|
| 108 |
+
_e('N/A', 'woocommerce-checkout-manager');
|
| 109 |
+
else
|
| 110 |
+
echo $order->get_formatted_billing_address();
|
| 111 |
+
?></p>
|
| 112 |
+
</address>
|
| 113 |
|
| 114 |
+
<?php if (get_option('woocommerce_ship_to_billing_address_only') == 'no') { ?>
|
| 115 |
|
| 116 |
+
</div>
|
| 117 |
+
<!-- .col-1 -->
|
| 118 |
|
| 119 |
+
<div class="col-2">
|
| 120 |
|
| 121 |
+
<header class="title">
|
| 122 |
+
<h3><?php _e('Shipping Address', 'woocommerce-checkout-manager'); ?></h3>
|
| 123 |
+
</header>
|
| 124 |
|
| 125 |
+
<address>
|
| 126 |
+
<p><?php if (!$order->get_formatted_shipping_address())
|
| 127 |
+
_e('N/A', 'woocommerce-checkout-manager');
|
| 128 |
+
else
|
| 129 |
+
echo $order->get_formatted_shipping_address();
|
| 130 |
+
?></p>
|
| 131 |
+
</address>
|
| 132 |
|
| 133 |
+
</div>
|
| 134 |
+
<!-- .col-2 -->
|
| 135 |
|
| 136 |
+
</div>
|
| 137 |
+
<!-- .col2-set -->
|
| 138 |
|
| 139 |
+
<?php } ?>
|
| 140 |
|
| 141 |
+
<div class="clear"></div>
|
| 142 |
|
| 143 |
+
<script type="text/javascript">
|
| 144 |
+
var array = [];
|
| 145 |
+
<?php foreach ($buttons as $btn) { ?>
|
| 146 |
+
array.push("<?php echo $btn['changenamep']; ?>", "<?php echo $btn['changename']; ?>")
|
| 147 |
+
<?php } ?>
|
| 148 |
+
b(array);
|
| 149 |
+
function b(array) {
|
| 150 |
+
for (var i = 0; i < (array.length - 1); i = i + 2) {
|
| 151 |
+
document.body.innerHTML = document.body.innerHTML.replace(array[i], array[i + 1])
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
</script>
|
| 155 |
|
| 156 |
+
<?php
|
| 157 |
+
}
|
| 158 |
|
| 159 |
}
|
| 160 |
|
| 161 |
+
if (wooccm_enable_auto_complete()) {
|
| 162 |
+
|
| 163 |
+
function wooccm_retain_field_values() {
|
| 164 |
+
|
| 165 |
+
$options = get_option('wccs_settings');
|
| 166 |
+
$options2 = get_option('wccs_settings2');
|
| 167 |
+
$options3 = get_option('wccs_settings3');
|
| 168 |
+
|
| 169 |
+
if (is_checkout() == false)
|
| 170 |
+
return;
|
| 171 |
+
|
| 172 |
+
$saved = WC()->session->get('wooccm_retain', array());
|
| 173 |
+
?>
|
| 174 |
+
|
| 175 |
+
<script type="text/javascript">
|
| 176 |
+
|
| 177 |
+
jQuery(document).ready(function () {
|
| 178 |
+
window.onload = function () {
|
| 179 |
+
|
| 180 |
+
<?php
|
| 181 |
+
if (!empty($options['buttons'])) {
|
| 182 |
+
foreach ($options['buttons'] as $btn) {
|
| 183 |
+
if (
|
| 184 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 185 |
+
$btn['type'] !== 'changename' &&
|
| 186 |
+
$btn['type'] !== 'heading' &&
|
| 187 |
+
$btn['disabled'] !== 'true' &&
|
| 188 |
+
empty($btn['tax_remove']) &&
|
| 189 |
+
empty($btn['add_amount'])
|
| 190 |
+
) {
|
| 191 |
+
?>
|
| 192 |
+
document.forms['checkout'].elements['<?php echo $btn['cow']; ?>'].value = "<?php echo $saved[$btn['cow']]; ?>";
|
| 193 |
+
<?php
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
if (!is_user_logged_in()) {
|
| 199 |
+
|
| 200 |
+
if (WC()->cart->needs_shipping_address() === true && sanitize_text_field($_POST['ship_to_different_address']) == 1) {
|
| 201 |
+
|
| 202 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 203 |
+
foreach ($options2['shipping_buttons'] as $btn) {
|
| 204 |
+
if (
|
| 205 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 206 |
+
$btn['type'] !== 'changename' &&
|
| 207 |
+
$btn['type'] !== 'heading' &&
|
| 208 |
+
$btn['disabled'] !== 'true' &&
|
| 209 |
+
empty($btn['tax_remove']) &&
|
| 210 |
+
empty($btn['add_amount'])
|
| 211 |
+
) {
|
| 212 |
+
?>
|
| 213 |
+
document.forms['checkout'].elements['shipping_<?php echo $btn['cow']; ?>'].value = "<?php echo $saved[sprintf('shipping_%s', $btn['cow'])]; ?>";
|
| 214 |
+
<?php
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if (!empty($options3['billing_buttons'])) {
|
| 221 |
+
foreach ($options3['billing_buttons'] as $btn) {
|
| 222 |
+
if (
|
| 223 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 224 |
+
$btn['type'] !== 'changename' &&
|
| 225 |
+
$btn['type'] !== 'heading' &&
|
| 226 |
+
$btn['disabled'] !== 'true' &&
|
| 227 |
+
empty($btn['tax_remove']) &&
|
| 228 |
+
empty($btn['add_amount'])
|
| 229 |
+
) {
|
| 230 |
+
?>
|
| 231 |
+
document.forms['checkout'].elements['billing_<?php echo $btn['cow']; ?>'].value = "<?php echo $saved[sprintf('billing_%s', $btn['cow'])]; ?>";
|
| 232 |
+
<?php
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
?>
|
| 238 |
+
|
| 239 |
+
}
|
| 240 |
+
});
|
| 241 |
+
</script>
|
| 242 |
+
|
| 243 |
+
<script type="text/javascript">
|
| 244 |
+
|
| 245 |
+
jQuery(document).ready(function() {
|
| 246 |
+
jQuery('body').change(function() {
|
| 247 |
+
|
| 248 |
+
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
|
| 249 |
+
data = { action: 'retain_val_wccs',
|
| 250 |
+
<?php
|
| 251 |
+
if (!empty($options['buttons'])) {
|
| 252 |
+
foreach ($options['buttons'] as $btn) {
|
| 253 |
+
if (
|
| 254 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 255 |
+
$btn['type'] !== 'changename' &&
|
| 256 |
+
$btn['type'] !== 'heading' &&
|
| 257 |
+
empty($btn['tax_remove']) &&
|
| 258 |
+
empty($btn['add_amount'])
|
| 259 |
+
) {
|
| 260 |
+
?>
|
| 261 |
+
<?php echo $btn['cow']; ?>: jQuery("#<?php echo $btn['cow']; ?>").val(),
|
| 262 |
+
<?php
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
if (!is_user_logged_in()) {
|
| 268 |
+
|
| 269 |
+
if (WC()->cart->needs_shipping_address() === true && sanitize_text_field($_POST['ship_to_different_address']) == 1) {
|
| 270 |
+
|
| 271 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 272 |
+
foreach ($options2['shipping_buttons'] as $btn) {
|
| 273 |
+
if (
|
| 274 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 275 |
+
$btn['type'] !== 'changename' &&
|
| 276 |
+
$btn['type'] !== 'heading' &&
|
| 277 |
+
empty($btn['tax_remove']) &&
|
| 278 |
+
empty($btn['add_amount'])
|
| 279 |
+
) {
|
| 280 |
+
?>
|
| 281 |
+
shipping_<?php echo $btn['cow']; ?>: jQuery("shipping_<?php echo $btn['cow']; ?>").val(),
|
| 282 |
+
<?php
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
if (!empty($options3['billing_buttons'])) {
|
| 289 |
+
foreach ($options3['billing_buttons'] as $btn) {
|
| 290 |
+
if (
|
| 291 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 292 |
+
$btn['type'] !== 'changename' &&
|
| 293 |
+
$btn['type'] !== 'heading' &&
|
| 294 |
+
empty($btn['tax_remove']) &&
|
| 295 |
+
empty($btn['add_amount'])
|
| 296 |
+
) {
|
| 297 |
+
?>
|
| 298 |
+
billing_<?php echo $btn['cow']; ?>: jQuery("#billing_<?php echo $btn['cow']; ?>").val(),
|
| 299 |
+
<?php
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
?>
|
| 305 |
+
};
|
| 306 |
+
jQuery.post(ajaxurl, data, function(response) { });
|
| 307 |
+
return false;
|
| 308 |
+
});
|
| 309 |
+
});
|
| 310 |
+
|
| 311 |
+
</script>
|
| 312 |
+
|
| 313 |
+
<?php
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
function wooccm_retain_val_callback() {
|
| 317 |
+
|
| 318 |
+
global $wpdb;
|
| 319 |
+
|
| 320 |
+
$options = get_option('wccs_settings');
|
| 321 |
+
$options2 = get_option('wccs_settings2');
|
| 322 |
+
$options3 = get_option('wccs_settings3');
|
| 323 |
+
|
| 324 |
+
if (!empty($options['buttons'])) {
|
| 325 |
+
foreach ($options['buttons'] as $btn) {
|
| 326 |
+
if (
|
| 327 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 328 |
+
$btn['type'] !== 'changename' &&
|
| 329 |
+
$btn['type'] !== 'heading' &&
|
| 330 |
+
empty($btn['tax_remove']) &&
|
| 331 |
+
empty($btn['add_amount'])
|
| 332 |
+
) {
|
| 333 |
+
if (!empty($_POST[$btn['cow']])) {
|
| 334 |
+
$saved[$btn['cow']] = sanitize_text_field($_POST[$btn['cow']]);
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
if (WC()->cart->needs_shipping_address() === true && sanitize_text_field($_POST['ship_to_different_address']) == 1) {
|
| 341 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 342 |
+
foreach ($options2['shipping_buttons'] as $btn) {
|
| 343 |
+
if (
|
| 344 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 345 |
+
$btn['type'] !== 'changename' &&
|
| 346 |
+
$btn['type'] !== 'heading' &&
|
| 347 |
+
empty($btn['tax_remove']) &&
|
| 348 |
+
empty($btn['add_amount'])
|
| 349 |
+
) {
|
| 350 |
+
if (!empty($_POST[sprintf('shipping_%s', $btn['cow'])])) {
|
| 351 |
+
$saved[sprintf('shipping_%s', $btn['cow'])] = sanitize_text_field($_POST[sprintf('shipping_%s', $btn['cow'])]);
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
if (!empty($options3['billing_buttons'])) {
|
| 359 |
+
foreach ($options3['billing_buttons'] as $btn) {
|
| 360 |
+
if (
|
| 361 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 362 |
+
$btn['type'] !== 'changename' &&
|
| 363 |
+
$btn['type'] !== 'heading' &&
|
| 364 |
+
empty($btn['tax_remove']) &&
|
| 365 |
+
empty($btn['add_amount'])
|
| 366 |
+
) {
|
| 367 |
+
if (!empty($_POST[sprintf('billing_%s', $btn['cow'])])) {
|
| 368 |
+
$saved[sprintf('billing_%s', $btn['cow'])] = sanitize_text_field($_POST[sprintf('billing_%s', $btn['cow'])]);
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
WC()->session->set('wooccm_retain', $saved);
|
| 375 |
+
|
| 376 |
+
die();
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
add_action('wp_ajax_retain_val_wccs', 'wooccm_retain_val_callback');
|
| 380 |
+
add_action('wp_ajax_nopriv_retain_val_wccs', 'wooccm_retain_val_callback');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
}
|
| 382 |
|
| 383 |
function wooccm_enable_auto_complete() {
|
| 384 |
|
| 385 |
+
$options = get_option('wccs_settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
+
if (!empty($options['checkness']['retainval'])) {
|
| 388 |
+
return true;
|
| 389 |
+
} else {
|
| 390 |
+
return false;
|
| 391 |
+
}
|
| 392 |
}
|
| 393 |
|
| 394 |
+
/*function wooccm_remove_tax_wccm() {
|
| 395 |
+
|
| 396 |
+
$saved['wooccm_addamount453userf'] = sanitize_text_field($_POST['add_amount_faj']);
|
| 397 |
+
$saved['wooccm_tax_save_method'] = sanitize_text_field($_POST['tax_remove_aj']);
|
| 398 |
+
$saved['wooccm_addamount453user'] = sanitize_text_field($_POST['add_amount_aj']);
|
| 399 |
+
WC()->session->set('wooccm_retain', $saved);
|
| 400 |
+
|
| 401 |
+
die();
|
| 402 |
+
}*/
|
| 403 |
+
|
| 404 |
+
//add_action('wp_ajax_remove_tax_wccm', 'wooccm_remove_tax_wccm');
|
| 405 |
+
//add_action('wp_ajax_nopriv_remove_tax_wccm', 'wooccm_remove_tax_wccm');
|
| 406 |
+
|
| 407 |
+
/*function wooccm_custom_user_charge_man($cart) {
|
| 408 |
+
|
| 409 |
+
global $woocommerce, $wpdb;
|
| 410 |
+
|
| 411 |
+
$options = get_option('wccs_settings');
|
| 412 |
+
$options2 = get_option('wccs_settings2');
|
| 413 |
+
$options3 = get_option('wccs_settings3');
|
| 414 |
+
|
| 415 |
+
$saved = WC()->session->get('wooccm_retain', array());
|
| 416 |
+
|
| 417 |
+
if (!empty($options['buttons'])) {
|
| 418 |
+
foreach ($options['buttons'] as $btn) {
|
| 419 |
+
|
| 420 |
+
if (!empty($btn['add_amount']) && !empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 421 |
+
if ($saved['wooccm_addamount453user'] == $btn['chosen_valt']) {
|
| 422 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $btn['add_amount_field'], false, '');
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
if (!empty($btn['add_amount']) && empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 427 |
+
if (!empty($saved['wooccm_addamount453userf']) && is_numeric($saved['wooccm_addamount453userf'])) {
|
| 428 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $saved['wooccm_addamount453userf'], false, '');
|
| 429 |
+
}
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
if (!empty($options3['billing_buttons'])) {
|
| 435 |
+
foreach ($options3['billing_buttons'] as $btn) {
|
| 436 |
+
|
| 437 |
+
if (!empty($btn['add_amount']) && !empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 438 |
+
|
| 439 |
+
error_log('test amount');
|
| 440 |
+
|
| 441 |
+
// if (!empty($saved['wooccm_addamount453user']) && $saved['wooccm_addamount453user'] == $btn['chosen_valt']) {
|
| 442 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $btn['add_amount_field'], false, '');
|
| 443 |
+
//}
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
if (!empty($btn['add_amount']) && empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 447 |
+
if (!empty($saved['wooccm_addamount453userf']) && is_numeric($saved['wooccm_addamount453userf'])) {
|
| 448 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $saved['wooccm_addamount453userf'], false, '');
|
| 449 |
+
}
|
| 450 |
+
}
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 455 |
+
foreach ($options2['shipping_buttons'] as $btn) {
|
| 456 |
+
|
| 457 |
+
if (!empty($btn['add_amount']) && !empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 458 |
+
if ($saved['wooccm_addamount453user'] == $btn['chosen_valt']) {
|
| 459 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $btn['add_amount_field'], false, '');
|
| 460 |
+
}
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
if (!empty($btn['add_amount']) && empty($btn['add_amount_field']) && !empty($btn['label']) && !empty($btn['fee_name'])) {
|
| 464 |
+
if (!empty($saved['wooccm_addamount453userf']) && is_numeric($saved['wooccm_addamount453userf'])) {
|
| 465 |
+
$woocommerce->cart->add_fee($btn['fee_name'], $saved['wooccm_addamount453userf'], false, '');
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
}*/
|
| 471 |
+
|
| 472 |
+
//add_action('woocommerce_cart_calculate_fees', 'wooccm_custom_user_charge_man');
|
| 473 |
+
|
| 474 |
+
/*function wooccm_remove_tax_for_exempt($cart) {
|
| 475 |
+
|
| 476 |
+
global $woocommerce, $wpdb;
|
| 477 |
+
|
| 478 |
+
$options = get_option('wccs_settings');
|
| 479 |
+
$options2 = get_option('wccs_settings2');
|
| 480 |
+
$options3 = get_option('wccs_settings3');
|
| 481 |
+
|
| 482 |
+
$saved = WC()->session->get('wooccm_retain', array());
|
| 483 |
+
|
| 484 |
+
if (!empty($options['buttons'])) {
|
| 485 |
+
foreach ($options['buttons'] as $btn) {
|
| 486 |
+
if (!empty($btn['tax_remove'])) {
|
| 487 |
+
if ($saved['wooccm_tax_save_method'] == $btn['chosen_valt']) {
|
| 488 |
+
$cart->remove_taxes();
|
| 489 |
+
}
|
| 490 |
+
}
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
if (!empty($options3['billing_buttons'])) {
|
| 495 |
+
foreach ($options3['billing_buttons'] as $btn) {
|
| 496 |
+
if (!empty($btn['tax_remove'])) {
|
| 497 |
+
if ($saved['wooccm_tax_save_method'] == $btn['chosen_valt']) {
|
| 498 |
+
$cart->remove_taxes();
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 505 |
+
foreach ($options2['shipping_buttons'] as $btn) {
|
| 506 |
+
if (!empty($btn['tax_remove'])) {
|
| 507 |
+
if ($saved['wooccm_tax_save_method'] == $btn['chosen_valt']) {
|
| 508 |
+
$cart->remove_taxes();
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
return $cart;
|
| 515 |
+
}*/
|
| 516 |
+
|
| 517 |
+
//add_action('woocommerce_calculate_totals', 'wooccm_remove_tax_for_exempt');
|
| 518 |
|
| 519 |
function wooccm_state_default_switch() {
|
| 520 |
|
| 521 |
+
$options = get_option('wccs_settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
|
| 523 |
+
if (!empty($options['checkness']['per_state']) && !empty($options['checkness']['per_state_check'])) {
|
| 524 |
+
return $options['checkness']['per_state'];
|
| 525 |
+
}
|
| 526 |
}
|
| 527 |
|
| 528 |
+
function wooccm_woocommerce_delivery_notes_compat($fields, $order) {
|
| 529 |
+
|
| 530 |
+
if (version_compare(wooccm_get_woo_version(), '2.7', '>=')) {
|
| 531 |
+
$order_id = ( method_exists($order, 'get_id') ? $order->get_id() : $order->id );
|
| 532 |
+
} else {
|
| 533 |
+
$order_id = ( isset($order->id) ? $order->id : 0 );
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
$new_fields = array();
|
| 537 |
+
|
| 538 |
+
$shipping = array(
|
| 539 |
+
'country',
|
| 540 |
+
'first_name',
|
| 541 |
+
'last_name',
|
| 542 |
+
'company',
|
| 543 |
+
'address_1',
|
| 544 |
+
'address_2',
|
| 545 |
+
'city',
|
| 546 |
+
'state',
|
| 547 |
+
'postcode'
|
| 548 |
+
);
|
| 549 |
+
$billing = array(
|
| 550 |
+
'country',
|
| 551 |
+
'first_name',
|
| 552 |
+
'last_name',
|
| 553 |
+
'company',
|
| 554 |
+
'address_1',
|
| 555 |
+
'address_2',
|
| 556 |
+
'city',
|
| 557 |
+
'state',
|
| 558 |
+
'postcode',
|
| 559 |
+
'email',
|
| 560 |
+
'phone'
|
| 561 |
+
);
|
| 562 |
+
|
| 563 |
+
$names = array(
|
| 564 |
+
'billing',
|
| 565 |
+
'shipping'
|
| 566 |
+
);
|
| 567 |
+
$inc = 3;
|
| 568 |
+
foreach ($names as $name) {
|
| 569 |
+
|
| 570 |
+
$array = ( $name == 'billing' ) ? $billing : $shipping;
|
| 571 |
+
|
| 572 |
+
$options = get_option('wccs_settings' . $inc);
|
| 573 |
+
if (!empty($options[$name . '_buttons'])) {
|
| 574 |
+
foreach ($options[$name . '_buttons'] as $btn) {
|
| 575 |
+
|
| 576 |
+
if (!in_array($btn['cow'], $array)) {
|
| 577 |
+
|
| 578 |
+
if (
|
| 579 |
+
get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) &&
|
| 580 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 581 |
+
$btn['type'] !== 'heading' &&
|
| 582 |
+
(
|
| 583 |
+
$btn['type'] !== 'multiselect' || $btn['type'] !== 'multicheckbox'
|
| 584 |
+
)
|
| 585 |
+
) {
|
| 586 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])] = array(
|
| 587 |
+
'label' => wooccm_wpml_string($btn['label']),
|
| 588 |
+
'value' => get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true)
|
| 589 |
+
);
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
if (
|
| 593 |
+
get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) &&
|
| 594 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 595 |
+
$btn['type'] !== 'heading' &&
|
| 596 |
+
(
|
| 597 |
+
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
| 598 |
+
)
|
| 599 |
+
) {
|
| 600 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])]['label'] = wooccm_wpml_string($btn['label']);
|
| 601 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])]['value'] = '';
|
| 602 |
+
$value = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
|
| 603 |
+
$strings = maybe_unserialize($value);
|
| 604 |
+
if (!empty($strings)) {
|
| 605 |
+
if (is_array($strings)) {
|
| 606 |
+
$iww = 0;
|
| 607 |
+
$len = count($strings);
|
| 608 |
+
foreach ($strings as $key) {
|
| 609 |
+
if ($iww == $len - 1) {
|
| 610 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])]['value'] .= $key;
|
| 611 |
+
} else {
|
| 612 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])]['value'] .= $key . ', ';
|
| 613 |
+
}
|
| 614 |
+
$iww++;
|
| 615 |
+
}
|
| 616 |
+
} else {
|
| 617 |
+
echo $strings;
|
| 618 |
+
}
|
| 619 |
+
} else {
|
| 620 |
+
echo '-';
|
| 621 |
+
}
|
| 622 |
+
} elseif ($btn['type'] == 'wooccmupload') {
|
| 623 |
+
$info = explode("||", get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true));
|
| 624 |
+
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
| 625 |
+
$new_fields[sprintf('_%s_%s', $name, $btn['cow'])] = array(
|
| 626 |
+
'label' => wooccm_wpml_string(trim($btn['label'])),
|
| 627 |
+
'value' => $info[0]
|
| 628 |
+
);
|
| 629 |
+
}
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
$inc--;
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
$options = get_option('wccs_settings');
|
| 637 |
+
if (!empty($options['buttons'])) {
|
| 638 |
+
foreach ($options['buttons'] as $btn) {
|
| 639 |
+
|
| 640 |
+
if (
|
| 641 |
+
get_post_meta($order_id, $btn['cow'], true) &&
|
| 642 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 643 |
+
$btn['type'] !== 'heading' &&
|
| 644 |
+
(
|
| 645 |
+
$btn['type'] !== 'multiselect' || $btn['type'] !== 'multicheckbox'
|
| 646 |
+
)
|
| 647 |
+
) {
|
| 648 |
+
$new_fields[$btn['cow']] = array(
|
| 649 |
+
'label' => wooccm_wpml_string($btn['label']),
|
| 650 |
+
'value' => get_post_meta($order_id, $btn['cow'], true)
|
| 651 |
+
);
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
if (
|
| 655 |
+
get_post_meta($order_id, $btn['cow'], true) &&
|
| 656 |
+
$btn['type'] !== 'wooccmupload' &&
|
| 657 |
+
$btn['type'] !== 'heading' &&
|
| 658 |
+
(
|
| 659 |
+
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
| 660 |
+
)
|
| 661 |
+
) {
|
| 662 |
+
$new_fields[$btn['cow']]['label'] = wooccm_wpml_string($btn['label']);
|
| 663 |
+
$new_fields[$btn['cow']]['value'] = '';
|
| 664 |
+
$value = get_post_meta($order_id, $btn['cow'], true);
|
| 665 |
+
$strings = maybe_unserialize($value);
|
| 666 |
+
if (!empty($strings)) {
|
| 667 |
+
if (is_array($strings)) {
|
| 668 |
+
$iww = 0;
|
| 669 |
+
$len = count($strings);
|
| 670 |
+
foreach ($strings as $key) {
|
| 671 |
+
if ($iww == $len - 1) {
|
| 672 |
+
$new_fields[$btn['cow']]['value'] .= $key;
|
| 673 |
+
} else {
|
| 674 |
+
$new_fields[$btn['cow']]['value'] .= $key . ', ';
|
| 675 |
+
}
|
| 676 |
+
$iww++;
|
| 677 |
+
}
|
| 678 |
+
} else {
|
| 679 |
+
echo $strings;
|
| 680 |
+
}
|
| 681 |
+
} else {
|
| 682 |
+
echo '-';
|
| 683 |
+
}
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
if ($btn['type'] == 'wooccmupload') {
|
| 687 |
+
$info = get_post_meta($order_id, $btn['cow'], true);
|
| 688 |
+
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
| 689 |
+
$new_fields[$btn['cow']] = array(
|
| 690 |
+
'label' => wooccm_wpml_string(trim($btn['label'])),
|
| 691 |
+
'value' => $info[0]
|
| 692 |
+
);
|
| 693 |
+
}
|
| 694 |
+
}
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
return array_merge($fields, $new_fields);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 698 |
}
|
| 699 |
|
| 700 |
+
function wooccm_order_notes($fields = array()) {
|
| 701 |
|
| 702 |
+
$options = get_option('wccs_settings');
|
| 703 |
|
| 704 |
+
if (!empty($options['checkness']['noteslabel'])) {
|
| 705 |
+
$fields['order']['order_comments']['label'] = $options['checkness']['noteslabel'];
|
| 706 |
+
}
|
| 707 |
+
if (!empty($options['checkness']['notesplaceholder'])) {
|
| 708 |
+
$fields['order']['order_comments']['placeholder'] = $options['checkness']['notesplaceholder'];
|
| 709 |
+
}
|
| 710 |
+
if (!empty($options['checkness']['notesenable'])) {
|
| 711 |
+
unset($fields['order']['order_comments']);
|
| 712 |
+
}
|
|
|
|
|
|
|
| 713 |
|
| 714 |
+
return $fields;
|
| 715 |
}
|
| 716 |
|
| 717 |
function woooccm_restrict_manage_posts() {
|
| 718 |
|
| 719 |
+
$options = get_option('wccs_settings');
|
| 720 |
+
$options2 = get_option('wccs_settings2');
|
| 721 |
+
$options3 = get_option('wccs_settings3');
|
| 722 |
+
|
| 723 |
+
$billing = array(
|
| 724 |
+
'country',
|
| 725 |
+
'first_name',
|
| 726 |
+
'last_name',
|
| 727 |
+
'company',
|
| 728 |
+
'address_1',
|
| 729 |
+
'address_2',
|
| 730 |
+
'city',
|
| 731 |
+
'state',
|
| 732 |
+
'postcode',
|
| 733 |
+
'email',
|
| 734 |
+
'phone'
|
| 735 |
+
);
|
| 736 |
+
$shipping = array(
|
| 737 |
+
'country',
|
| 738 |
+
'first_name',
|
| 739 |
+
'last_name',
|
| 740 |
+
'company',
|
| 741 |
+
'address_1',
|
| 742 |
+
'address_2',
|
| 743 |
+
'city',
|
| 744 |
+
'state',
|
| 745 |
+
'postcode'
|
| 746 |
+
);
|
| 747 |
+
|
| 748 |
+
$post_type = 'shop_order';
|
| 749 |
+
if (get_current_screen()->post_type == $post_type) {
|
| 750 |
+
|
| 751 |
+
$values = array();
|
| 752 |
+
if (!empty($options['buttons'])) {
|
| 753 |
+
foreach ($options['buttons'] as $name) {
|
| 754 |
+
$values[$name['label']] = $name['cow'];
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
if (!empty($values)) {
|
| 758 |
+
array_unique($values);
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
+
$values2 = array();
|
| 762 |
+
if (!empty($options2['shipping_buttons'])) {
|
| 763 |
+
foreach ($options2['shipping_buttons'] as $name) {
|
| 764 |
+
if (!in_array($name['cow'], $shipping)) {
|
| 765 |
+
$values2['Shipping ' . $name['label']] = sprintf('_shipping_%s', $name['cow']);
|
| 766 |
+
}
|
| 767 |
+
}
|
| 768 |
+
}
|
| 769 |
+
if (!empty($values2)) {
|
| 770 |
+
array_unique($values2);
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
$values3 = array();
|
| 774 |
+
if (!empty($options3['billing_buttons'])) {
|
| 775 |
+
foreach ($options3['billing_buttons'] as $name) {
|
| 776 |
+
if (!in_array($name['cow'], $billing)) {
|
| 777 |
+
$values3['Billing ' . $name['label']] = sprintf('_billing_%s', $name['cow']);
|
| 778 |
+
}
|
| 779 |
+
}
|
| 780 |
+
}
|
| 781 |
+
if (!empty($values3)) {
|
| 782 |
+
array_unique($values3);
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
if (!empty($values) && !empty($values2) && !empty($values3)) {
|
| 786 |
+
$values = array_merge($values, $values2);
|
| 787 |
+
$values = array_merge($values, $values3);
|
| 788 |
+
} elseif (!empty($values) && !empty($values2) && empty($values3)) {
|
| 789 |
+
$values = array_merge($values, $values2);
|
| 790 |
+
} elseif (!empty($values) && empty($values2) && !empty($values3)) {
|
| 791 |
+
$values = array_merge($values, $values3);
|
| 792 |
+
} elseif (empty($values) && !empty($values2) && !empty($values3)) {
|
| 793 |
+
$values = array_merge($values2, $values3);
|
| 794 |
+
} elseif (empty($values) && empty($values2) && !empty($values3)) {
|
| 795 |
+
$values = $values3;
|
| 796 |
+
} elseif (empty($values) && !empty($values2) && empty($values3)) {
|
| 797 |
+
$values = $values2;
|
| 798 |
+
} elseif (!empty($values) && empty($values2) && empty($values3)) {
|
| 799 |
+
$values = $values;
|
| 800 |
+
}
|
| 801 |
+
?>
|
| 802 |
+
<select name="wooccm_abbreviation">
|
| 803 |
+
<?php if (empty($values) && empty($values2) && empty($values3)) { ?>
|
| 804 |
+
<option value=""><?php _e('No Added Fields', 'woocommerce-checkout-manager'); ?></option>
|
| 805 |
+
<?php } else { ?>
|
| 806 |
+
<option value=""><?php _e('Field Name', 'woocommerce-checkout-manager'); ?></option>
|
| 807 |
+
<?php } ?>
|
| 808 |
+
<?php
|
| 809 |
+
$current_v = ( isset($_GET['wooccm_abbreviation']) ? sanitize_text_field($_GET['wooccm_abbreviation']) : '' );
|
| 810 |
+
if (!empty($values)) {
|
| 811 |
+
foreach ($values as $label => $value) {
|
| 812 |
+
printf(
|
| 813 |
+
'<option value="%s"%s>%s</option>', $value, $value == $current_v ? ' selected="selected"' : '', $label
|
| 814 |
+
);
|
| 815 |
+
}
|
| 816 |
+
}
|
| 817 |
+
?>
|
| 818 |
+
</select>
|
| 819 |
+
<?php
|
| 820 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 821 |
}
|
| 822 |
|
| 823 |
+
function wooccm_query_list($query) {
|
| 824 |
|
| 825 |
+
global $pagenow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 826 |
|
| 827 |
+
$wooccm_abbreviation = ( isset($_GET['wooccm_abbreviation']) ? sanitize_text_field($_GET['wooccm_abbreviation']) : '' );
|
| 828 |
+
if (is_admin() && $pagenow == 'edit.php' && $wooccm_abbreviation != '') {
|
| 829 |
+
$query->query_vars['meta_key'] = $wooccm_abbreviation;
|
| 830 |
+
}
|
| 831 |
}
|
| 832 |
|
| 833 |
// ========================================
|
| 834 |
// Remove conditional notices
|
| 835 |
// ========================================
|
| 836 |
|
| 837 |
+
function wooccm_remove_notices_conditional($posted) {
|
| 838 |
+
|
| 839 |
+
$notice = WC()->session->get('wc_notices');
|
| 840 |
+
|
| 841 |
+
$shipping = array(
|
| 842 |
+
'country',
|
| 843 |
+
'first_name',
|
| 844 |
+
'last_name',
|
| 845 |
+
'company',
|
| 846 |
+
'address_1',
|
| 847 |
+
'address_2',
|
| 848 |
+
'city',
|
| 849 |
+
'state',
|
| 850 |
+
'postcode'
|
| 851 |
+
);
|
| 852 |
+
$billing = array(
|
| 853 |
+
'country',
|
| 854 |
+
'first_name',
|
| 855 |
+
'last_name',
|
| 856 |
+
'company',
|
| 857 |
+
'address_1',
|
| 858 |
+
'address_2',
|
| 859 |
+
'city',
|
| 860 |
+
'state',
|
| 861 |
+
'postcode',
|
| 862 |
+
'email',
|
| 863 |
+
'phone'
|
| 864 |
+
);
|
| 865 |
+
|
| 866 |
+
$options = get_option('wccs_settings');
|
| 867 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
| 868 |
+
|
| 869 |
+
$names = array(
|
| 870 |
+
'billing',
|
| 871 |
+
'shipping'
|
| 872 |
+
);
|
| 873 |
+
$inc = 3;
|
| 874 |
+
foreach ($names as $name) {
|
| 875 |
+
|
| 876 |
+
$array = ( $name == 'billing' ) ? $billing : $shipping;
|
| 877 |
+
|
| 878 |
+
$options2 = get_option('wccs_settings' . $inc);
|
| 879 |
+
if (!empty($options2[$name . '_buttons'])) {
|
| 880 |
+
foreach ($options2[$name . '_buttons'] as $btn) {
|
| 881 |
+
|
| 882 |
+
if (
|
| 883 |
+
!empty($btn['chosen_valt']) &&
|
| 884 |
+
!empty($btn['conditional_parent_use']) &&
|
| 885 |
+
!empty($btn['conditional_tie']) &&
|
| 886 |
+
$btn['type'] !== 'changename' &&
|
| 887 |
+
$btn['type'] !== 'heading' &&
|
| 888 |
+
!empty($btn['conditional_parent'])
|
| 889 |
+
) {
|
| 890 |
+
if (!empty($_POST[$btn['cow']])) {
|
| 891 |
+
foreach ($buttons as $btn2) {
|
| 892 |
+
|
| 893 |
+
if (
|
| 894 |
+
!empty($btn2['chosen_valt']) &&
|
| 895 |
+
!empty($btn2['conditional_parent_use']) &&
|
| 896 |
+
!empty($btn2['conditional_tie']) &&
|
| 897 |
+
$btn2['type'] !== 'changename' &&
|
| 898 |
+
$btn2['type'] !== 'heading' &&
|
| 899 |
+
empty($btn2['conditional_parent'])
|
| 900 |
+
) {
|
| 901 |
+
if (sanitize_text_field($_POST[$btn['cow']]) != $btn2['chosen_valt']) {
|
| 902 |
+
if (empty($_POST[$btn2['cow']])) {
|
| 903 |
+
foreach ($notice['error'] as $position => $value) {
|
| 904 |
+
|
| 905 |
+
if (strip_tags($value) == sprintf(__('%s is a required field.', 'woocommerce'), wooccm_wpml_string($btn2['label']))) {
|
| 906 |
+
unset($notice['error'][$position]);
|
| 907 |
+
}
|
| 908 |
+
}
|
| 909 |
+
}
|
| 910 |
+
}
|
| 911 |
+
}
|
| 912 |
+
}
|
| 913 |
+
} else {
|
| 914 |
+
foreach ($notice['error'] as $position => $value) {
|
| 915 |
+
|
| 916 |
+
if (strip_tags($value) == sprintf(__('%s is a required field.', 'woocommerce'), wooccm_wpml_string($btn2['label']))) {
|
| 917 |
+
unset($notice['error'][$position]);
|
| 918 |
+
}
|
| 919 |
+
}
|
| 920 |
+
}
|
| 921 |
+
}
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
$inc--;
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
$options = get_option('wccs_settings');
|
| 928 |
+
|
| 929 |
+
global $woocommerce;
|
| 930 |
+
|
| 931 |
+
if (!empty($options['buttons'])) {
|
| 932 |
+
foreach ($options['buttons'] as $btn) {
|
| 933 |
+
|
| 934 |
+
if (!empty($btn['chosen_valt']) && !empty($btn['conditional_parent_use']) && !empty($btn['conditional_tie']) && $btn['type'] !== 'changename' && ($btn['type'] !== 'heading') && !empty($btn['conditional_parent'])) {
|
| 935 |
+
|
| 936 |
+
if (!empty($_POST[$btn['cow']])) {
|
| 937 |
+
|
| 938 |
+
foreach ($options['buttons'] as $btn2) {
|
| 939 |
+
|
| 940 |
+
if (!empty($btn2['chosen_valt']) && !empty($btn2['conditional_parent_use']) && !empty($btn2['conditional_tie']) && $btn2['type'] !== 'changename' && ($btn2['type'] !== 'heading') && empty($btn2['conditional_parent'])) {
|
| 941 |
+
if (sanitize_text_field($_POST[$btn['cow']]) != $btn2['chosen_valt']) {
|
| 942 |
+
if (empty($_POST[$btn2['cow']])) {
|
| 943 |
+
foreach ($notice['error'] as $position => $value) {
|
| 944 |
+
|
| 945 |
+
if (strip_tags($value) == sprintf(__('%s is a required field.', 'woocommerce'), wooccm_wpml_string($btn2['label']))) {
|
| 946 |
+
unset($notice['error'][$position]);
|
| 947 |
+
}
|
| 948 |
+
}
|
| 949 |
+
}
|
| 950 |
+
}
|
| 951 |
+
}
|
| 952 |
+
}
|
| 953 |
+
} else {
|
| 954 |
+
|
| 955 |
+
foreach ($notice['error'] as $position => $value) {
|
| 956 |
+
|
| 957 |
+
if (strip_tags($value) == sprintf(__('%s is a required field.', 'woocommerce'), wooccm_wpml_string($btn2['label']))) {
|
| 958 |
+
unset($notice['error'][$position]);
|
| 959 |
+
}
|
| 960 |
+
}
|
| 961 |
+
}
|
| 962 |
+
}
|
| 963 |
+
}
|
| 964 |
+
}
|
| 965 |
+
|
| 966 |
+
WC()->session->set('wc_notices', $notice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
}
|
| 968 |
+
|
| 969 |
+
add_action('woocommerce_after_checkout_validation', 'wooccm_remove_notices_conditional');
|
| 970 |
?>
|
includes/template.php
CHANGED
|
@@ -1,294 +1,4 @@
|
|
| 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
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
// @mod - Change to thank you page to catch all Order Status
|
| 3 |
// add_action( 'woocommerce_order_status_completed', 'wooccm_update_attachment_ids' );
|
| 4 |
// Checkout - Order Received
|
new/admin.php
CHANGED
|
@@ -117,10 +117,12 @@ if (!class_exists('WOOCCM_Admin')) {
|
|
| 117 |
wp_die();
|
| 118 |
}
|
| 119 |
|
| 120 |
-
function add_sections(
|
| 121 |
|
| 122 |
global $current_section;
|
| 123 |
|
|
|
|
|
|
|
| 124 |
$sections[''] = esc_html__('General', 'woocommerce-checkout-manager');
|
| 125 |
$sections['orders'] = esc_html__('Orders', 'woocommerce-checkout-manager');
|
| 126 |
$sections['billing'] = esc_html__('Billing', 'woocommerce-checkout-manager');
|
| 117 |
wp_die();
|
| 118 |
}
|
| 119 |
|
| 120 |
+
function add_sections() {
|
| 121 |
|
| 122 |
global $current_section;
|
| 123 |
|
| 124 |
+
$sections = array();
|
| 125 |
+
|
| 126 |
$sections[''] = esc_html__('General', 'woocommerce-checkout-manager');
|
| 127 |
$sections['orders'] = esc_html__('Orders', 'woocommerce-checkout-manager');
|
| 128 |
$sections['billing'] = esc_html__('Billing', 'woocommerce-checkout-manager');
|
new/admin/pages/billing.php
CHANGED
|
@@ -150,6 +150,9 @@
|
|
| 150 |
<li class="advanced_options">
|
| 151 |
<a href="#advanced_product_data"><span><?php esc_html_e('Timing', 'woocommerce-checkout-manager'); ?></span></a>
|
| 152 |
</li>
|
|
|
|
|
|
|
|
|
|
| 153 |
<li class="marketplace-suggestions_options">
|
| 154 |
<a href="#marketplace_suggestions"><span><?php esc_html_e('Advanced', 'woocommerce-checkout-manager'); ?></span></a>
|
| 155 |
</li>
|
|
@@ -158,7 +161,6 @@
|
|
| 158 |
<div id="general_product_data" class="panel woocommerce_options_panel" style="display: none;">
|
| 159 |
<div class="options_group">
|
| 160 |
<!--<p>
|
| 161 |
-
<td class="billing-wccs-order-hidden">
|
| 162 |
<input type="hidden" name="order" value="{{data.order}}">
|
| 163 |
</p>-->
|
| 164 |
<!--<p>
|
|
@@ -173,6 +175,10 @@
|
|
| 173 |
<label><?php esc_html_e('Name', 'woocommerce-checkout-manager'); ?></label>
|
| 174 |
<input class="short" type="text" name="cow" placeholder="<?php esc_html_e('MyField', 'woocommerce-checkout-manager'); ?>" value="{{data.cow}}" readonly="readonly">
|
| 175 |
<span class="description"><?php esc_html_e('To edit Abbreviations open General > Switches > Editing Of Abbreviation Fields.', 'woocommerce-checkout-manager'); ?></span>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
</p>
|
| 177 |
</div>
|
| 178 |
<!--<div class="options_group">
|
|
@@ -203,7 +209,7 @@
|
|
| 203 |
</p>
|
| 204 |
<p class="form-field">
|
| 205 |
<label><?php esc_html_e('Placeholder', 'woocommerce-checkout-manager'); ?></label>
|
| 206 |
-
<input class="short" type="text" name="placeholder"
|
| 207 |
<span class="description"><?php esc_html_e('Placeholder text for the checkout field.', 'woocommerce-checkout-manager'); ?></span>
|
| 208 |
</p>
|
| 209 |
</div>
|
|
@@ -266,7 +272,7 @@
|
|
| 266 |
</p>
|
| 267 |
<p class="form-field">
|
| 268 |
<label><?php esc_html_e('Chosen Value', 'woocommerce-checkout-manager'); ?></label>
|
| 269 |
-
<input class="short" type="text" name="chosen_valt" placeholder="Yes" value="{{data.chosen_valt}}">
|
| 270 |
</p>
|
| 271 |
</div>
|
| 272 |
</div>
|
|
@@ -285,19 +291,23 @@
|
|
| 285 |
<p class="form-field">
|
| 286 |
<label><?php esc_html_e('Amount Total', 'woocommerce-checkout-manager'); ?></label>
|
| 287 |
<input class="short" name="add_amount_field" type="text" value="{{data.add_amount_field}}" placeholder="50">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
</p>
|
| 289 |
</div>
|
| 290 |
|
| 291 |
<div class="options_group">
|
| 292 |
-
<p class="form-field">
|
| 293 |
-
<label><?php esc_html_e('Deny Checkout', 'woocommerce-checkout-manager'); ?></label>
|
| 294 |
-
<input <# if ( data.deny_checkout == 'true' ) { #>checked<# } #> type="checkbox" name="deny_checkout" value="true">
|
| 295 |
-
<span class="description"><?php esc_html_e('1326.', 'woocommerce-checkout-manager'); ?></span>
|
| 296 |
-
</p>
|
| 297 |
<p class="form-field">
|
| 298 |
<label><?php esc_html_e('Tax Remove', 'woocommerce-checkout-manager'); ?></label>
|
| 299 |
<input <# if ( data.tax_remove == 'true' ) { #>checked<# } #> type="checkbox" name="tax_remove" value="true">
|
| 300 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
<p class="form-field">
|
| 302 |
<label><?php esc_html_e('Deny Receipt', 'woocommerce-checkout-manager'); ?></label>
|
| 303 |
<input <# if ( data.deny_receipt == 'true' ) { #>checked<# } #> type="checkbox" name="deny_receipt" value="true">
|
|
@@ -338,22 +348,29 @@
|
|
| 338 |
<p class="form-field">
|
| 339 |
<label><?php esc_html_e('More', 'woocommerce-checkout-manager'); ?></label>
|
| 340 |
<input <# if ( data.more_content == '1' ) { #>checked<# } #> type="checkbox" name="more_content" value="1">
|
|
|
|
| 341 |
</p>
|
|
|
|
|
|
|
|
|
|
| 342 |
<p class="form-field">
|
| 343 |
<label><?php esc_html_e('Hide Field from Product', 'woocommerce-checkout-manager'); ?></label>
|
| 344 |
-
<input class="short" type="text" name="single_p" placeholder="Product ID(s) e.g 1674||1233" value="{{data.single_p}}">
|
| 345 |
</p>
|
| 346 |
<p class="form-field">
|
| 347 |
<label><?php esc_html_e('Show Field for Product', 'woocommerce-checkout-manager'); ?></label>
|
| 348 |
-
<input class="short" type="text" name="single_px" placeholder="Product ID(s) e.g 1674||1233" value="{{data.single_px}}">
|
| 349 |
</p>
|
|
|
|
|
|
|
|
|
|
| 350 |
<p class="form-field">
|
| 351 |
<label><?php esc_html_e('Hide Field from Category', 'woocommerce-checkout-manager'); ?></label>
|
| 352 |
-
<input class="short" type="text" name="single_p_cat" placeholder="Category Slug(s) e.g my-cat||my-cat2" value="{{data.single_p_cat}}">
|
| 353 |
</p>
|
| 354 |
<p class="form-field">
|
| 355 |
<label><?php esc_html_e('Show Field for Category', 'woocommerce-checkout-manager'); ?></label>
|
| 356 |
-
<input class="short" type="text" name="single_px_cat" placeholder="my-cat
|
| 357 |
</p>
|
| 358 |
</div>
|
| 359 |
</div>
|
|
@@ -448,7 +465,25 @@
|
|
| 448 |
</div>
|
| 449 |
|
| 450 |
</div>
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
<div id="marketplace_suggestions" class="panel woocommerce_options_panel hidden" style="display: none;">
|
| 453 |
<div class="marketplace-suggestions-container showing-suggestion" data-marketplace-suggestions-context="product-edit-meta-tab-header">
|
| 454 |
<div class="marketplace-suggestion-container" data-suggestion-slug="product-edit-meta-tab-header">
|
|
@@ -558,7 +593,7 @@
|
|
| 558 |
<p class="description"><?php esc_html_e('Label text for the checkout field.', 'woocommerce-checkout-manager'); ?></p>
|
| 559 |
<label class="setting" data-setting="placeholder">
|
| 560 |
<span class="name"><?php esc_html_e('Placeholder', 'woocommerce-checkout-manager'); ?></span>
|
| 561 |
-
<input type="text" name="placeholder"
|
| 562 |
</label>
|
| 563 |
<p class="description"><?php esc_html_e('Placeholder text for the checkout field.', 'woocommerce-checkout-manager'); ?></p>
|
| 564 |
<label class="setting" data-setting="position">
|
| 150 |
<li class="advanced_options">
|
| 151 |
<a href="#advanced_product_data"><span><?php esc_html_e('Timing', 'woocommerce-checkout-manager'); ?></span></a>
|
| 152 |
</li>
|
| 153 |
+
<li class="advanced_panel">
|
| 154 |
+
<a href="#advanced_panel"><span><?php esc_html_e('Advanced', 'woocommerce-checkout-manager'); ?></span></a>
|
| 155 |
+
</li>
|
| 156 |
<li class="marketplace-suggestions_options">
|
| 157 |
<a href="#marketplace_suggestions"><span><?php esc_html_e('Advanced', 'woocommerce-checkout-manager'); ?></span></a>
|
| 158 |
</li>
|
| 161 |
<div id="general_product_data" class="panel woocommerce_options_panel" style="display: none;">
|
| 162 |
<div class="options_group">
|
| 163 |
<!--<p>
|
|
|
|
| 164 |
<input type="hidden" name="order" value="{{data.order}}">
|
| 165 |
</p>-->
|
| 166 |
<!--<p>
|
| 175 |
<label><?php esc_html_e('Name', 'woocommerce-checkout-manager'); ?></label>
|
| 176 |
<input class="short" type="text" name="cow" placeholder="<?php esc_html_e('MyField', 'woocommerce-checkout-manager'); ?>" value="{{data.cow}}" readonly="readonly">
|
| 177 |
<span class="description"><?php esc_html_e('To edit Abbreviations open General > Switches > Editing Of Abbreviation Fields.', 'woocommerce-checkout-manager'); ?></span>
|
| 178 |
+
</p>
|
| 179 |
+
<p class="form-field">
|
| 180 |
+
<label><?php esc_html_e('Default', 'woocommerce-checkout-manager'); ?></label>
|
| 181 |
+
<input class="short" type="text" name="default" placeholder="<?php esc_html_e('Enter a default value (optional)', 'woocommerce-checkout-manager'); ?>" value="{{data.default}}" readonly="readonly">
|
| 182 |
</p>
|
| 183 |
</div>
|
| 184 |
<!--<div class="options_group">
|
| 209 |
</p>
|
| 210 |
<p class="form-field">
|
| 211 |
<label><?php esc_html_e('Placeholder', 'woocommerce-checkout-manager'); ?></label>
|
| 212 |
+
<input class="short" type="text" name="placeholder" placeholder="<?php esc_html_e('Example red', 'woocommerce-checkout-manager'); ?>" value="{{data.placeholder}}">
|
| 213 |
<span class="description"><?php esc_html_e('Placeholder text for the checkout field.', 'woocommerce-checkout-manager'); ?></span>
|
| 214 |
</p>
|
| 215 |
</div>
|
| 272 |
</p>
|
| 273 |
<p class="form-field">
|
| 274 |
<label><?php esc_html_e('Chosen Value', 'woocommerce-checkout-manager'); ?></label>
|
| 275 |
+
<input class="short" type="text" name="chosen_valt" placeholder="<?php esc_html_e('Yes'); ?>" value="{{data.chosen_valt}}">
|
| 276 |
</p>
|
| 277 |
</div>
|
| 278 |
</div>
|
| 291 |
<p class="form-field">
|
| 292 |
<label><?php esc_html_e('Amount Total', 'woocommerce-checkout-manager'); ?></label>
|
| 293 |
<input class="short" name="add_amount_field" type="text" value="{{data.add_amount_field}}" placeholder="50">
|
| 294 |
+
<select style="margin:0 0 0 10px;line-height: 30px; height: 30px;" class="select" name="add_amount_type">
|
| 295 |
+
<option value="fixed" selected="selected">$</option>
|
| 296 |
+
<option value="percent">%</option>
|
| 297 |
+
</select>
|
| 298 |
</p>
|
| 299 |
</div>
|
| 300 |
|
| 301 |
<div class="options_group">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
<p class="form-field">
|
| 303 |
<label><?php esc_html_e('Tax Remove', 'woocommerce-checkout-manager'); ?></label>
|
| 304 |
<input <# if ( data.tax_remove == 'true' ) { #>checked<# } #> type="checkbox" name="tax_remove" value="true">
|
| 305 |
</p>
|
| 306 |
+
<!--<p class="form-field">
|
| 307 |
+
<label><?php esc_html_e('Deny Checkout', 'woocommerce-checkout-manager'); ?></label>
|
| 308 |
+
<input <# if ( data.deny_checkout == 'true' ) { #>checked<# } #> type="checkbox" name="deny_checkout" value="true">
|
| 309 |
+
<span class="description"><?php esc_html_e('1326.', 'woocommerce-checkout-manager'); ?></span>
|
| 310 |
+
</p>-->
|
| 311 |
<p class="form-field">
|
| 312 |
<label><?php esc_html_e('Deny Receipt', 'woocommerce-checkout-manager'); ?></label>
|
| 313 |
<input <# if ( data.deny_receipt == 'true' ) { #>checked<# } #> type="checkbox" name="deny_receipt" value="true">
|
| 348 |
<p class="form-field">
|
| 349 |
<label><?php esc_html_e('More', 'woocommerce-checkout-manager'); ?></label>
|
| 350 |
<input <# if ( data.more_content == '1' ) { #>checked<# } #> type="checkbox" name="more_content" value="1">
|
| 351 |
+
<span class="description"><?php esc_html_e('Apply conditions event it there is more than one product', 'woocommerce-checkout-manager'); ?></span>
|
| 352 |
</p>
|
| 353 |
+
</div>
|
| 354 |
+
|
| 355 |
+
<div class="options_group">
|
| 356 |
<p class="form-field">
|
| 357 |
<label><?php esc_html_e('Hide Field from Product', 'woocommerce-checkout-manager'); ?></label>
|
| 358 |
+
<input class="short" type="text" name="single_p" placeholder="<?php esc_html_e('Product ID(s) e.g 1674||1233', 'woocommerce-checkout-manager'); ?>" value="{{data.single_p}}">
|
| 359 |
</p>
|
| 360 |
<p class="form-field">
|
| 361 |
<label><?php esc_html_e('Show Field for Product', 'woocommerce-checkout-manager'); ?></label>
|
| 362 |
+
<input class="short" type="text" name="single_px" placeholder="<?php esc_html_e('Product ID(s) e.g 1674||1233', 'woocommerce-checkout-manager'); ?>" value="{{data.single_px}}">
|
| 363 |
</p>
|
| 364 |
+
</div>
|
| 365 |
+
|
| 366 |
+
<div class="options_group">
|
| 367 |
<p class="form-field">
|
| 368 |
<label><?php esc_html_e('Hide Field from Category', 'woocommerce-checkout-manager'); ?></label>
|
| 369 |
+
<input class="short" type="text" name="single_p_cat" placeholder="<?php esc_html_e('Category Slug(s) e.g my-cat||my-cat2', 'woocommerce-checkout-manager'); ?>" value="{{data.single_p_cat}}">
|
| 370 |
</p>
|
| 371 |
<p class="form-field">
|
| 372 |
<label><?php esc_html_e('Show Field for Category', 'woocommerce-checkout-manager'); ?></label>
|
| 373 |
+
<input class="short" type="text" name="single_px_cat" placeholder="<?php esc_html_e('Category Slug(s) e.g my-cat||my-cat2', 'woocommerce-checkout-manager'); ?>" value="{{data.sigle_px_cat}}">
|
| 374 |
</p>
|
| 375 |
</div>
|
| 376 |
</div>
|
| 465 |
</div>
|
| 466 |
|
| 467 |
</div>
|
| 468 |
+
<div id="advanced_panel" class="panel woocommerce_options_panel hidden" style="display: none;">
|
| 469 |
+
<div class="options_group">
|
| 470 |
+
<p class="form-field">
|
| 471 |
+
<label><?php esc_html_e('Listable', 'woocommerce-checkout-manager'); ?></label>
|
| 472 |
+
<input <# if ( data.clear_row == 'true' ) { #>checked<# } #> type="checkbox" name="listable" value="listable">
|
| 473 |
+
<span class="description"><?php esc_html_e('Display in View Orders screen ', 'woocommerce-checkout-manager'); ?></span>
|
| 474 |
+
</p>
|
| 475 |
+
<p class="form-field">
|
| 476 |
+
<label><?php esc_html_e('Sortable', 'woocommerce-checkout-manager'); ?></label>
|
| 477 |
+
<input <# if ( data.clear_row == 'true' ) { #>checked<# } #> type="checkbox" name="sortable" value="sortable">
|
| 478 |
+
<span class="description"><?php esc_html_e('Allow Sorting on View Orders screen', 'woocommerce-checkout-manager'); ?></span>
|
| 479 |
+
</p>
|
| 480 |
+
<p class="form-field">
|
| 481 |
+
<label><?php esc_html_e('Filterable', 'woocommerce-checkout-manager'); ?></label>
|
| 482 |
+
<input <# if ( data.clear_row == 'true' ) { #>checked<# } #> type="checkbox" name="filterable" value="filterable">
|
| 483 |
+
<span class="description"><?php esc_html_e('Allow Filtering on View Orders screen', 'woocommerce-checkout-manager'); ?></span>
|
| 484 |
+
</p>
|
| 485 |
+
</div>
|
| 486 |
+
</div>
|
| 487 |
<div id="marketplace_suggestions" class="panel woocommerce_options_panel hidden" style="display: none;">
|
| 488 |
<div class="marketplace-suggestions-container showing-suggestion" data-marketplace-suggestions-context="product-edit-meta-tab-header">
|
| 489 |
<div class="marketplace-suggestion-container" data-suggestion-slug="product-edit-meta-tab-header">
|
| 593 |
<p class="description"><?php esc_html_e('Label text for the checkout field.', 'woocommerce-checkout-manager'); ?></p>
|
| 594 |
<label class="setting" data-setting="placeholder">
|
| 595 |
<span class="name"><?php esc_html_e('Placeholder', 'woocommerce-checkout-manager'); ?></span>
|
| 596 |
+
<input type="text" name="placeholder" placeholder="<?php esc_html_e('Example red', 'woocommerce-checkout-manager'); ?>" value="{{data.placeholder}}">
|
| 597 |
</label>
|
| 598 |
<p class="description"><?php esc_html_e('Placeholder text for the checkout field.', 'woocommerce-checkout-manager'); ?></p>
|
| 599 |
<label class="setting" data-setting="position">
|
new/checkout.php
CHANGED
|
@@ -5,52 +5,62 @@ if (!class_exists('WOOCCM_Checkout')) {
|
|
| 5 |
|
| 6 |
protected static $instance;
|
| 7 |
|
| 8 |
-
function
|
| 9 |
|
| 10 |
-
if (!
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 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 |
|
|
@@ -92,7 +102,7 @@ if (!class_exists('WOOCCM_Checkout')) {
|
|
| 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 |
|
| 5 |
|
| 6 |
protected static $instance;
|
| 7 |
|
| 8 |
+
protected function process_uploads($files, $key, $post_id = 0) {
|
| 9 |
|
| 10 |
+
if (!function_exists('media_handle_upload')) {
|
| 11 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
| 12 |
+
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
| 13 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
| 14 |
+
}
|
| 15 |
|
| 16 |
+
$attachment_ids = array();
|
| 17 |
|
| 18 |
+
add_filter('upload_dir', function( $param ) {
|
| 19 |
+
$param['path'] = sprintf('%s/wooccm_uploads', $param['basedir']);
|
| 20 |
+
$param['url'] = sprintf('%s/wooccm_uploads', $param['baseurl']);
|
| 21 |
+
return $param;
|
| 22 |
+
}, 10);
|
| 23 |
|
| 24 |
+
foreach ($files['name'] as $id => $value) {
|
| 25 |
+
|
| 26 |
+
if ($files['name'][$id]) {
|
| 27 |
+
|
| 28 |
+
$_FILES[$key] = array(
|
| 29 |
+
'name' => $files['name'][$id],
|
| 30 |
+
'type' => $files['type'][$id],
|
| 31 |
+
'tmp_name' => $files['tmp_name'][$id],
|
| 32 |
+
'error' => $files['error'][$id],
|
| 33 |
+
'size' => $files['size'][$id]
|
| 34 |
+
);
|
| 35 |
+
|
| 36 |
+
if (!is_wp_error($attachment_id = media_handle_upload($key, $post_id))) {
|
| 37 |
+
$attachment_ids[] = $attachment_id;
|
| 38 |
+
} else {
|
| 39 |
+
wc_add_notice($attachment_id->get_error_message(), 'error');
|
| 40 |
+
wp_send_json_error($attachment_id->get_error_message());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
return $attachment_ids;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function ajax_checkout_attachment_upload() {
|
| 49 |
+
|
| 50 |
+
if (!empty($_REQUEST) && check_admin_referer('wooccm_checkout_attachment_upload', 'nonce')) {
|
| 51 |
+
|
| 52 |
+
$files = ( isset($_FILES['wooccm_checkout_attachment_upload']) ? $_FILES['wooccm_checkout_attachment_upload'] : false );
|
| 53 |
+
|
| 54 |
+
if (empty($files)) {
|
| 55 |
+
wc_add_notice(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'), 'error');
|
| 56 |
+
wp_send_json_error();
|
| 57 |
+
}
|
| 58 |
|
| 59 |
+
if (count($attachment_ids = $this->process_uploads($files, 'wooccm_checkout_attachment_upload'))) {
|
| 60 |
wp_send_json_success($attachment_ids);
|
| 61 |
}
|
| 62 |
+
wc_add_notice(esc_html__('Unknow error.', 'woocommerce-checkout-manager'), 'error');
|
| 63 |
+
wp_send_json_error();
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 102 |
}
|
| 103 |
}
|
| 104 |
|
| 105 |
+
function checkout_billing_attachment_update_ids($order_id = 0) {
|
| 106 |
$this->checkout_attachment_update_ids($order_id, 'wccs_settings3', 'billing_buttons', 'billing_');
|
| 107 |
}
|
| 108 |
|
new/fields_additional.php
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
if (!class_exists('WOOCCM_Fields_Additional')) {
|
| 4 |
+
|
| 5 |
+
class WOOCCM_Fields_Additional extends 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_fields_required($fields, $name, $key, $prefix = '') {
|
| 24 |
+
|
| 25 |
+
if ($options = get_option($name)) {
|
| 26 |
+
|
| 27 |
+
if (array_key_exists($key, $options)) {
|
| 28 |
+
|
| 29 |
+
if ($custom_fields = $options[$key]) {
|
| 30 |
+
|
| 31 |
+
foreach ($custom_fields as $id => $custom_field) {
|
| 32 |
+
|
| 33 |
+
$key = sprintf("%s%s", $prefix, $custom_field['cow']);
|
| 34 |
+
|
| 35 |
+
$custom_field = $this->add_checkout_field_filter($key, $custom_fields, $custom_field);
|
| 36 |
+
|
| 37 |
+
if (!empty($custom_field['required']) && !empty($custom_field['cow']) && empty($custom_field['deny_checkout'])) {
|
| 38 |
+
|
| 39 |
+
if (empty($_POST[$custom_field['cow']])) {
|
| 40 |
+
$message = sprintf(__('%s is a required field.', 'woocommerce-checkout-manager'), '<strong>' . wooccm_wpml_string($custom_field['label']) . '</strong>');
|
| 41 |
+
wc_add_notice($message, 'error');
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return $fields;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
function add_checkout_additional_required($fields) {
|
| 53 |
+
return $this->add_checkout_fields_required($fields, 'wccs_settings', 'buttons');
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function add_checkout_additional_fields($checkout) {
|
| 57 |
+
|
| 58 |
+
if ($options = get_option('wccs_settings')) {
|
| 59 |
+
|
| 60 |
+
if (array_key_exists('buttons', $options)) {
|
| 61 |
+
|
| 62 |
+
if ($buttons = $options['buttons']) {
|
| 63 |
+
|
| 64 |
+
foreach ($buttons as $key => $custom_field) {
|
| 65 |
+
woocommerce_form_field($custom_field['cow'], $this->add_checkout_field_filter($key, $custom_field, $custom_field), $checkout->get_value($custom_field['cow']));
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
function init() {
|
| 73 |
+
add_action('woocommerce_checkout_process', array($this, 'add_checkout_additional_required'));
|
| 74 |
+
|
| 75 |
+
// Additional fields
|
| 76 |
+
// -----------------------------------------------------------------------
|
| 77 |
+
switch ($this->get_positioning()) {
|
| 78 |
+
case 'before_shipping_form':
|
| 79 |
+
add_action('woocommerce_before_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
|
| 80 |
+
break;
|
| 81 |
+
|
| 82 |
+
case 'after_shipping_form':
|
| 83 |
+
add_action('woocommerce_after_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
|
| 84 |
+
break;
|
| 85 |
+
|
| 86 |
+
case 'before_billing_form':
|
| 87 |
+
add_action('woocommerce_before_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
|
| 88 |
+
break;
|
| 89 |
+
|
| 90 |
+
case 'after_billing_form':
|
| 91 |
+
add_action('woocommerce_after_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
|
| 92 |
+
break;
|
| 93 |
+
|
| 94 |
+
case 'after_order_notes':
|
| 95 |
+
add_action('woocommerce_after_order_notes', array($this, 'add_checkout_additional_fields'));
|
| 96 |
+
break;
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
public static function instance() {
|
| 101 |
+
if (!isset(self::$instance)) {
|
| 102 |
+
self::$instance = new self();
|
| 103 |
+
self::$instance->init();
|
| 104 |
+
}
|
| 105 |
+
return self::$instance;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
WOOCCM_Fields_Additional::instance();
|
| 111 |
+
}
|
new/fields_display.php
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
if (!class_exists('WOOCCM_Fields_Display')) {
|
| 4 |
+
|
| 5 |
+
class WOOCCM_Fields_Display {
|
| 6 |
+
|
| 7 |
+
protected static $instance;
|
| 8 |
+
|
| 9 |
+
function disable_by_role($field, $key) {
|
| 10 |
+
|
| 11 |
+
global $current_user;
|
| 12 |
+
|
| 13 |
+
$user_roles = $current_user->roles;
|
| 14 |
+
|
| 15 |
+
$user_role = array_shift($user_roles);
|
| 16 |
+
|
| 17 |
+
if (!empty($field['user_role']) && (!empty($field['role_options']) || !empty($field['role_options2']))) {
|
| 18 |
+
|
| 19 |
+
$rolekeys = explode('||', $field['role_options']);
|
| 20 |
+
|
| 21 |
+
$rolekeys2 = explode('||', $field['role_options2']);
|
| 22 |
+
|
| 23 |
+
if (!empty($field['role_options']) && !in_array($user_role, $rolekeys)) {
|
| 24 |
+
$field['disabled'] = true;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
if (!empty($field['role_options2']) && in_array($user_role, $rolekeys2)) {
|
| 28 |
+
$field['disabled'] = true;
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return $field;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function disable_by_category($field, $key) {
|
| 36 |
+
|
| 37 |
+
if (empty($field['disabled']) && (!empty($field['single_p_cat']) || !empty($field['single_px_cat']))) {
|
| 38 |
+
|
| 39 |
+
if (count($cart_contents = WC()->cart->get_cart_contents())) {
|
| 40 |
+
|
| 41 |
+
$hide_cats_array = (array) explode(',', @$field['single_p_cat']);
|
| 42 |
+
|
| 43 |
+
$show_cats_array = (array) explode('||', @$field['single_px_cat']);
|
| 44 |
+
|
| 45 |
+
$product_cats = array();
|
| 46 |
+
|
| 47 |
+
foreach ($cart_contents as $key => $values) {
|
| 48 |
+
if ($cats = wp_get_post_terms($values['product_id'], 'product_cat', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs'))) {
|
| 49 |
+
$product_cats += $cats;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// field without more
|
| 54 |
+
// -------------------------------------------------------------------
|
| 55 |
+
if (empty($field['more_content']) && count($cart_contents) < 2) {
|
| 56 |
+
// hide field
|
| 57 |
+
// -----------------------------------------------------------------
|
| 58 |
+
if (!empty($field['single_p_cat'])) {
|
| 59 |
+
if (array_intersect($product_cats, $hide_cats_array)) {
|
| 60 |
+
$field['disabled'] = true;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// show field
|
| 65 |
+
// -----------------------------------------------------------------
|
| 66 |
+
if (!empty($field['single_px_cat'])) {
|
| 67 |
+
if (array_intersect($product_cats, $show_cats_array)) {
|
| 68 |
+
$field['disabled'] = false;
|
| 69 |
+
} else {
|
| 70 |
+
$field['disabled'] = true;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// field with more
|
| 76 |
+
// -------------------------------------------------------------------
|
| 77 |
+
if (!empty($field['more_content'])) {
|
| 78 |
+
|
| 79 |
+
// hide field
|
| 80 |
+
// -------------------------------------------------------------
|
| 81 |
+
if (!empty($field['single_p_cat'])) {
|
| 82 |
+
if (array_intersect($product_cats, $hide_cats_array)) {
|
| 83 |
+
$field['disabled'] = true;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// show field
|
| 88 |
+
// ---------------------------------------------------------------
|
| 89 |
+
if (!empty($field['single_px_cat'])) {
|
| 90 |
+
if (array_intersect($product_cats, $show_cats_array)) {
|
| 91 |
+
$field['disabled'] = false;
|
| 92 |
+
} else {
|
| 93 |
+
//error_log('disabled 4');
|
| 94 |
+
$field['disabled'] = true;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
return $field;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function disable_by_product($field, $key) {
|
| 105 |
+
|
| 106 |
+
if (empty($field['disabled']) && (!empty($field['single_p']) || !empty($field['single_px']))) {
|
| 107 |
+
|
| 108 |
+
if (count($cart_contents = WC()->cart->get_cart_contents())) {
|
| 109 |
+
|
| 110 |
+
$hide_ids_array = (array) explode(',', @$field['single_p']);
|
| 111 |
+
|
| 112 |
+
$show_ids_array = (array) explode('||', @$field['single_px']);
|
| 113 |
+
|
| 114 |
+
$product_ids = array_column($cart_contents, 'product_id');
|
| 115 |
+
|
| 116 |
+
// field without more
|
| 117 |
+
// -------------------------------------------------------------------
|
| 118 |
+
if (empty($field['more_content']) && count($cart_contents) < 2) {
|
| 119 |
+
// hide field
|
| 120 |
+
// -----------------------------------------------------------------
|
| 121 |
+
if (!empty($field['single_p'])) {
|
| 122 |
+
if (array_intersect($product_ids, $hide_ids_array)) {
|
| 123 |
+
$field['disabled'] = true;
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// show field
|
| 128 |
+
// -----------------------------------------------------------------
|
| 129 |
+
if (!empty($field['single_px'])) {
|
| 130 |
+
if (array_intersect($product_ids, $show_ids_array)) {
|
| 131 |
+
$field['disabled'] = false;
|
| 132 |
+
} else {
|
| 133 |
+
$field['disabled'] = true;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// field with more
|
| 139 |
+
// -------------------------------------------------------------------
|
| 140 |
+
if (!empty($field['more_content'])) {
|
| 141 |
+
|
| 142 |
+
// hide field
|
| 143 |
+
// -------------------------------------------------------------
|
| 144 |
+
if (!empty($field['single_p'])) {
|
| 145 |
+
if (array_intersect($product_ids, $hide_ids_array)) {
|
| 146 |
+
$field['disabled'] = true;
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
// show field
|
| 151 |
+
// ---------------------------------------------------------------
|
| 152 |
+
if (!empty($field['single_px'])) {
|
| 153 |
+
if (array_intersect($product_ids, $show_ids_array)) {
|
| 154 |
+
$field['disabled'] = false;
|
| 155 |
+
} else {
|
| 156 |
+
//error_log('disabled 4');
|
| 157 |
+
$field['disabled'] = true;
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
return $field;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
function init() {
|
| 168 |
+
|
| 169 |
+
// Remove by product
|
| 170 |
+
add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_product'), 10, 2);
|
| 171 |
+
|
| 172 |
+
// Remove by category
|
| 173 |
+
add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_category'), 10, 2);
|
| 174 |
+
|
| 175 |
+
// Remove by role
|
| 176 |
+
add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_role'), 10, 2);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
public static function instance() {
|
| 180 |
+
if (!isset(self::$instance)) {
|
| 181 |
+
self::$instance = new self();
|
| 182 |
+
self::$instance->init();
|
| 183 |
+
}
|
| 184 |
+
return self::$instance;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
WOOCCM_Fields_Display::instance();
|
| 190 |
+
}
|
new/fields_handler.php
CHANGED
|
@@ -7,173 +7,17 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
|
|
| 7 |
protected static $instance;
|
| 8 |
protected static $i = 0;
|
| 9 |
|
| 10 |
-
function disable_by_category($field, $key) {
|
| 11 |
-
|
| 12 |
-
if (empty($field['disabled']) && (!empty($field['single_p_cat']) || !empty($field['single_px_cat']))) {
|
| 13 |
-
|
| 14 |
-
if (count($cart_contents = WC()->cart->get_cart_contents())) {
|
| 15 |
-
|
| 16 |
-
$hide_cats_array = (array) explode(',', @$field['single_p_cat']);
|
| 17 |
-
|
| 18 |
-
$show_cats_array = (array) explode('||', @$field['single_px_cat']);
|
| 19 |
-
|
| 20 |
-
$product_cats = array();
|
| 21 |
-
|
| 22 |
-
foreach ($cart_contents as $key => $values) {
|
| 23 |
-
if ($cats = wp_get_post_terms($values['product_id'], 'product_cat', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs'))) {
|
| 24 |
-
$product_cats += $cats;
|
| 25 |
-
}
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
// field without more
|
| 29 |
-
// -------------------------------------------------------------------
|
| 30 |
-
if (empty($field['more_content']) && count($cart_contents) < 2) {
|
| 31 |
-
// hide field
|
| 32 |
-
// -----------------------------------------------------------------
|
| 33 |
-
if (!empty($field['single_p_cat'])) {
|
| 34 |
-
if (array_intersect($product_cats, $hide_cats_array)) {
|
| 35 |
-
$field['disabled'] = true;
|
| 36 |
-
}
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
// show field
|
| 40 |
-
// -----------------------------------------------------------------
|
| 41 |
-
if (!empty($field['single_px_cat'])) {
|
| 42 |
-
if (array_intersect($product_cats, $show_cats_array)) {
|
| 43 |
-
$field['disabled'] = false;
|
| 44 |
-
} else {
|
| 45 |
-
$field['disabled'] = true;
|
| 46 |
-
}
|
| 47 |
-
}
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
// field with more
|
| 51 |
-
// -------------------------------------------------------------------
|
| 52 |
-
if (!empty($field['more_content'])) {
|
| 53 |
-
|
| 54 |
-
// hide field
|
| 55 |
-
// -------------------------------------------------------------
|
| 56 |
-
if (!empty($field['single_p_cat'])) {
|
| 57 |
-
if (array_intersect($product_cats, $hide_cats_array)) {
|
| 58 |
-
$field['disabled'] = true;
|
| 59 |
-
}
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
// show field
|
| 63 |
-
// ---------------------------------------------------------------
|
| 64 |
-
if (!empty($field['single_px_cat'])) {
|
| 65 |
-
if (array_intersect($product_cats, $show_cats_array)) {
|
| 66 |
-
$field['disabled'] = false;
|
| 67 |
-
} else {
|
| 68 |
-
//error_log('disabled 4');
|
| 69 |
-
$field['disabled'] = true;
|
| 70 |
-
}
|
| 71 |
-
}
|
| 72 |
-
}
|
| 73 |
-
}
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
return $field;
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
function disable_by_product($field, $key) {
|
| 80 |
-
|
| 81 |
-
if (empty($field['disabled']) && (!empty($field['single_p']) || !empty($field['single_px']))) {
|
| 82 |
-
|
| 83 |
-
if (count($cart_contents = WC()->cart->get_cart_contents())) {
|
| 84 |
-
|
| 85 |
-
$hide_ids_array = (array) explode(',', @$field['single_p']);
|
| 86 |
-
|
| 87 |
-
$show_ids_array = (array) explode('||', @$field['single_px']);
|
| 88 |
-
|
| 89 |
-
$product_ids = array_column($cart_contents, 'product_id');
|
| 90 |
-
|
| 91 |
-
// field without more
|
| 92 |
-
// -------------------------------------------------------------------
|
| 93 |
-
if (empty($field['more_content']) && count($cart_contents) < 2) {
|
| 94 |
-
// hide field
|
| 95 |
-
// -----------------------------------------------------------------
|
| 96 |
-
if (!empty($field['single_p'])) {
|
| 97 |
-
if (array_intersect($product_ids, $hide_ids_array)) {
|
| 98 |
-
$field['disabled'] = true;
|
| 99 |
-
}
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
// show field
|
| 103 |
-
// -----------------------------------------------------------------
|
| 104 |
-
if (!empty($field['single_px'])) {
|
| 105 |
-
if (array_intersect($product_ids, $show_ids_array)) {
|
| 106 |
-
$field['disabled'] = false;
|
| 107 |
-
} else {
|
| 108 |
-
$field['disabled'] = true;
|
| 109 |
-
}
|
| 110 |
-
}
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
// field with more
|
| 114 |
-
// -------------------------------------------------------------------
|
| 115 |
-
if (!empty($field['more_content'])) {
|
| 116 |
-
|
| 117 |
-
// hide field
|
| 118 |
-
// -------------------------------------------------------------
|
| 119 |
-
if (!empty($field['single_p'])) {
|
| 120 |
-
if (array_intersect($product_ids, $hide_ids_array)) {
|
| 121 |
-
$field['disabled'] = true;
|
| 122 |
-
}
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
// show field
|
| 126 |
-
// ---------------------------------------------------------------
|
| 127 |
-
if (!empty($field['single_px'])) {
|
| 128 |
-
if (array_intersect($product_ids, $show_ids_array)) {
|
| 129 |
-
$field['disabled'] = false;
|
| 130 |
-
} else {
|
| 131 |
-
//error_log('disabled 4');
|
| 132 |
-
$field['disabled'] = true;
|
| 133 |
-
}
|
| 134 |
-
}
|
| 135 |
-
}
|
| 136 |
-
}
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
return $field;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
function remove_checkout_fields($fields) {
|
| 143 |
|
| 144 |
-
global $current_user;
|
| 145 |
-
|
| 146 |
-
$user_roles = $current_user->roles;
|
| 147 |
-
|
| 148 |
-
$user_role = array_shift($user_roles);
|
| 149 |
-
|
| 150 |
foreach ($fields as $key => $type) {
|
| 151 |
|
| 152 |
foreach ($type as $id => $field) {
|
| 153 |
-
|
| 154 |
//var_dump($field);
|
| 155 |
// Remove disabled
|
| 156 |
// -------------------------------------------------------------------
|
| 157 |
if (!empty($field['disabled'])) {
|
| 158 |
unset($fields[$key][$id]);
|
| 159 |
}
|
| 160 |
-
// Remove based on roles
|
| 161 |
-
// -------------------------------------------------------------------
|
| 162 |
-
|
| 163 |
-
if (!empty($field['user_role']) && (!empty($field['role_options']) || !empty($field['role_options2']))) {
|
| 164 |
-
|
| 165 |
-
$rolekeys = explode('||', $field['role_options']);
|
| 166 |
-
|
| 167 |
-
$rolekeys2 = explode('||', $field['role_options2']);
|
| 168 |
-
|
| 169 |
-
if (!empty($field['role_options']) && !in_array($user_role, $rolekeys)) {
|
| 170 |
-
unset($fields[$key][$id]);
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
if (!empty($field['role_options2']) && in_array($user_role, $rolekeys2)) {
|
| 174 |
-
unset($fields[$key][$id]);
|
| 175 |
-
}
|
| 176 |
-
}
|
| 177 |
}
|
| 178 |
}
|
| 179 |
|
|
@@ -219,11 +63,6 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
|
|
| 219 |
|
| 220 |
function init() {
|
| 221 |
|
| 222 |
-
// Remove by product
|
| 223 |
-
add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_product'), 10, 2);
|
| 224 |
-
|
| 225 |
-
// Remove by category
|
| 226 |
-
add_filter('wooccm_checkout_field_filter', array($this, 'disable_by_category'), 10, 2);
|
| 227 |
// Remove fields
|
| 228 |
// -----------------------------------------------------------------------
|
| 229 |
add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
|
| 7 |
protected static $instance;
|
| 8 |
protected static $i = 0;
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
function remove_checkout_fields($fields) {
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
foreach ($fields as $key => $type) {
|
| 13 |
|
| 14 |
foreach ($type as $id => $field) {
|
|
|
|
| 15 |
//var_dump($field);
|
| 16 |
// Remove disabled
|
| 17 |
// -------------------------------------------------------------------
|
| 18 |
if (!empty($field['disabled'])) {
|
| 19 |
unset($fields[$key][$id]);
|
| 20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 63 |
|
| 64 |
function init() {
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
// Remove fields
|
| 67 |
// -----------------------------------------------------------------------
|
| 68 |
add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
|
new/fields_register.php
CHANGED
|
@@ -5,21 +5,6 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 5 |
class WOOCCM_Fields_Register {
|
| 6 |
|
| 7 |
protected static $instance;
|
| 8 |
-
protected static $i = 0;
|
| 9 |
-
|
| 10 |
-
function get_positioning($position = 'after_order_notes') {
|
| 11 |
-
|
| 12 |
-
if ($options = get_option('wccs_settings')) {
|
| 13 |
-
|
| 14 |
-
if (!empty($options['checkness']['position'])) {
|
| 15 |
-
$position = sanitize_text_field($options['checkness']['position']);
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
return $position;
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
return false;
|
| 22 |
-
}
|
| 23 |
|
| 24 |
function add_checkout_field_filter($key, $fields, $custom_field) {
|
| 25 |
|
|
@@ -202,22 +187,6 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 202 |
return $fields;
|
| 203 |
}
|
| 204 |
|
| 205 |
-
function add_checkout_additional_fields($checkout) {
|
| 206 |
-
|
| 207 |
-
if ($options = get_option('wccs_settings')) {
|
| 208 |
-
|
| 209 |
-
if (array_key_exists('buttons', $options)) {
|
| 210 |
-
|
| 211 |
-
if ($buttons = $options['buttons']) {
|
| 212 |
-
|
| 213 |
-
foreach ($buttons as $key => $custom_field) {
|
| 214 |
-
woocommerce_form_field($custom_field['cow'], $this->add_checkout_field_filter($key, $custom_field, $custom_field), $checkout->get_value($custom_field['cow']));
|
| 215 |
-
}
|
| 216 |
-
}
|
| 217 |
-
}
|
| 218 |
-
}
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
function add_checkout_shipping_fields($fields) {
|
| 222 |
return $this->add_checkout_fields_filter($fields, 'wccs_settings2', 'shipping_buttons', 'shipping_');
|
| 223 |
}
|
|
@@ -236,29 +205,6 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 236 |
// -----------------------------------------------------------------------
|
| 237 |
add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
|
| 238 |
|
| 239 |
-
// Additional fields
|
| 240 |
-
// -----------------------------------------------------------------------
|
| 241 |
-
switch ($this->get_positioning()) {
|
| 242 |
-
case 'before_shipping_form':
|
| 243 |
-
add_action('woocommerce_before_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
|
| 244 |
-
break;
|
| 245 |
-
|
| 246 |
-
case 'after_shipping_form':
|
| 247 |
-
add_action('woocommerce_after_checkout_shipping_form', array($this, 'add_checkout_additional_fields'));
|
| 248 |
-
break;
|
| 249 |
-
|
| 250 |
-
case 'before_billing_form':
|
| 251 |
-
add_action('woocommerce_before_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
|
| 252 |
-
break;
|
| 253 |
-
|
| 254 |
-
case 'after_billing_form':
|
| 255 |
-
add_action('woocommerce_after_checkout_billing_form', array($this, 'add_checkout_additional_fields'));
|
| 256 |
-
break;
|
| 257 |
-
|
| 258 |
-
case 'after_order_notes':
|
| 259 |
-
add_action('woocommerce_after_order_notes', array($this, 'add_checkout_additional_fields'));
|
| 260 |
-
break;
|
| 261 |
-
}
|
| 262 |
}
|
| 263 |
|
| 264 |
public static function instance() {
|
| 5 |
class WOOCCM_Fields_Register {
|
| 6 |
|
| 7 |
protected static $instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
function add_checkout_field_filter($key, $fields, $custom_field) {
|
| 10 |
|
| 187 |
return $fields;
|
| 188 |
}
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
function add_checkout_shipping_fields($fields) {
|
| 191 |
return $this->add_checkout_fields_filter($fields, 'wccs_settings2', 'shipping_buttons', 'shipping_');
|
| 192 |
}
|
| 205 |
// -----------------------------------------------------------------------
|
| 206 |
add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
public static function instance() {
|
new/fields_required.php
DELETED
|
@@ -1,66 +0,0 @@
|
|
| 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/install.php
CHANGED
|
@@ -127,7 +127,7 @@ if (!class_exists('WOOCCM_Install')) {
|
|
| 127 |
|
| 128 |
function woocommerce() {
|
| 129 |
self::field_defaults();
|
| 130 |
-
var_dump(apply_filters('woocommerce_billing_fields', WC()->countries->get_default_address_fields()));
|
| 131 |
}
|
| 132 |
|
| 133 |
function init() {
|
| 127 |
|
| 128 |
function woocommerce() {
|
| 129 |
self::field_defaults();
|
| 130 |
+
//var_dump(apply_filters('woocommerce_billing_fields', WC()->countries->get_default_address_fields()));
|
| 131 |
}
|
| 132 |
|
| 133 |
function init() {
|
new/orders.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
if (!class_exists('WOOCCM_Orders')) {
|
| 4 |
|
| 5 |
-
class WOOCCM_Orders {
|
| 6 |
|
| 7 |
protected static $instance;
|
| 8 |
|
|
@@ -32,10 +32,11 @@ if (!class_exists('WOOCCM_Orders')) {
|
|
| 32 |
|
| 33 |
if (!empty($_REQUEST) && check_admin_referer('wooccm_admin', 'nonce')) {
|
| 34 |
|
| 35 |
-
$
|
| 36 |
|
| 37 |
-
if (empty($
|
| 38 |
-
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
$order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
|
|
@@ -48,40 +49,7 @@ if (!class_exists('WOOCCM_Orders')) {
|
|
| 48 |
wp_send_json_error(esc_html__('Invalid order id.', 'woocommerce-checkout-manager'));
|
| 49 |
}
|
| 50 |
|
| 51 |
-
|
| 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 |
|
|
@@ -123,6 +91,7 @@ if (!class_exists('WOOCCM_Orders')) {
|
|
| 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 |
|
| 2 |
|
| 3 |
if (!class_exists('WOOCCM_Orders')) {
|
| 4 |
|
| 5 |
+
class WOOCCM_Orders extends WOOCCM_Checkout {
|
| 6 |
|
| 7 |
protected static $instance;
|
| 8 |
|
| 32 |
|
| 33 |
if (!empty($_REQUEST) && check_admin_referer('wooccm_admin', 'nonce')) {
|
| 34 |
|
| 35 |
+
$files = ( isset($_FILES['wooccm_order_attachment_upload']) ? $_FILES['wooccm_order_attachment_upload'] : false );
|
| 36 |
|
| 37 |
+
if (empty($files)) {
|
| 38 |
+
//wc_add_notice(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'), 'error');
|
| 39 |
+
wp_send_json_error(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'), 'error');
|
| 40 |
}
|
| 41 |
|
| 42 |
$order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
|
| 49 |
wp_send_json_error(esc_html__('Invalid order id.', 'woocommerce-checkout-manager'));
|
| 50 |
}
|
| 51 |
|
| 52 |
+
if (count($attachment_ids = $this->process_uploads($files, 'wooccm_order_attachment_upload', $order_id))) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
ob_start();
|
| 55 |
|
| 91 |
$mailer->send($email_recipients, strip_tags($subject), $message);
|
| 92 |
// remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' ); */
|
| 93 |
}
|
| 94 |
+
wp_send_json_error(esc_html__('Unknow error.', 'woocommerce-checkout-manager'));
|
| 95 |
}
|
| 96 |
}
|
| 97 |
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/
|
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 5.2.3
|
| 7 |
-
Stable tag: 4.4.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -137,6 +137,11 @@ Example:
|
|
| 137 |
|
| 138 |
== Changelog ==
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
= 4.4.3 =
|
| 141 |
* Fix: woocommerce checkout hide field based on product id rebuilt
|
| 142 |
* Fix: woocommerce checkout hide field based on product category rebuilt
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 5.2.3
|
| 7 |
+
Stable tag: 4.4.4
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 137 |
|
| 138 |
== Changelog ==
|
| 139 |
|
| 140 |
+
= 4.4.4 =
|
| 141 |
+
* Fix: small CSS changes
|
| 142 |
+
* Fix: security issue related with upload files types
|
| 143 |
+
* Improvement: woocommerce checkout upload rebuilt
|
| 144 |
+
|
| 145 |
= 4.4.3 =
|
| 146 |
* Fix: woocommerce checkout hide field based on product id rebuilt
|
| 147 |
* Fix: woocommerce checkout hide field based on product category rebuilt
|
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.4.
|
| 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.4.
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 22 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
|
@@ -148,6 +148,32 @@ if (!class_exists('WOOCCM')) {
|
|
| 148 |
<?php
|
| 149 |
}
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
function add_action_links($links) {
|
| 152 |
|
| 153 |
$links[] = '<a target="_blank" href="' . WOOCCM_SUPPORT_URL . '">' . esc_html__('Support', 'woocommerce-checkout-manager') . '</a>';
|
|
@@ -185,11 +211,24 @@ if (!class_exists('WOOCCM')) {
|
|
| 185 |
|
| 186 |
wp_register_script('wooccm-order-upload', plugins_url('assets/js/wooccm-order-upload.js', WOOCCM_PLUGIN_FILE), array('wooccm-admin'), WOOCCM_PLUGIN_VERSION, true);
|
| 187 |
|
| 188 |
-
wp_register_script('wooccm-checkout
|
| 189 |
|
| 190 |
-
wp_localize_script('wooccm-checkout
|
| 191 |
'ajaxurl' => admin_url('admin-ajax.php'),
|
| 192 |
'nonce' => wp_create_nonce('wooccm_checkout_attachment_upload'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
'uploading' => esc_html__('Uploading, please wait...', 'woocommerce-checkout-manager'),
|
| 194 |
'saving' => esc_html__('Saving, please wait...', 'woocommerce-checkout-manager'),
|
| 195 |
'success' => esc_html__('Files uploaded successfully.', 'woocommerce-checkout-manager'),
|
|
@@ -251,7 +290,7 @@ if (!class_exists('WOOCCM')) {
|
|
| 251 |
|
| 252 |
if (is_checkout()) {
|
| 253 |
|
| 254 |
-
wp_enqueue_script('wooccm-checkout
|
| 255 |
|
| 256 |
// UI
|
| 257 |
// ---------------------------------------------------------------------
|
|
@@ -343,9 +382,11 @@ if (!class_exists('WOOCCM')) {
|
|
| 343 |
include( WOOCCM_PLUGIN_DIR . 'new/checkout.php' );
|
| 344 |
include( WOOCCM_PLUGIN_DIR . 'new/orders.php' );
|
| 345 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_register.php' );
|
| 346 |
-
include( WOOCCM_PLUGIN_DIR . 'new/
|
|
|
|
| 347 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_handler.php' );
|
| 348 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_filters.php' );
|
|
|
|
| 349 |
}
|
| 350 |
|
| 351 |
function init() {
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce Checkout Manager
|
| 4 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
| 5 |
+
* Version: 4.4.4
|
| 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.4.4');
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 22 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
| 148 |
<?php
|
| 149 |
}
|
| 150 |
|
| 151 |
+
protected function get_mime_types() {
|
| 152 |
+
|
| 153 |
+
$extensions = $types = array();
|
| 154 |
+
|
| 155 |
+
$allowed_types = get_allowed_mime_types();
|
| 156 |
+
|
| 157 |
+
// break the allowed extensions into their respective types
|
| 158 |
+
foreach ($allowed_types as $allowed_extensions => $type) {
|
| 159 |
+
|
| 160 |
+
$type = substr($type, 0, strpos($type, '/'));
|
| 161 |
+
|
| 162 |
+
$extensions[$type][] = str_replace('|', ',', $allowed_extensions);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// format the extensions for plupload
|
| 166 |
+
foreach ($extensions as $type => $exts) {
|
| 167 |
+
|
| 168 |
+
$types[] = array(
|
| 169 |
+
'title' => $type,
|
| 170 |
+
'extensions' => implode(',', $exts),
|
| 171 |
+
);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
return apply_filters('wooccm_mime_types', $types);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
function add_action_links($links) {
|
| 178 |
|
| 179 |
$links[] = '<a target="_blank" href="' . WOOCCM_SUPPORT_URL . '">' . esc_html__('Support', 'woocommerce-checkout-manager') . '</a>';
|
| 211 |
|
| 212 |
wp_register_script('wooccm-order-upload', plugins_url('assets/js/wooccm-order-upload.js', WOOCCM_PLUGIN_FILE), array('wooccm-admin'), WOOCCM_PLUGIN_VERSION, true);
|
| 213 |
|
| 214 |
+
wp_register_script('wooccm-checkout', plugins_url('assets/js/wooccm-checkout.js', WOOCCM_PLUGIN_FILE), array('jquery'), WOOCCM_PLUGIN_VERSION, true);
|
| 215 |
|
| 216 |
+
wp_localize_script('wooccm-checkout', 'wooccm', array(
|
| 217 |
'ajaxurl' => admin_url('admin-ajax.php'),
|
| 218 |
'nonce' => wp_create_nonce('wooccm_checkout_attachment_upload'),
|
| 219 |
+
'limit' => array(
|
| 220 |
+
'max_file_size' => wp_max_upload_size(),
|
| 221 |
+
'max_files' => 4,
|
| 222 |
+
//'mime_types' => $this->get_mime_types(),
|
| 223 |
+
),
|
| 224 |
+
'icons' => array(
|
| 225 |
+
'interactive' => site_url('wp-includes/images/media/interactive.png'),
|
| 226 |
+
'spreadsheet' => site_url('wp-includes/images/media/spreadsheet.png'),
|
| 227 |
+
'archive' => site_url('wp-includes/images/media/archive.png'),
|
| 228 |
+
'audio' => site_url('wp-includes/images/media/audio.png'),
|
| 229 |
+
'text' => site_url('wp-includes/images/media/text.png'),
|
| 230 |
+
'video' => site_url('wp-includes/images/media/video.png')
|
| 231 |
+
),
|
| 232 |
'uploading' => esc_html__('Uploading, please wait...', 'woocommerce-checkout-manager'),
|
| 233 |
'saving' => esc_html__('Saving, please wait...', 'woocommerce-checkout-manager'),
|
| 234 |
'success' => esc_html__('Files uploaded successfully.', 'woocommerce-checkout-manager'),
|
| 290 |
|
| 291 |
if (is_checkout()) {
|
| 292 |
|
| 293 |
+
wp_enqueue_script('wooccm-checkout');
|
| 294 |
|
| 295 |
// UI
|
| 296 |
// ---------------------------------------------------------------------
|
| 382 |
include( WOOCCM_PLUGIN_DIR . 'new/checkout.php' );
|
| 383 |
include( WOOCCM_PLUGIN_DIR . 'new/orders.php' );
|
| 384 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_register.php' );
|
| 385 |
+
include( WOOCCM_PLUGIN_DIR . 'new/fields_additional.php' );
|
| 386 |
+
include( WOOCCM_PLUGIN_DIR . 'new/fields_display.php' );
|
| 387 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_handler.php' );
|
| 388 |
include( WOOCCM_PLUGIN_DIR . 'new/fields_filters.php' );
|
| 389 |
+
//include( WOOCCM_PLUGIN_DIR . 'new/premium/fields_amount.php' );
|
| 390 |
}
|
| 391 |
|
| 392 |
function init() {
|
