Version Description
- Improvement: woocommerce order fields rebuilt
- Fix: woocommerce conditional fields required
Download this release
Release Info
Developer | quadlayers |
Plugin | WooCommerce Checkout Manager |
Version | 4.5.4 |
Comparing to | |
See all releases |
Code changes from version 4.5.3 to 4.5.4
- assets/css/wooccm.css +3 -0
- assets/css/wooccm.css.map +1 -1
- assets/js/wooccm-checkout.js +8 -3
- assets/js/wooccm-checkout.min.js +1 -1
- assets/less/wooccm.less +4 -0
- includes/admin.php +368 -368
- includes/classes/main.php +1 -276
- includes/formatting.php +1 -71
- includes/functions.php +1 -2
- includes/template.php +0 -442
- includes/templates/functions/required/add_required.php +0 -133
- includes/templates/functions/required/billing_required.php +0 -185
- includes/templates/functions/required/shipping_required.php +0 -156
- new/class-wooccm-admin.php +0 -17
- new/class-wooccm.php +8 -12
- new/controller/{checkout.php → class-wooccm-checkout-controller.php} +0 -0
- new/controller/{class-field-controller.php → class-wooccm-field-controller.php} +105 -15
- new/controller/{order.php → class-wooccm-order-controller.php} +0 -0
- new/controller/{upload.php → class-wooccm-upload-handler.php} +0 -0
- new/model/class-wooccm-field-additional.php +8 -0
- new/model/class-wooccm-field-billing.php +8 -0
- new/model/class-wooccm-field-old.php +6 -4
- new/model/class-wooccm-field-shipping.php +8 -0
- new/model/class-wooccm-field.php +2 -1
- new/view/frontend/checkout.php +7 -0
- new/view/frontend/fields/conditional.php +26 -1
- new/view/frontend/fields/handler.php +2 -2
- new/view/frontend/fields/register.php +4 -4
- new/view/frontend/order.php +0 -1
- readme.txt +5 -1
- templates/checkout/thankyou-fields.php +54 -0
- woocommerce-checkout-manager.php +3 -21
assets/css/wooccm.css
CHANGED
@@ -6,6 +6,9 @@
|
|
6 |
.woocommerce form .wooccm-clearfix:after {
|
7 |
clear: both;
|
8 |
}
|
|
|
|
|
|
|
9 |
.button.fileinput-button {
|
10 |
position: relative;
|
11 |
overflow: hidden!important;
|
6 |
.woocommerce form .wooccm-clearfix:after {
|
7 |
clear: both;
|
8 |
}
|
9 |
+
.woocommerce form .wooccm-conditional-child {
|
10 |
+
display: none;
|
11 |
+
}
|
12 |
.button.fileinput-button {
|
13 |
position: relative;
|
14 |
overflow: hidden!important;
|
assets/css/wooccm.css.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["../less/wooccm.less"],"names":[],"mappings":"AAKI,YALS,KAEX,iBAGG;AACC,YANO,KAEX,iBAIK;EACD,SAAQ,EAAR;EACA,cAAA;;AAEF,YAVS,KAEX,iBAQG;EACC,WAAA;;
|
1 |
+
{"version":3,"sources":["../less/wooccm.less"],"names":[],"mappings":"AAKI,YALS,KAEX,iBAGG;AACC,YANO,KAEX,iBAIK;EACD,SAAQ,EAAR;EACA,cAAA;;AAEF,YAVS,KAEX,iBAQG;EACC,WAAA;;AAXN,YAAa,KAeX;EACE,aAAA;;AAMF,OAAC;EACC,kBAAA;EACA,0BAAA;;AAFF,OAAC,iBAIC;EACE,kBAAA;EACA,MAAA;EACA,QAAA;EACA,SAAA;EACA,UAAA;EACA,YAAW,kBAAX;EACA,gBAAA;EACA,cAAA;EACA,eAAA;;AAMN;EACE,cAAA;EACA,UAAA;EACA,aAAA;EACA,eAAA;EACA,mBAAA;EACA,sBAAA;;AANF,kBAQE;EACE,aAAA;EACA,uBAAA;EACA,oBAAA;EACA,sBAAA;EACA,uBAAA;EACA,UAAA;EAEA,kBAAA;;AAhBJ,kBAQE,mBAWE;EACE,UAAA;EACA,kBAAA;EACA,QAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,sBAAA;EACA,cAAA;EACA,iBAAA;EACA,kBAAA;EACA,cAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;EACA,eAAA;EACA,iBAAA;;AAnCN,kBAQE,mBA8BE;EACE,WAAA;EACA,gBAAA;;AAxCN,kBAQE,mBAmCE;EACE,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,gBAAA;EACA,WAAA;EACA,iBAAA;EACA,kBAAA;EACA,gBAAA;;AAnDN,kBAQE,mBAmCE,mCAUE;EACE,gBAAA;EACA,iBAAA;EACA,kBAAA;EACA,QAAA;EACA,YAAA;EACA,WAAA;EACA,YAAA;;AAEA,kBAtDN,mBAmCE,mCAUE,MASG;EACC,MAAA;EACA,SAAA;EACA,OAAA;EACA,QAAA;EAEA,gBAAA;EACA,YAAA;EACA,WAAA","file":"wooccm.css"}
|
assets/js/wooccm-checkout.js
CHANGED
@@ -282,17 +282,21 @@
|
|
282 |
$('.wooccm-conditional-child').each(function (i, field) {
|
283 |
|
284 |
var $field = $(field),
|
285 |
-
$parent = $('#' + $field.find('[data-conditional-parent]').data('conditional-parent')),
|
286 |
show_if_value = $field.find('[data-conditional-parent-value]').data('conditional-parent-value');
|
287 |
|
288 |
if ($parent.length) {
|
289 |
|
290 |
$parent.on('wooccm_change change keyup', function (e) {
|
291 |
|
292 |
-
|
293 |
-
var $this = $(e.currentTarget).find('input,select,textarea').first(),
|
294 |
value = $this.val();
|
295 |
|
|
|
|
|
|
|
|
|
|
|
296 |
if ($this.prop('type') == 'checkbox') {
|
297 |
value = $this.is(':checked');
|
298 |
}
|
@@ -304,6 +308,7 @@
|
|
304 |
}
|
305 |
|
306 |
$this.off('wooccm_change');
|
|
|
307 |
$this.off('keyup');
|
308 |
|
309 |
});
|
282 |
$('.wooccm-conditional-child').each(function (i, field) {
|
283 |
|
284 |
var $field = $(field),
|
285 |
+
$parent = $('#' + $field.find('[data-conditional-parent]').data('conditional-parent') + '_field'),
|
286 |
show_if_value = $field.find('[data-conditional-parent-value]').data('conditional-parent-value');
|
287 |
|
288 |
if ($parent.length) {
|
289 |
|
290 |
$parent.on('wooccm_change change keyup', function (e) {
|
291 |
|
292 |
+
var $this = $(e.target),
|
|
|
293 |
value = $this.val();
|
294 |
|
295 |
+
// fix for select2 search
|
296 |
+
if ($this.hasClass('select2-selection')) {
|
297 |
+
return;
|
298 |
+
}
|
299 |
+
|
300 |
if ($this.prop('type') == 'checkbox') {
|
301 |
value = $this.is(':checked');
|
302 |
}
|
308 |
}
|
309 |
|
310 |
$this.off('wooccm_change');
|
311 |
+
$this.off('change');
|
312 |
$this.off('keyup');
|
313 |
|
314 |
});
|
assets/js/wooccm-checkout.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(e){var f=function(h){return h.is(".processing")||h.parents(".processing").length};var g=function(h){if(!f(h)){h.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(h){h.removeClass("processing").unblock()};var d=function(n,l,m,h,k){var o=e(n),p;if(k.match("image.*")){p="image"}else{if(k.match("application/ms.*")){m=wooccm_upload.icons.spreadsheet;p="spreadsheet"}else{if(k.match("application/x.*")){m=wooccm_upload.icons.archive;p="application"}else{if(k.match("audio.*")){m=wooccm_upload.icons.audio;p="audio"}else{if(k.match("text.*")){m=wooccm_upload.icons.text;p="text"}else{if(k.match("video.*")){m=wooccm_upload.icons.video;p="video"}else{m=wooccm_upload.icons.interactive;p="interactive"}}}}}}var j='<span data-file_id="'+l+'" title="'+h+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <a title="'+h+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n <span class="wooccmupload_file_image_container">\n <img class="'+p+'" alt="'+h+'" src="'+m+'"/>\n </span>\n </span>\n </span>';o.append(j).fadeIn()};function b(i,h){if(h){i.find("label .optional").remove();i.addClass("validate-required");if(i.find("label .required").length===0){i.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')}}else{i.find("label .required").remove();i.removeClass("validate-required woocommerce-invalid woocommerce-invalid-required-field");if(i.find("label .optional").length===0){i.find("label").append(' <span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>")}}}e(document).on("country_to_state_changing",function(i,k,m){var j=m,h;var l=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(l,function(n,o){var p=j.find(o),q=p.find("[data-required]").data("required")||0;b(p,q)})});var c=[];e(".wooccmupload-field").each(function(j,m){var k=e(m),l=k.find("[type=file]"),h=k.find(".wooccmupload_button"),n=k.find(".wooccmupload_list");c[k.attr("id")]=[];h.on("click",function(i){i.preventDefault();l.trigger("click")});n.on("click",".wooccmupload_file_delete",function(i){e(this).closest(".wooccmupload_file").remove()});l.on("change",function(o){var i=e(this)[0].files;if(i.length){if(window.FileReader){e.each(i,function(q,p){var r=n.find("span[data-file_id]").length+q;if(r>=wooccm_upload.limit.max_files){alert("Exeeds max files limit of "+wooccm_upload.limit.max_files);return false}if(p.size>wooccm_upload.limit.max_file_size){alert("Exeeds max file size of "+wooccm_upload.limit.max_file_size);return true}reader=new FileReader();reader.onload=(function(s){return function(t){setTimeout(function(){d(n,c[k.attr("id")].push(p)-1,t.target.result,s.name,s.type)},200)}})(p);console.log(p.name);reader.readAsDataURL(p)})}}})});e("#order_review").on("ajaxSuccess",function(l){var k=e(l.target),j=k.find("#place_order"),i=e(".wooccmupload-field"),h=i.length;if(h){j.addClass("wooccm-upload-process")}});e(document).on("click","#place_order.wooccm-upload-process",function(l){l.preventDefault();var i=e("form.checkout"),k=e(this),j=e(".wooccmupload-field"),h=j.length;j.each(function(m,p){var n=e(p),r=n.find(".wooccmupload_field"),q=n.find(".wooccmupload_list");if(window.FormData&&c[n.attr("id")].length){if(!f(i)){k.html(wooccm_upload.message.uploading);g(i)}var o=new FormData();q.find("span[data-file_id]").each(function(t,s){var u=e(s).data("file_id");if(t>wooccm_upload.limit.max_files){console.log("Exeeds max files limit of "+wooccm_upload.limit.max_files);return false}if(c[n.attr("id")][u]===undefined){console.log("Undefined "+u);return true}if(c[n.attr("id")][u].size>wooccm_upload.limit.max_file_size){console.log("Exeeds max file size of "+wooccm_upload.limit.max_files);return true}console.log("We're ready to upload "+c[n.attr("id")][u].name);o.append("wooccm_checkout_attachment_upload[]",c[n.attr("id")][u])});o.append("action","wooccm_checkout_attachment_upload");o.append("nonce",wooccm_upload.nonce);e.ajax({async:false,url:wooccm_upload.ajaxurl,type:"POST",cache:false,data:o,processData:false,contentType:false,beforeSend:function(s){},success:function(s){if(s.success){r.val(s.data)}else{e("body").trigger("update_checkout")}},complete:function(s){h=h-1}})}else{h=h-1}if(h==0){a(i);k.removeClass("wooccm-upload-process").trigger("click")}})});e(document).on("change",".wooccm-add-checkout-fees",function(h){e("body").trigger("update_checkout")});e(".wooccm-conditional-child").each(function(h,m){var j=e(m),l=e("#"+j.find("[data-conditional-parent]").data("conditional-parent")),k=j.find("[data-conditional-parent-value]").data("conditional-parent-value");if(l.length){l.on("wooccm_change change keyup",function(o){var n=e(o.
|
1 |
+
(function(e){var f=function(h){return h.is(".processing")||h.parents(".processing").length};var g=function(h){if(!f(h)){h.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}};var a=function(h){h.removeClass("processing").unblock()};var d=function(n,l,m,h,k){var o=e(n),p;if(k.match("image.*")){p="image"}else{if(k.match("application/ms.*")){m=wooccm_upload.icons.spreadsheet;p="spreadsheet"}else{if(k.match("application/x.*")){m=wooccm_upload.icons.archive;p="application"}else{if(k.match("audio.*")){m=wooccm_upload.icons.audio;p="audio"}else{if(k.match("text.*")){m=wooccm_upload.icons.text;p="text"}else{if(k.match("video.*")){m=wooccm_upload.icons.video;p="video"}else{m=wooccm_upload.icons.interactive;p="interactive"}}}}}}var j='<span data-file_id="'+l+'" title="'+h+'" class="wooccmupload_file">\n <span class="wooccmupload_file_container">\n <a title="'+h+'" class="wooccmupload_file_delete" class="wooccm_dele wooccm-btn wooccm-btn-danger">×</a>\n <span class="wooccmupload_file_image_container">\n <img class="'+p+'" alt="'+h+'" src="'+m+'"/>\n </span>\n </span>\n </span>';o.append(j).fadeIn()};function b(i,h){if(h){i.find("label .optional").remove();i.addClass("validate-required");if(i.find("label .required").length===0){i.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')}}else{i.find("label .required").remove();i.removeClass("validate-required woocommerce-invalid woocommerce-invalid-required-field");if(i.find("label .optional").length===0){i.find("label").append(' <span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>")}}}e(document).on("country_to_state_changing",function(i,k,m){var j=m,h;var l=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(l,function(n,o){var p=j.find(o),q=p.find("[data-required]").data("required")||0;b(p,q)})});var c=[];e(".wooccmupload-field").each(function(j,m){var k=e(m),l=k.find("[type=file]"),h=k.find(".wooccmupload_button"),n=k.find(".wooccmupload_list");c[k.attr("id")]=[];h.on("click",function(i){i.preventDefault();l.trigger("click")});n.on("click",".wooccmupload_file_delete",function(i){e(this).closest(".wooccmupload_file").remove()});l.on("change",function(o){var i=e(this)[0].files;if(i.length){if(window.FileReader){e.each(i,function(q,p){var r=n.find("span[data-file_id]").length+q;if(r>=wooccm_upload.limit.max_files){alert("Exeeds max files limit of "+wooccm_upload.limit.max_files);return false}if(p.size>wooccm_upload.limit.max_file_size){alert("Exeeds max file size of "+wooccm_upload.limit.max_file_size);return true}reader=new FileReader();reader.onload=(function(s){return function(t){setTimeout(function(){d(n,c[k.attr("id")].push(p)-1,t.target.result,s.name,s.type)},200)}})(p);console.log(p.name);reader.readAsDataURL(p)})}}})});e("#order_review").on("ajaxSuccess",function(l){var k=e(l.target),j=k.find("#place_order"),i=e(".wooccmupload-field"),h=i.length;if(h){j.addClass("wooccm-upload-process")}});e(document).on("click","#place_order.wooccm-upload-process",function(l){l.preventDefault();var i=e("form.checkout"),k=e(this),j=e(".wooccmupload-field"),h=j.length;j.each(function(m,p){var n=e(p),r=n.find(".wooccmupload_field"),q=n.find(".wooccmupload_list");if(window.FormData&&c[n.attr("id")].length){if(!f(i)){k.html(wooccm_upload.message.uploading);g(i)}var o=new FormData();q.find("span[data-file_id]").each(function(t,s){var u=e(s).data("file_id");if(t>wooccm_upload.limit.max_files){console.log("Exeeds max files limit of "+wooccm_upload.limit.max_files);return false}if(c[n.attr("id")][u]===undefined){console.log("Undefined "+u);return true}if(c[n.attr("id")][u].size>wooccm_upload.limit.max_file_size){console.log("Exeeds max file size of "+wooccm_upload.limit.max_files);return true}console.log("We're ready to upload "+c[n.attr("id")][u].name);o.append("wooccm_checkout_attachment_upload[]",c[n.attr("id")][u])});o.append("action","wooccm_checkout_attachment_upload");o.append("nonce",wooccm_upload.nonce);e.ajax({async:false,url:wooccm_upload.ajaxurl,type:"POST",cache:false,data:o,processData:false,contentType:false,beforeSend:function(s){},success:function(s){if(s.success){r.val(s.data)}else{e("body").trigger("update_checkout")}},complete:function(s){h=h-1}})}else{h=h-1}if(h==0){a(i);k.removeClass("wooccm-upload-process").trigger("click")}})});e(document).on("change",".wooccm-add-checkout-fees",function(h){e("body").trigger("update_checkout")});e(".wooccm-conditional-child").each(function(h,m){var j=e(m),l=e("#"+j.find("[data-conditional-parent]").data("conditional-parent")+"_field"),k=j.find("[data-conditional-parent-value]").data("conditional-parent-value");if(l.length){l.on("wooccm_change change keyup",function(o){var n=e(o.target),i=n.val();if(n.hasClass("select2-selection")){return}if(n.prop("type")=="checkbox"){i=n.is(":checked")}if(k==i||(e.isArray(i)&&i.indexOf(k)>-1)){j.fadeIn()}else{j.fadeOut()}n.off("wooccm_change");n.off("change");n.off("keyup")});l.find("select:first").trigger("wooccm_change");l.find("textarea:first").trigger("wooccm_change");l.find("input[type=button]:first").trigger("wooccm_change");l.find("input[type=radio]:checked:first").trigger("wooccm_change");l.find("input[type=checkbox]:checked:first").trigger("wooccm_change");l.find("input[type=color]:first").trigger("wooccm_change");l.find("input[type=date]:first").trigger("wooccm_change");l.find("input[type=datetime-local]:first").trigger("wooccm_change");l.find("input[type=email]:first").trigger("wooccm_change");l.find("input[type=file]:first").trigger("wooccm_change");l.find("input[type=hidden]:first").trigger("wooccm_change");l.find("input[type=image]:first").trigger("wooccm_change");l.find("input[type=month]:first").trigger("wooccm_change");l.find("input[type=number]:first").trigger("wooccm_change");l.find("input[type=password]:first").trigger("wooccm_change");l.find("input[type=range]:first").trigger("wooccm_change");l.find("input[type=reset]:first").trigger("wooccm_change");l.find("input[type=search]:first").trigger("wooccm_change");l.find("input[type=submit]:first").trigger("wooccm_change");l.find("input[type=tel]:first").trigger("wooccm_change");l.find("input[type=text]:first").trigger("wooccm_change");l.find("input[type=time]:first").trigger("wooccm_change");l.find("input[type=url]:first").trigger("wooccm_change");l.find("input[type=week]:first").trigger("wooccm_change")}else{j.show()}});e(".wooccm-type-datepicker").each(function(h,k){var j=e(k),l=j.find("input[type=text]");if(e.isFunction(e.fn.datepicker)){l.datepicker({dateFormat:l.data("formatdate")||"dd-mm-yy",minDate:l.data("mindate")||undefined,maxDate:l.data("maxdate")||undefined,beforeShowDay:function(n){var i=n.getDay(),m=l.data("disable")||false;if(!m){return[true]}else{return[m[i]!==undefined]}}})}});e(".wooccm-type-timepicker").each(function(h,k){var j=e(k),l=j.find("input[type=text]");if(e.isFunction(e.fn.timepicker)){l.timepicker({showPeriod:true,showLeadingZero:true,hours:l.data("hours")||undefined,minutes:l.data("minutes")||undefined,})}});e(".wooccm-colorpicker-farbtastic").each(function(h,k){var j=e(k),m=j.find("input[type=text]"),l=j.find(".wooccmcolorpicker_container");m.hide();if(e.isFunction(e.fn.farbtastic)){l.farbtastic("#"+m.attr("id"));l.on("click",function(i){m.fadeIn()})}});e(".wooccm-colorpicker-iris").each(function(h,k){var j=e(k),l=j.find("input[type=text]");l.css("color","#fff").css("background",l.val()).hide();l.iris({wccmclass:l.attr("id"),palettes:true,color:"",hide:false,change:function(i,m){l.css("color","#000").css("background",m.color.toString()).fadeIn()}})})})(jQuery);
|
assets/less/wooccm.less
CHANGED
@@ -13,6 +13,10 @@
|
|
13 |
}
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
.button {
|
13 |
}
|
14 |
}
|
15 |
|
16 |
+
.wooccm-conditional-child {
|
17 |
+
display: none;
|
18 |
+
}
|
19 |
+
|
20 |
}
|
21 |
|
22 |
.button {
|
includes/admin.php
CHANGED
@@ -14,9 +14,9 @@ if (is_admin()) {
|
|
14 |
//1326
|
15 |
//add_action('admin_notices', 'wooccm_admin_notices');
|
16 |
// Add fields to the Edit Order screen
|
17 |
-
add_action('
|
18 |
-
add_action('
|
19 |
-
add_action('
|
20 |
}
|
21 |
|
22 |
// Display admin notice on screen load
|
@@ -1071,372 +1071,372 @@ function wooccm_admin_updater_notice() {
|
|
1071 |
}
|
1072 |
}
|
1073 |
|
1074 |
-
|
1075 |
-
function wooccm_admin_edit_order_additional_details($order) {
|
1076 |
-
|
1077 |
-
global $post;
|
1078 |
-
|
1079 |
-
if (version_compare(wooccm_get_woo_version(), '2.7', '>=')) {
|
1080 |
-
$order_id = ( method_exists($order, 'get_id') ? $order->get_id() : $order->id );
|
1081 |
-
} else {
|
1082 |
-
$order_id = ( isset($order->id) ? $order->id : 0 );
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
$options = get_option('wccs_settings');
|
1086 |
-
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
1087 |
-
if (!empty($buttons)) {
|
1088 |
-
echo '
|
1089 |
-
|
1090 |
-
|
1091 |
-
foreach ($buttons as $btn) {
|
1092 |
-
|
1093 |
-
if (
|
1094 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1095 |
-
!empty($btn['label']) &&
|
1096 |
-
$btn['type'] !== 'heading' &&
|
1097 |
-
$btn['type'] !== 'multiselect' &&
|
1098 |
-
$btn['type'] !== 'wooccmupload' &&
|
1099 |
-
$btn['type'] !== 'multicheckbox'
|
1100 |
-
) {
|
1101 |
-
echo '
|
1102 |
-
|
1103 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $btn['cow'], __('Generic', 'woocommerce-checkout-manager')) . '">
|
1104 |
-
' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, $btn['cow'], true)) . '
|
1105 |
-
|
1106 |
-
|
1107 |
-
} elseif (
|
1108 |
-
!empty($btn['label']) &&
|
1109 |
-
$btn['type'] !== 'wooccmupload' &&
|
1110 |
-
$btn['type'] !== 'multiselect' &&
|
1111 |
-
$btn['type'] !== 'multicheckbox' &&
|
1112 |
-
$btn['type'] == 'heading'
|
1113 |
-
) {
|
1114 |
-
echo '
|
1115 |
-
|
1116 |
-
} elseif (
|
1117 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1118 |
-
!empty($btn['label']) &&
|
1119 |
-
$btn['type'] !== 'heading' &&
|
1120 |
-
$btn['type'] !== 'wooccmupload' &&
|
1121 |
-
(
|
1122 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1123 |
-
)
|
1124 |
-
) {
|
1125 |
-
$value = get_post_meta($order_id, $btn['cow'], true);
|
1126 |
-
$strings = maybe_unserialize($value);
|
1127 |
-
echo '
|
1128 |
-
|
1129 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $btn['cow'], __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1130 |
-
if (!empty($strings)) {
|
1131 |
-
if (is_array($strings)) {
|
1132 |
-
$iww = 0;
|
1133 |
-
$len = count($strings);
|
1134 |
-
foreach ($strings as $key) {
|
1135 |
-
if ($iww == $len - 1) {
|
1136 |
-
echo '' . wooccm_wpml_string($key);
|
1137 |
-
} else {
|
1138 |
-
echo '' . wooccm_wpml_string($key) . ', ';
|
1139 |
-
}
|
1140 |
-
$iww++;
|
1141 |
-
}
|
1142 |
-
}
|
1143 |
-
} else {
|
1144 |
-
echo '-';
|
1145 |
-
}
|
1146 |
-
echo '
|
1147 |
-
|
1148 |
-
|
1149 |
-
} elseif (
|
1150 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1151 |
-
$btn['type'] == 'wooccmupload'
|
1152 |
-
) {
|
1153 |
-
$attachments = get_post_meta($order_id, $btn['cow'], true);
|
1154 |
-
if (!empty($attachments)) {
|
1155 |
-
// Check for delimiter
|
1156 |
-
if (strstr($attachments, '||') !== false)
|
1157 |
-
$attachments = explode('||', $attachments);
|
1158 |
-
else if (strstr($attachments, ',') !== false)
|
1159 |
-
$attachments = explode(',', $attachments);
|
1160 |
-
else if (is_numeric($attachments))
|
1161 |
-
$attachments = array($attachments);
|
1162 |
-
}
|
1163 |
-
echo '
|
1164 |
-
|
1165 |
-
<strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1166 |
-
if (empty($attachments)) {
|
1167 |
-
echo '<br />';
|
1168 |
-
echo '-';
|
1169 |
-
}
|
1170 |
-
echo '
|
1171 |
-
|
1172 |
-
if (!empty($attachments)) {
|
1173 |
-
echo '<ul>' . "\n";
|
1174 |
-
foreach ($attachments as $attachment) {
|
1175 |
-
$attachment_url = wp_get_attachment_url($attachment);
|
1176 |
-
if (!empty($attachment_url))
|
1177 |
-
echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1178 |
-
}
|
1179 |
-
echo '</ul>';
|
1180 |
-
}
|
1181 |
-
echo '
|
1182 |
-
|
1183 |
-
}
|
1184 |
-
}
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
|
1188 |
// Billing details
|
1189 |
-
function wooccm_admin_edit_order_billing_details($order) {
|
1190 |
-
|
1191 |
-
global $post;
|
1192 |
-
|
1193 |
-
$order_id = ( isset($post->ID) ? $post->ID : false );
|
1194 |
-
|
1195 |
-
$options = get_option('wccs_settings3');
|
1196 |
-
$buttons = ( isset($options['billing_buttons']) ? $options['billing_buttons'] : false );
|
1197 |
-
if (!empty($buttons)) {
|
1198 |
-
$fields = array(
|
1199 |
-
'country',
|
1200 |
-
'first_name',
|
1201 |
-
'last_name',
|
1202 |
-
'company',
|
1203 |
-
'address_1',
|
1204 |
-
'address_2',
|
1205 |
-
'city',
|
1206 |
-
'state',
|
1207 |
-
'postcode',
|
1208 |
-
'email',
|
1209 |
-
'phone'
|
1210 |
-
);
|
1211 |
-
foreach ($buttons as $btn) {
|
1212 |
-
|
1213 |
-
if (!in_array($btn['cow'], $fields)) {
|
1214 |
-
if (
|
1215 |
-
( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1216 |
-
!empty($btn['label']) &&
|
1217 |
-
$btn['type'] !== 'heading' &&
|
1218 |
-
$btn['type'] !== 'multiselect' &&
|
1219 |
-
$btn['type'] !== 'wooccmupload' &&
|
1220 |
-
$btn['type'] !== 'multicheckbox'
|
1221 |
-
) {
|
1222 |
-
echo '
|
1223 |
-
|
1224 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_billing_%s', $btn['cow']), __('Generic', 'woocommerce-checkout-manager')) . '">
|
1225 |
-
' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true)) . '
|
1226 |
-
|
1227 |
-
|
1228 |
-
} elseif (
|
1229 |
-
!empty($btn['label']) &&
|
1230 |
-
$btn['type'] !== 'wooccmupload' &&
|
1231 |
-
$btn['type'] !== 'multiselect' &&
|
1232 |
-
$btn['type'] !== 'multicheckbox' &&
|
1233 |
-
$btn['type'] == 'heading'
|
1234 |
-
) {
|
1235 |
-
echo '
|
1236 |
-
|
1237 |
-
} elseif (
|
1238 |
-
( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1239 |
-
!empty($btn['label']) &&
|
1240 |
-
$btn['type'] !== 'heading' &&
|
1241 |
-
$btn['type'] !== 'wooccmupload' &&
|
1242 |
-
(
|
1243 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1244 |
-
)
|
1245 |
-
) {
|
1246 |
-
$value = get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true);
|
1247 |
-
$strings = maybe_unserialize($value);
|
1248 |
-
|
1249 |
-
echo '
|
1250 |
-
|
1251 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_billing_%s', $btn['cow']), __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1252 |
-
if (!empty($strings)) {
|
1253 |
-
if (is_array($strings)) {
|
1254 |
-
$iww = 0;
|
1255 |
-
$len = count($strings);
|
1256 |
-
foreach ($strings as $key) {
|
1257 |
-
if ($iww == $len - 1) {
|
1258 |
-
echo wooccm_wpml_string($key);
|
1259 |
-
} else {
|
1260 |
-
echo wooccm_wpml_string($key) . ', ';
|
1261 |
-
}
|
1262 |
-
$iww++;
|
1263 |
-
}
|
1264 |
-
} else {
|
1265 |
-
echo $strings;
|
1266 |
-
}
|
1267 |
-
} else {
|
1268 |
-
echo '-';
|
1269 |
-
}
|
1270 |
-
echo '
|
1271 |
-
|
1272 |
-
|
1273 |
-
} elseif (
|
1274 |
-
( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1275 |
-
$btn['type'] == 'wooccmupload'
|
1276 |
-
) {
|
1277 |
-
$attachments = get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true);
|
1278 |
-
if (!empty($attachments)) {
|
1279 |
-
// Check for delimiter
|
1280 |
-
if (strstr($attachments, '||') !== false)
|
1281 |
-
$attachments = explode('||', $attachments);
|
1282 |
-
else if (strstr($attachments, ',') !== false)
|
1283 |
-
$attachments = explode(',', $attachments);
|
1284 |
-
else if (is_numeric($attachments))
|
1285 |
-
$attachments = array($attachments);
|
1286 |
-
}
|
1287 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
1288 |
-
echo '
|
1289 |
-
|
1290 |
-
<strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1291 |
-
if (empty($attachments)) {
|
1292 |
-
echo '<br />';
|
1293 |
-
echo '-';
|
1294 |
-
}
|
1295 |
-
echo '
|
1296 |
-
|
1297 |
-
if (!empty($attachments)) {
|
1298 |
-
echo '<ul>' . "\n";
|
1299 |
-
foreach ($attachments as $attachment) {
|
1300 |
-
$attachment_url = wp_get_attachment_url($attachment);
|
1301 |
-
if (!empty($attachment_url))
|
1302 |
-
echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1303 |
-
}
|
1304 |
-
echo '</ul>';
|
1305 |
-
}
|
1306 |
-
echo '
|
1307 |
-
|
1308 |
-
}
|
1309 |
-
}
|
1310 |
-
}
|
1311 |
-
}
|
1312 |
-
}
|
1313 |
|
1314 |
// Shipping details
|
1315 |
-
function wooccm_admin_edit_order_shipping_details($order) {
|
1316 |
-
|
1317 |
-
global $post;
|
1318 |
-
|
1319 |
-
$order_id = ( isset($post->ID) ? $post->ID : false );
|
1320 |
-
|
1321 |
-
$options = get_option('wccs_settings2');
|
1322 |
-
$buttons = ( isset($options['shipping_buttons']) ? $options['shipping_buttons'] : false );
|
1323 |
-
if (!empty($buttons)) {
|
1324 |
-
$fields = array(
|
1325 |
-
'country',
|
1326 |
-
'first_name',
|
1327 |
-
'last_name',
|
1328 |
-
'company',
|
1329 |
-
'address_1',
|
1330 |
-
'address_2',
|
1331 |
-
'city',
|
1332 |
-
'state',
|
1333 |
-
'postcode'
|
1334 |
-
);
|
1335 |
-
foreach ($buttons as $btn) {
|
1336 |
-
|
1337 |
-
if (!in_array($btn['cow'], $fields)) {
|
1338 |
-
if (
|
1339 |
-
( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1340 |
-
!empty($btn['label']) &&
|
1341 |
-
$btn['type'] !== 'wooccmupload' &&
|
1342 |
-
$btn['type'] !== 'heading' &&
|
1343 |
-
$btn['type'] !== 'multiselect' &&
|
1344 |
-
$btn['type'] !== 'multicheckbox'
|
1345 |
-
) {
|
1346 |
-
echo '
|
1347 |
-
|
1348 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_shipping_%s', $btn['cow']), __('Generic', 'woocommerce-checkout-manager')) . '">
|
1349 |
-
' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true)) . '
|
1350 |
-
|
1351 |
-
|
1352 |
-
} elseif (
|
1353 |
-
!empty($btn['label']) &&
|
1354 |
-
$btn['type'] !== 'multiselect' &&
|
1355 |
-
$btn['type'] !== 'multicheckbox' &&
|
1356 |
-
$btn['type'] == 'heading'
|
1357 |
-
) {
|
1358 |
-
echo '
|
1359 |
-
|
1360 |
-
} elseif (
|
1361 |
-
( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1362 |
-
!empty($btn['label']) &&
|
1363 |
-
$btn['type'] !== 'heading' &&
|
1364 |
-
$btn['type'] !== 'wooccmupload' &&
|
1365 |
-
(
|
1366 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1367 |
-
)
|
1368 |
-
) {
|
1369 |
-
$value = get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true);
|
1370 |
-
$strings = maybe_unserialize($value);
|
1371 |
-
echo '
|
1372 |
-
|
1373 |
-
<strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_shipping_%s', $btn['cow']), __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1374 |
-
if (!empty($strings)) {
|
1375 |
-
if (is_array($strings)) {
|
1376 |
-
$iww = 0;
|
1377 |
-
$len = count($strings);
|
1378 |
-
foreach ($strings as $key) {
|
1379 |
-
if ($iww == $len - 1) {
|
1380 |
-
echo wooccm_wpml_string($key);
|
1381 |
-
} else {
|
1382 |
-
echo wooccm_wpml_string($key) . ', ';
|
1383 |
-
}
|
1384 |
-
$iww++;
|
1385 |
-
}
|
1386 |
-
} else {
|
1387 |
-
echo $strings;
|
1388 |
-
}
|
1389 |
-
} else {
|
1390 |
-
echo '-';
|
1391 |
-
}
|
1392 |
-
echo '
|
1393 |
-
|
1394 |
-
|
1395 |
-
} elseif (
|
1396 |
-
( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1397 |
-
$btn['type'] == 'wooccmupload'
|
1398 |
-
) {
|
1399 |
-
$attachments = get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true);
|
1400 |
-
if (!empty($attachments)) {
|
1401 |
-
// Check for delimiter
|
1402 |
-
if (strstr($attachments, '||') !== false)
|
1403 |
-
$attachments = explode('||', $attachments);
|
1404 |
-
else if (strstr($attachments, ',') !== false)
|
1405 |
-
$attachments = explode(',', $attachments);
|
1406 |
-
else if (is_numeric($attachments))
|
1407 |
-
$attachments = array($attachments);
|
1408 |
-
}
|
1409 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
1410 |
-
echo '
|
1411 |
-
|
1412 |
-
<strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1413 |
-
echo '
|
1414 |
-
|
1415 |
-
if (!empty($attachments) && is_array($attachments)) {
|
1416 |
-
echo '<ul>' . "\n";
|
1417 |
-
foreach ($attachments as $attachment) {
|
1418 |
-
$attachment_url = wp_get_attachment_url($attachment);
|
1419 |
-
if (!empty($attachment_url))
|
1420 |
-
echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1421 |
-
}
|
1422 |
-
echo '</ul>';
|
1423 |
-
} else {
|
1424 |
-
echo '<br />';
|
1425 |
-
echo '-';
|
1426 |
-
}
|
1427 |
-
echo '
|
1428 |
-
|
1429 |
-
}
|
1430 |
-
}
|
1431 |
-
}
|
1432 |
-
}
|
1433 |
-
}
|
1434 |
-
|
1435 |
-
function wooccm_js_str($s) {
|
1436 |
-
return '"' . addcslashes($s, "\0..\37\"\\") . '"';
|
1437 |
-
}
|
1438 |
-
|
1439 |
-
function wooccm_js_array($array) {
|
1440 |
-
$temp = array_map('wooccm_js_str', $array);
|
1441 |
-
return '[' . implode(',', $temp) . ']';
|
1442 |
-
}
|
14 |
//1326
|
15 |
//add_action('admin_notices', 'wooccm_admin_notices');
|
16 |
// Add fields to the Edit Order screen
|
17 |
+
//add_action('woocommerce_admin_order_data_after_billing_address', 'wooccm_admin_edit_order_billing_details');
|
18 |
+
//add_action('woocommerce_admin_order_data_after_shipping_address', 'wooccm_admin_edit_order_shipping_details');
|
19 |
+
//add_action('woocommerce_admin_order_data_after_order_details', 'wooccm_admin_edit_order_additional_details');
|
20 |
}
|
21 |
|
22 |
// Display admin notice on screen load
|
1071 |
}
|
1072 |
}
|
1073 |
|
1074 |
+
//// Additional details
|
1075 |
+
//function wooccm_admin_edit_order_additional_details($order) {
|
1076 |
+
//
|
1077 |
+
// global $post;
|
1078 |
+
//
|
1079 |
+
// if (version_compare(wooccm_get_woo_version(), '2.7', '>=')) {
|
1080 |
+
// $order_id = ( method_exists($order, 'get_id') ? $order->get_id() : $order->id );
|
1081 |
+
// } else {
|
1082 |
+
// $order_id = ( isset($order->id) ? $order->id : 0 );
|
1083 |
+
// }
|
1084 |
+
//
|
1085 |
+
// $options = get_option('wccs_settings');
|
1086 |
+
// $buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
1087 |
+
// if (!empty($buttons)) {
|
1088 |
+
// echo '
|
1089 |
+
//<p> </p>
|
1090 |
+
//<h4>' . __('Additional Details', 'woocommerce-checkout-manager') . '</h4>';
|
1091 |
+
// foreach ($buttons as $btn) {
|
1092 |
+
//
|
1093 |
+
// if (
|
1094 |
+
// ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1095 |
+
// !empty($btn['label']) &&
|
1096 |
+
// $btn['type'] !== 'heading' &&
|
1097 |
+
// $btn['type'] !== 'multiselect' &&
|
1098 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1099 |
+
// $btn['type'] !== 'multicheckbox'
|
1100 |
+
// ) {
|
1101 |
+
// echo '
|
1102 |
+
//<p id="additional_' . $btn['cow'] . '" class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1103 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $btn['cow'], __('Generic', 'woocommerce-checkout-manager')) . '">
|
1104 |
+
// ' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, $btn['cow'], true)) . '
|
1105 |
+
//</p>
|
1106 |
+
//<!-- .form-field-type-... -->';
|
1107 |
+
// } elseif (
|
1108 |
+
// !empty($btn['label']) &&
|
1109 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1110 |
+
// $btn['type'] !== 'multiselect' &&
|
1111 |
+
// $btn['type'] !== 'multicheckbox' &&
|
1112 |
+
// $btn['type'] == 'heading'
|
1113 |
+
// ) {
|
1114 |
+
// echo '
|
1115 |
+
//<h4>' . wooccm_wpml_string(trim($btn['label'])) . '</h4>';
|
1116 |
+
// } elseif (
|
1117 |
+
// ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1118 |
+
// !empty($btn['label']) &&
|
1119 |
+
// $btn['type'] !== 'heading' &&
|
1120 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1121 |
+
// (
|
1122 |
+
// $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1123 |
+
// )
|
1124 |
+
// ) {
|
1125 |
+
// $value = get_post_meta($order_id, $btn['cow'], true);
|
1126 |
+
// $strings = maybe_unserialize($value);
|
1127 |
+
// echo '
|
1128 |
+
//<p class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1129 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $btn['cow'], __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1130 |
+
// if (!empty($strings)) {
|
1131 |
+
// if (is_array($strings)) {
|
1132 |
+
// $iww = 0;
|
1133 |
+
// $len = count($strings);
|
1134 |
+
// foreach ($strings as $key) {
|
1135 |
+
// if ($iww == $len - 1) {
|
1136 |
+
// echo '' . wooccm_wpml_string($key);
|
1137 |
+
// } else {
|
1138 |
+
// echo '' . wooccm_wpml_string($key) . ', ';
|
1139 |
+
// }
|
1140 |
+
// $iww++;
|
1141 |
+
// }
|
1142 |
+
// }
|
1143 |
+
// } else {
|
1144 |
+
// echo '-';
|
1145 |
+
// }
|
1146 |
+
// echo '
|
1147 |
+
//</p>
|
1148 |
+
//<!-- .form-field-type-multiselect .form-field-type-multicheckbox -->';
|
1149 |
+
// } elseif (
|
1150 |
+
// ( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
1151 |
+
// $btn['type'] == 'wooccmupload'
|
1152 |
+
// ) {
|
1153 |
+
// $attachments = get_post_meta($order_id, $btn['cow'], true);
|
1154 |
+
// if (!empty($attachments)) {
|
1155 |
+
// // Check for delimiter
|
1156 |
+
// if (strstr($attachments, '||') !== false)
|
1157 |
+
// $attachments = explode('||', $attachments);
|
1158 |
+
// else if (strstr($attachments, ',') !== false)
|
1159 |
+
// $attachments = explode(',', $attachments);
|
1160 |
+
// else if (is_numeric($attachments))
|
1161 |
+
// $attachments = array($attachments);
|
1162 |
+
// }
|
1163 |
+
// echo '
|
1164 |
+
//<p class="form-field form-field-wide form-field-type-wooccmupload">
|
1165 |
+
// <strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1166 |
+
// if (empty($attachments)) {
|
1167 |
+
// echo '<br />';
|
1168 |
+
// echo '-';
|
1169 |
+
// }
|
1170 |
+
// echo '
|
1171 |
+
//</p>' . "\n";
|
1172 |
+
// if (!empty($attachments)) {
|
1173 |
+
// echo '<ul>' . "\n";
|
1174 |
+
// foreach ($attachments as $attachment) {
|
1175 |
+
// $attachment_url = wp_get_attachment_url($attachment);
|
1176 |
+
// if (!empty($attachment_url))
|
1177 |
+
// echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1178 |
+
// }
|
1179 |
+
// echo '</ul>';
|
1180 |
+
// }
|
1181 |
+
// echo '
|
1182 |
+
//<!-- .form-field-type-wooccmupload -->';
|
1183 |
+
// }
|
1184 |
+
// }
|
1185 |
+
// }
|
1186 |
+
//}
|
1187 |
|
1188 |
// Billing details
|
1189 |
+
//function wooccm_admin_edit_order_billing_details($order) {
|
1190 |
+
//
|
1191 |
+
// global $post;
|
1192 |
+
//
|
1193 |
+
// $order_id = ( isset($post->ID) ? $post->ID : false );
|
1194 |
+
//
|
1195 |
+
// $options = get_option('wccs_settings3');
|
1196 |
+
// $buttons = ( isset($options['billing_buttons']) ? $options['billing_buttons'] : false );
|
1197 |
+
// if (!empty($buttons)) {
|
1198 |
+
// $fields = array(
|
1199 |
+
// 'country',
|
1200 |
+
// 'first_name',
|
1201 |
+
// 'last_name',
|
1202 |
+
// 'company',
|
1203 |
+
// 'address_1',
|
1204 |
+
// 'address_2',
|
1205 |
+
// 'city',
|
1206 |
+
// 'state',
|
1207 |
+
// 'postcode',
|
1208 |
+
// 'email',
|
1209 |
+
// 'phone'
|
1210 |
+
// );
|
1211 |
+
// foreach ($buttons as $btn) {
|
1212 |
+
//
|
1213 |
+
// if (!in_array($btn['cow'], $fields)) {
|
1214 |
+
// if (
|
1215 |
+
// ( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1216 |
+
// !empty($btn['label']) &&
|
1217 |
+
// $btn['type'] !== 'heading' &&
|
1218 |
+
// $btn['type'] !== 'multiselect' &&
|
1219 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1220 |
+
// $btn['type'] !== 'multicheckbox'
|
1221 |
+
// ) {
|
1222 |
+
// echo '
|
1223 |
+
//<p id="billing_' . $btn['cow'] . '" class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1224 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_billing_%s', $btn['cow']), __('Generic', 'woocommerce-checkout-manager')) . '">
|
1225 |
+
// ' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true)) . '
|
1226 |
+
//</p>
|
1227 |
+
//<!-- .form-field-type-... -->';
|
1228 |
+
// } elseif (
|
1229 |
+
// !empty($btn['label']) &&
|
1230 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1231 |
+
// $btn['type'] !== 'multiselect' &&
|
1232 |
+
// $btn['type'] !== 'multicheckbox' &&
|
1233 |
+
// $btn['type'] == 'heading'
|
1234 |
+
// ) {
|
1235 |
+
// echo '
|
1236 |
+
//<h4>' . wooccm_wpml_string(trim($btn['label'])) . '</h4>';
|
1237 |
+
// } elseif (
|
1238 |
+
// ( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1239 |
+
// !empty($btn['label']) &&
|
1240 |
+
// $btn['type'] !== 'heading' &&
|
1241 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1242 |
+
// (
|
1243 |
+
// $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1244 |
+
// )
|
1245 |
+
// ) {
|
1246 |
+
// $value = get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true);
|
1247 |
+
// $strings = maybe_unserialize($value);
|
1248 |
+
//
|
1249 |
+
// echo '
|
1250 |
+
//<p class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1251 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_billing_%s', $btn['cow']), __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1252 |
+
// if (!empty($strings)) {
|
1253 |
+
// if (is_array($strings)) {
|
1254 |
+
// $iww = 0;
|
1255 |
+
// $len = count($strings);
|
1256 |
+
// foreach ($strings as $key) {
|
1257 |
+
// if ($iww == $len - 1) {
|
1258 |
+
// echo wooccm_wpml_string($key);
|
1259 |
+
// } else {
|
1260 |
+
// echo wooccm_wpml_string($key) . ', ';
|
1261 |
+
// }
|
1262 |
+
// $iww++;
|
1263 |
+
// }
|
1264 |
+
// } else {
|
1265 |
+
// echo $strings;
|
1266 |
+
// }
|
1267 |
+
// } else {
|
1268 |
+
// echo '-';
|
1269 |
+
// }
|
1270 |
+
// echo '
|
1271 |
+
//</p>
|
1272 |
+
//<!-- .form-field-type-multiselect .form-field-type-multicheckbox -->';
|
1273 |
+
// } elseif (
|
1274 |
+
// ( get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true) !== '' ) &&
|
1275 |
+
// $btn['type'] == 'wooccmupload'
|
1276 |
+
// ) {
|
1277 |
+
// $attachments = get_post_meta($order_id, sprintf('_billing_%s', $btn['cow']), true);
|
1278 |
+
// if (!empty($attachments)) {
|
1279 |
+
// // Check for delimiter
|
1280 |
+
// if (strstr($attachments, '||') !== false)
|
1281 |
+
// $attachments = explode('||', $attachments);
|
1282 |
+
// else if (strstr($attachments, ',') !== false)
|
1283 |
+
// $attachments = explode(',', $attachments);
|
1284 |
+
// else if (is_numeric($attachments))
|
1285 |
+
// $attachments = array($attachments);
|
1286 |
+
// }
|
1287 |
+
// $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
1288 |
+
// echo '
|
1289 |
+
//<p class="form-field form-field-wide form-field-type-wooccmupload">
|
1290 |
+
// <strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1291 |
+
// if (empty($attachments)) {
|
1292 |
+
// echo '<br />';
|
1293 |
+
// echo '-';
|
1294 |
+
// }
|
1295 |
+
// echo '
|
1296 |
+
//</p>' . "\n";
|
1297 |
+
// if (!empty($attachments)) {
|
1298 |
+
// echo '<ul>' . "\n";
|
1299 |
+
// foreach ($attachments as $attachment) {
|
1300 |
+
// $attachment_url = wp_get_attachment_url($attachment);
|
1301 |
+
// if (!empty($attachment_url))
|
1302 |
+
// echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1303 |
+
// }
|
1304 |
+
// echo '</ul>';
|
1305 |
+
// }
|
1306 |
+
// echo '
|
1307 |
+
//<!-- .form-field-type-wooccmupload -->';
|
1308 |
+
// }
|
1309 |
+
// }
|
1310 |
+
// }
|
1311 |
+
// }
|
1312 |
+
//}
|
1313 |
|
1314 |
// Shipping details
|
1315 |
+
//function wooccm_admin_edit_order_shipping_details($order) {
|
1316 |
+
//
|
1317 |
+
// global $post;
|
1318 |
+
//
|
1319 |
+
// $order_id = ( isset($post->ID) ? $post->ID : false );
|
1320 |
+
//
|
1321 |
+
// $options = get_option('wccs_settings2');
|
1322 |
+
// $buttons = ( isset($options['shipping_buttons']) ? $options['shipping_buttons'] : false );
|
1323 |
+
// if (!empty($buttons)) {
|
1324 |
+
// $fields = array(
|
1325 |
+
// 'country',
|
1326 |
+
// 'first_name',
|
1327 |
+
// 'last_name',
|
1328 |
+
// 'company',
|
1329 |
+
// 'address_1',
|
1330 |
+
// 'address_2',
|
1331 |
+
// 'city',
|
1332 |
+
// 'state',
|
1333 |
+
// 'postcode'
|
1334 |
+
// );
|
1335 |
+
// foreach ($buttons as $btn) {
|
1336 |
+
//
|
1337 |
+
// if (!in_array($btn['cow'], $fields)) {
|
1338 |
+
// if (
|
1339 |
+
// ( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1340 |
+
// !empty($btn['label']) &&
|
1341 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1342 |
+
// $btn['type'] !== 'heading' &&
|
1343 |
+
// $btn['type'] !== 'multiselect' &&
|
1344 |
+
// $btn['type'] !== 'multicheckbox'
|
1345 |
+
// ) {
|
1346 |
+
// echo '
|
1347 |
+
//<p id="shipping_' . $btn['cow'] . '" class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1348 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_shipping_%s', $btn['cow']), __('Generic', 'woocommerce-checkout-manager')) . '">
|
1349 |
+
// ' . wooccm_wpml_string(trim($btn['label'])) . ':</strong><br />' . nl2br(get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true)) . '
|
1350 |
+
//</p>
|
1351 |
+
//<!-- .form-field-type-... -->';
|
1352 |
+
// } elseif (
|
1353 |
+
// !empty($btn['label']) &&
|
1354 |
+
// $btn['type'] !== 'multiselect' &&
|
1355 |
+
// $btn['type'] !== 'multicheckbox' &&
|
1356 |
+
// $btn['type'] == 'heading'
|
1357 |
+
// ) {
|
1358 |
+
// echo '
|
1359 |
+
//<h4>' . wooccm_wpml_string(trim($btn['label'])) . '</h4>';
|
1360 |
+
// } elseif (
|
1361 |
+
// ( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1362 |
+
// !empty($btn['label']) &&
|
1363 |
+
// $btn['type'] !== 'heading' &&
|
1364 |
+
// $btn['type'] !== 'wooccmupload' &&
|
1365 |
+
// (
|
1366 |
+
// $btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
1367 |
+
// )
|
1368 |
+
// ) {
|
1369 |
+
// $value = get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true);
|
1370 |
+
// $strings = maybe_unserialize($value);
|
1371 |
+
// echo '
|
1372 |
+
//<p class="form-field form-field-wide form-field-type-' . $btn['type'] . '">
|
1373 |
+
// <strong title="' . sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), sprintf('_shipping_%s', $btn['cow']), __('Multi-Select or Multi-Checkbox', 'woocommerce-checkout-manager')) . '">' . wooccm_wpml_string(trim($btn['label'])) . ':</strong> ';
|
1374 |
+
// if (!empty($strings)) {
|
1375 |
+
// if (is_array($strings)) {
|
1376 |
+
// $iww = 0;
|
1377 |
+
// $len = count($strings);
|
1378 |
+
// foreach ($strings as $key) {
|
1379 |
+
// if ($iww == $len - 1) {
|
1380 |
+
// echo wooccm_wpml_string($key);
|
1381 |
+
// } else {
|
1382 |
+
// echo wooccm_wpml_string($key) . ', ';
|
1383 |
+
// }
|
1384 |
+
// $iww++;
|
1385 |
+
// }
|
1386 |
+
// } else {
|
1387 |
+
// echo $strings;
|
1388 |
+
// }
|
1389 |
+
// } else {
|
1390 |
+
// echo '-';
|
1391 |
+
// }
|
1392 |
+
// echo '
|
1393 |
+
//</p>
|
1394 |
+
//<!-- .form-field-type-multiselect .form-field-type-multicheckbox -->';
|
1395 |
+
// } elseif (
|
1396 |
+
// ( get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true) !== '' ) &&
|
1397 |
+
// $btn['type'] == 'wooccmupload'
|
1398 |
+
// ) {
|
1399 |
+
// $attachments = get_post_meta($order_id, sprintf('_shipping_%s', $btn['cow']), true);
|
1400 |
+
// if (!empty($attachments)) {
|
1401 |
+
// // Check for delimiter
|
1402 |
+
// if (strstr($attachments, '||') !== false)
|
1403 |
+
// $attachments = explode('||', $attachments);
|
1404 |
+
// else if (strstr($attachments, ',') !== false)
|
1405 |
+
// $attachments = explode(',', $attachments);
|
1406 |
+
// else if (is_numeric($attachments))
|
1407 |
+
// $attachments = array($attachments);
|
1408 |
+
// }
|
1409 |
+
// $btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
1410 |
+
// echo '
|
1411 |
+
//<p class="form-field form-field-wide form-field-type-wooccmupload">
|
1412 |
+
// <strong>' . wooccm_wpml_string(trim($btn['label'])) . ':</strong>';
|
1413 |
+
// echo '
|
1414 |
+
//</p>' . "\n";
|
1415 |
+
// if (!empty($attachments) && is_array($attachments)) {
|
1416 |
+
// echo '<ul>' . "\n";
|
1417 |
+
// foreach ($attachments as $attachment) {
|
1418 |
+
// $attachment_url = wp_get_attachment_url($attachment);
|
1419 |
+
// if (!empty($attachment_url))
|
1420 |
+
// echo '<li><a href="' . $attachment_url . '" target="_blank">' . basename($attachment_url) . '</a></li>' . "\n";
|
1421 |
+
// }
|
1422 |
+
// echo '</ul>';
|
1423 |
+
// } else {
|
1424 |
+
// echo '<br />';
|
1425 |
+
// echo '-';
|
1426 |
+
// }
|
1427 |
+
// echo '
|
1428 |
+
//<!-- .form-field-type-wooccmupload -->';
|
1429 |
+
// }
|
1430 |
+
// }
|
1431 |
+
// }
|
1432 |
+
// }
|
1433 |
+
//}
|
1434 |
+
|
1435 |
+
//function wooccm_js_str($s) {
|
1436 |
+
// return '"' . addcslashes($s, "\0..\37\"\\") . '"';
|
1437 |
+
//}
|
1438 |
+
//
|
1439 |
+
//function wooccm_js_array($array) {
|
1440 |
+
// $temp = array_map('wooccm_js_str', $array);
|
1441 |
+
// return '[' . implode(',', $temp) . ']';
|
1442 |
+
//}
|
includes/classes/main.php
CHANGED
@@ -9,155 +9,6 @@
|
|
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 |
-
|
48 |
-
// -----------------------------------------------------------
|
49 |
-
// -----------------------------------------------------------
|
50 |
-
// -----------------------------------------------------------
|
51 |
-
// -----------------------------------------------------------
|
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() {
|
@@ -391,131 +242,6 @@ function wooccm_enable_auto_complete() {
|
|
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');
|
@@ -966,5 +692,4 @@ function wooccm_remove_notices_conditional($posted) {
|
|
966 |
WC()->session->set('wc_notices', $notice);
|
967 |
}
|
968 |
|
969 |
-
add_action('woocommerce_after_checkout_validation', 'wooccm_remove_notices_conditional');
|
970 |
-
?>
|
9 |
if (!defined('ABSPATH'))
|
10 |
exit;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
if (wooccm_enable_auto_complete()) {
|
13 |
|
14 |
function wooccm_retain_field_values() {
|
242 |
}
|
243 |
}
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
function wooccm_state_default_switch() {
|
246 |
|
247 |
$options = get_option('wccs_settings');
|
692 |
WC()->session->set('wc_notices', $notice);
|
693 |
}
|
694 |
|
695 |
+
add_action('woocommerce_after_checkout_validation', 'wooccm_remove_notices_conditional');
|
|
includes/formatting.php
CHANGED
@@ -13,63 +13,6 @@ function wooccm_mul_array( $val, $array ) {
|
|
13 |
|
14 |
}
|
15 |
|
16 |
-
/*function wooccm_mul_array2( $val ) {
|
17 |
-
|
18 |
-
global $wpdb;
|
19 |
-
|
20 |
-
foreach( $wpdb->last_result as $item => $tru ) {
|
21 |
-
if( isset($tru->meta_key) && $tru->meta_key == $val ) {
|
22 |
-
return true;
|
23 |
-
}
|
24 |
-
}
|
25 |
-
return false;
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
function wooccm_get_value_by_key( $array, $key ) {
|
30 |
-
|
31 |
-
if( !empty( $array ) ) {
|
32 |
-
foreach( $array as $k => $each ){
|
33 |
-
if( $k == $key ) {
|
34 |
-
return $each;
|
35 |
-
}
|
36 |
-
if( is_array( $each ) ) {
|
37 |
-
if( $return = wooccm_get_value_by_key( $each,$key ) ) {
|
38 |
-
return $return;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
function wooccm_does_existw( $array ) {
|
47 |
-
|
48 |
-
if( empty( $array ) )
|
49 |
-
return;
|
50 |
-
|
51 |
-
if( !is_array( $array ) )
|
52 |
-
return;
|
53 |
-
|
54 |
-
foreach( $array as $sub ) {
|
55 |
-
if( wooccm_mul_array2( wooccm_get_value_by_key( $sub, 'cow' ) ) ) {
|
56 |
-
return true;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
}*/
|
61 |
-
|
62 |
-
function wooccm_clean( $string ) {
|
63 |
-
|
64 |
-
$trim_length = 200; //desired length of text to display
|
65 |
-
$string = str_replace('-', '', $string); // Replaces all spaces with hyphens.
|
66 |
-
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
|
67 |
-
// $string = preg_replace('/\s+/', '', strip_tags($string)); // removes html and spaces
|
68 |
-
// $string = preg_replace('/\d/', '', $string); // Replaces multiple hyphens with single one.
|
69 |
-
return rtrim( substr( $string, 0, $trim_length ) );
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
function wooccm_wpml_string( $input = '' ) {
|
74 |
|
75 |
if( function_exists( 'icl_t' ) ) {
|
@@ -78,17 +21,4 @@ function wooccm_wpml_string( $input = '' ) {
|
|
78 |
return $input;
|
79 |
}
|
80 |
|
81 |
-
}
|
82 |
-
|
83 |
-
// Sort Checkout fields based on order
|
84 |
-
function wooccm_sort_fields( $a, $b ) {
|
85 |
-
|
86 |
-
if( !isset( $a['order'] ) || !isset( $b['order'] ) )
|
87 |
-
return 0;
|
88 |
-
|
89 |
-
if( $a['order'] == $b['order'] )
|
90 |
-
return 0;
|
91 |
-
return ( $a['order'] < $b['order'] ) ? -1 : 1;
|
92 |
-
|
93 |
-
}
|
94 |
-
?>
|
13 |
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
function wooccm_wpml_string( $input = '' ) {
|
17 |
|
18 |
if( function_exists( 'icl_t' ) ) {
|
21 |
return $input;
|
22 |
}
|
23 |
|
24 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions.php
CHANGED
@@ -27,5 +27,4 @@ function wooccm_get_woo_version() {
|
|
27 |
}
|
28 |
return $version;
|
29 |
|
30 |
-
}
|
31 |
-
?>
|
27 |
}
|
28 |
return $version;
|
29 |
|
30 |
+
}
|
|
includes/template.php
DELETED
@@ -1,442 +0,0 @@
|
|
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
|
5 |
-
function wooccm_order_received_checkout_details($order) {
|
6 |
-
|
7 |
-
if (version_compare(wooccm_get_woo_version(), '2.7', '>='))
|
8 |
-
$order_id = ( method_exists($order, 'get_id') ? $order->get_id() : $order->id );
|
9 |
-
else
|
10 |
-
$order_id = ( isset($order->id) ? $order->id : 0 );
|
11 |
-
|
12 |
-
$shipping = array(
|
13 |
-
'country',
|
14 |
-
'first_name',
|
15 |
-
'last_name',
|
16 |
-
'company',
|
17 |
-
'address_1',
|
18 |
-
'address_2',
|
19 |
-
'city',
|
20 |
-
'state',
|
21 |
-
'postcode'
|
22 |
-
);
|
23 |
-
$billing = array(
|
24 |
-
'country',
|
25 |
-
'first_name',
|
26 |
-
'last_name',
|
27 |
-
'company',
|
28 |
-
'address_1',
|
29 |
-
'address_2',
|
30 |
-
'city',
|
31 |
-
'state',
|
32 |
-
'postcode',
|
33 |
-
'email',
|
34 |
-
'phone'
|
35 |
-
);
|
36 |
-
|
37 |
-
$names = array(
|
38 |
-
'billing',
|
39 |
-
'shipping'
|
40 |
-
);
|
41 |
-
$inc = 3;
|
42 |
-
|
43 |
-
$show_table = apply_filters('wooccm_order_received_checkout_show_table', ( defined('WOOCOMMERCE_VERSION') && version_compare(WOOCOMMERCE_VERSION, '2.3', '>=')));
|
44 |
-
$print_table = apply_filters('wooccm_order_received_checkout_print_table', true);
|
45 |
-
|
46 |
-
// Check if above WooCommerce 2.3+
|
47 |
-
if ($show_table) {
|
48 |
-
|
49 |
-
if ($print_table) {
|
50 |
-
echo '<table class="wccs_custom_fields shop_table">';
|
51 |
-
}
|
52 |
-
|
53 |
-
foreach ($names as $name) {
|
54 |
-
|
55 |
-
$array = ( $name == 'billing' ) ? $billing : $shipping;
|
56 |
-
|
57 |
-
$options = get_option('wccs_settings' . $inc);
|
58 |
-
if (!empty($options[sprintf('%s_buttons', $name)])) {
|
59 |
-
foreach ($options[sprintf('%s_buttons', $name)] as $btn) {
|
60 |
-
|
61 |
-
if (!in_array($btn['cow'], $array)) {
|
62 |
-
if (
|
63 |
-
( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
|
64 |
-
!empty($btn['label']) &&
|
65 |
-
empty($btn['deny_receipt']) &&
|
66 |
-
$btn['type'] !== 'heading' &&
|
67 |
-
$btn['type'] !== 'wooccmupload' &&
|
68 |
-
$btn['type'] !== 'multiselect' &&
|
69 |
-
$btn['type'] !== 'multicheckbox'
|
70 |
-
) {
|
71 |
-
echo '
|
72 |
-
<tr>
|
73 |
-
<th>' . wooccm_wpml_string($btn['label']) . ':</th>
|
74 |
-
<td>' . nl2br(get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true)) . '</td>
|
75 |
-
</tr>';
|
76 |
-
} elseif (
|
77 |
-
!empty($btn['label']) &&
|
78 |
-
empty($btn['deny_receipt']) &&
|
79 |
-
$btn['type'] !== 'multiselect' &&
|
80 |
-
$btn['type'] !== 'multicheckbox' &&
|
81 |
-
$btn['type'] == 'heading'
|
82 |
-
) {
|
83 |
-
echo '
|
84 |
-
<tr>
|
85 |
-
<th colspan="2">' . wooccm_wpml_string($btn['label']) . '</th>
|
86 |
-
</tr>';
|
87 |
-
} elseif (
|
88 |
-
( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '') &&
|
89 |
-
$btn['type'] !== 'wooccmupload' &&
|
90 |
-
!empty($btn['label']) &&
|
91 |
-
empty($btn['deny_receipt']) &&
|
92 |
-
$btn['type'] !== 'heading' &&
|
93 |
-
(
|
94 |
-
( $btn['type'] == 'multiselect' ) || ( $btn['type'] == 'multicheckbox' )
|
95 |
-
)
|
96 |
-
) {
|
97 |
-
$value = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
|
98 |
-
$strings = maybe_unserialize($value);
|
99 |
-
echo '
|
100 |
-
<tr>
|
101 |
-
<th>' . wooccm_wpml_string($btn['label']) . ':</th>
|
102 |
-
<td data-title="' . wooccm_wpml_string($btn['label']) . '">';
|
103 |
-
if (!empty($strings)) {
|
104 |
-
if (is_array($strings)) {
|
105 |
-
foreach ($strings as $key) {
|
106 |
-
echo wooccm_wpml_string($key) . ', ';
|
107 |
-
}
|
108 |
-
} else {
|
109 |
-
echo $strings;
|
110 |
-
}
|
111 |
-
} else {
|
112 |
-
echo '-';
|
113 |
-
}
|
114 |
-
echo '
|
115 |
-
</td>
|
116 |
-
</tr>';
|
117 |
-
} elseif ($btn['type'] == 'wooccmupload') {
|
118 |
-
$info = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
|
119 |
-
if (!empty($info)) {
|
120 |
-
// Check for delimiter
|
121 |
-
if (strstr($info, '||') !== false)
|
122 |
-
$info = explode('||', $info);
|
123 |
-
else if (strstr($info, ',') !== false)
|
124 |
-
$info = explode(',', $info);
|
125 |
-
else if (is_numeric($info))
|
126 |
-
$info = array($info);
|
127 |
-
if (is_array($info)) {
|
128 |
-
$num_files = count($info);
|
129 |
-
if (!empty($num_files))
|
130 |
-
$info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
|
131 |
-
else
|
132 |
-
$info = '-';
|
133 |
-
} else {
|
134 |
-
$info = '-';
|
135 |
-
}
|
136 |
-
} else {
|
137 |
-
$info = '-';
|
138 |
-
}
|
139 |
-
|
140 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
141 |
-
echo '
|
142 |
-
<tr>
|
143 |
-
<th>' . wooccm_wpml_string(trim($btn['label'])) . ':</th>
|
144 |
-
<td>' . $info . '</td>
|
145 |
-
</tr>';
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
$inc--;
|
151 |
-
}
|
152 |
-
|
153 |
-
$options = get_option('wccs_settings');
|
154 |
-
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
155 |
-
if (!empty($buttons)) {
|
156 |
-
foreach ($buttons as $btn) {
|
157 |
-
|
158 |
-
if (
|
159 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
160 |
-
!empty($btn['label']) &&
|
161 |
-
empty($btn['deny_receipt']) &&
|
162 |
-
$btn['type'] !== 'heading' &&
|
163 |
-
$btn['type'] !== 'wooccmupload' &&
|
164 |
-
$btn['type'] !== 'multiselect' &&
|
165 |
-
$btn['type'] !== 'multicheckbox'
|
166 |
-
) {
|
167 |
-
$value = get_post_meta($order_id, $btn['cow'], true);
|
168 |
-
if ($value == '1')
|
169 |
-
$value = __('Yes', 'woocommerce-checkout-manager');
|
170 |
-
else if ($value == '0')
|
171 |
-
$value = __('No', 'woocommerce-checkout-manager');
|
172 |
-
echo '
|
173 |
-
<tr>
|
174 |
-
<th>' . wooccm_wpml_string($btn['label']) . ':</th>
|
175 |
-
<td data-title="' . wooccm_wpml_string($btn['label']) . '">' . nl2br($value) . '</td>
|
176 |
-
</tr>';
|
177 |
-
} elseif (
|
178 |
-
!empty($btn['label']) &&
|
179 |
-
empty($btn['deny_receipt']) &&
|
180 |
-
$btn['type'] !== 'wooccmupload' &&
|
181 |
-
$btn['type'] !== 'multiselect' &&
|
182 |
-
$btn['type'] !== 'multicheckbox' &&
|
183 |
-
$btn['type'] == 'heading'
|
184 |
-
) {
|
185 |
-
echo '
|
186 |
-
<tr>
|
187 |
-
<th colspan="2">' . wooccm_wpml_string($btn['label']) . '</th>
|
188 |
-
</tr>';
|
189 |
-
} elseif (
|
190 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
191 |
-
!empty($btn['label']) &&
|
192 |
-
empty($btn['deny_receipt']) &&
|
193 |
-
$btn['type'] !== 'heading' &&
|
194 |
-
$btn['type'] !== 'wooccmupload' &&
|
195 |
-
(
|
196 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
197 |
-
)
|
198 |
-
) {
|
199 |
-
$value = get_post_meta($order_id, $btn['cow'], true);
|
200 |
-
$strings = maybe_unserialize($value);
|
201 |
-
echo '
|
202 |
-
<tr>
|
203 |
-
<th>' . wooccm_wpml_string($btn['label']) . ':</th>
|
204 |
-
<td data-title="' . wooccm_wpml_string($btn['label']) . '">';
|
205 |
-
if (!empty($strings)) {
|
206 |
-
if (is_array($strings)) {
|
207 |
-
foreach ($strings as $key) {
|
208 |
-
echo wooccm_wpml_string($key) . ', ';
|
209 |
-
}
|
210 |
-
} else {
|
211 |
-
echo $strings;
|
212 |
-
}
|
213 |
-
} else {
|
214 |
-
echo '-';
|
215 |
-
}
|
216 |
-
echo '
|
217 |
-
</td>
|
218 |
-
</tr>';
|
219 |
-
} elseif ($btn['type'] == 'wooccmupload') {
|
220 |
-
$info = get_post_meta($order_id, $btn['cow'], true);
|
221 |
-
if (!empty($info)) {
|
222 |
-
// Check for delimiter
|
223 |
-
if (strstr($info, '||') !== false)
|
224 |
-
$info = explode('||', $info);
|
225 |
-
else if (strstr($info, ',') !== false)
|
226 |
-
$info = explode(',', $info);
|
227 |
-
else if (is_numeric($info))
|
228 |
-
$info = array($info);
|
229 |
-
if (is_array($info)) {
|
230 |
-
$num_files = count($info);
|
231 |
-
if (!empty($num_files))
|
232 |
-
$info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
|
233 |
-
else
|
234 |
-
$info = '-';
|
235 |
-
} else {
|
236 |
-
$info = '-';
|
237 |
-
}
|
238 |
-
} else {
|
239 |
-
$info = '-';
|
240 |
-
}
|
241 |
-
|
242 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
243 |
-
echo '
|
244 |
-
<tr>
|
245 |
-
<th>' . wooccm_wpml_string(trim($btn['label'])) . ':</th>
|
246 |
-
<td data-title="' . wooccm_wpml_string(trim($btn['label'])) . '">' . $info . '</td>
|
247 |
-
</tr>';
|
248 |
-
}
|
249 |
-
}
|
250 |
-
}
|
251 |
-
|
252 |
-
if ($print_table) {
|
253 |
-
echo '</table>';
|
254 |
-
echo '<!-- .wccs_custom_fields -->';
|
255 |
-
}
|
256 |
-
} else {
|
257 |
-
|
258 |
-
// @mod - Legacy support below WooCommerce 2.3
|
259 |
-
echo '<div class="wccs_custom_fields">';
|
260 |
-
|
261 |
-
foreach ($names as $name) {
|
262 |
-
|
263 |
-
$array = ( $name == 'billing' ) ? $billing : $shipping;
|
264 |
-
|
265 |
-
$options = get_option('wccs_settings' . $inc);
|
266 |
-
if (!empty($options[sprintf('%s_buttons', $name)])) {
|
267 |
-
foreach ($options[sprintf('%s_buttons', $name)] as $btn) {
|
268 |
-
|
269 |
-
if (!in_array($btn['cow'], $array)) {
|
270 |
-
if (
|
271 |
-
( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
|
272 |
-
!empty($btn['label']) &&
|
273 |
-
empty($btn['deny_receipt']) &&
|
274 |
-
$btn['type'] !== 'heading' &&
|
275 |
-
$btn['type'] !== 'multiselect' &&
|
276 |
-
$btn['type'] !== 'wooccmupload' &&
|
277 |
-
$btn['type'] !== 'multicheckbox'
|
278 |
-
) {
|
279 |
-
echo '
|
280 |
-
<dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
|
281 |
-
<dd>' . nl2br(get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true)) . '</dd>';
|
282 |
-
} elseif (
|
283 |
-
!empty($btn['label']) &&
|
284 |
-
empty($btn['deny_receipt']) &&
|
285 |
-
$btn['type'] !== 'multiselect' &&
|
286 |
-
$btn['type'] !== 'multicheckbox' &&
|
287 |
-
$btn['type'] == 'heading'
|
288 |
-
) {
|
289 |
-
echo '
|
290 |
-
<h2>' . wooccm_wpml_string($btn['label']) . '</h2>';
|
291 |
-
} elseif (
|
292 |
-
( get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true) !== '' ) &&
|
293 |
-
!empty($btn['label']) &&
|
294 |
-
empty($btn['deny_receipt']) &&
|
295 |
-
$btn['type'] !== 'heading' &&
|
296 |
-
(
|
297 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
298 |
-
)
|
299 |
-
) {
|
300 |
-
$value = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
|
301 |
-
$strings = maybe_unserialize($value);
|
302 |
-
echo '
|
303 |
-
<dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
|
304 |
-
<dd>';
|
305 |
-
if (!empty($strings)) {
|
306 |
-
if (is_array($strings)) {
|
307 |
-
foreach ($strings as $key) {
|
308 |
-
echo wooccm_wpml_string($key) . ', ';
|
309 |
-
}
|
310 |
-
} else {
|
311 |
-
echo $strings;
|
312 |
-
}
|
313 |
-
} else {
|
314 |
-
echo '-';
|
315 |
-
}
|
316 |
-
echo '
|
317 |
-
</dd>';
|
318 |
-
} elseif ($btn['type'] == 'wooccmupload') {
|
319 |
-
$info = get_post_meta($order_id, sprintf('_%s_%s', $name, $btn['cow']), true);
|
320 |
-
if (!empty($info)) {
|
321 |
-
// Check for delimiter
|
322 |
-
if (strstr($info, '||') !== false)
|
323 |
-
$info = explode('||', $info);
|
324 |
-
else if (strstr($info, ',') !== false)
|
325 |
-
$info = explode(',', $info);
|
326 |
-
else if (is_numeric($info))
|
327 |
-
$info = array($info);
|
328 |
-
if (is_array($info)) {
|
329 |
-
$num_files = count($info);
|
330 |
-
if (!empty($num_files))
|
331 |
-
$info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
|
332 |
-
else
|
333 |
-
$info = '-';
|
334 |
-
} else {
|
335 |
-
$info = '-';
|
336 |
-
}
|
337 |
-
} else {
|
338 |
-
$info = '-';
|
339 |
-
}
|
340 |
-
|
341 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
342 |
-
echo '
|
343 |
-
<dt>' . wooccm_wpml_string(trim($btn['label'])) . ':</dt>
|
344 |
-
<dd>' . $info . '</dd>';
|
345 |
-
}
|
346 |
-
}
|
347 |
-
}
|
348 |
-
}
|
349 |
-
$inc--;
|
350 |
-
}
|
351 |
-
|
352 |
-
$options = get_option('wccs_settings');
|
353 |
-
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
354 |
-
if (!empty($buttons)) {
|
355 |
-
foreach ($buttons as $btn) {
|
356 |
-
|
357 |
-
if (
|
358 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
359 |
-
!empty($btn['label']) &&
|
360 |
-
empty($btn['deny_receipt']) &&
|
361 |
-
$btn['type'] !== 'heading' &&
|
362 |
-
$btn['type'] !== 'multicheckbox' &&
|
363 |
-
(
|
364 |
-
$btn['type'] !== 'wooccmupload' && $btn['type'] !== 'multiselect'
|
365 |
-
)
|
366 |
-
) {
|
367 |
-
echo '
|
368 |
-
<dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
|
369 |
-
<dd>' . nl2br(get_post_meta($order_id, $btn['cow'], true)) . '</dd>';
|
370 |
-
} elseif (
|
371 |
-
!empty($btn['label']) &&
|
372 |
-
empty($btn['deny_receipt']) &&
|
373 |
-
$btn['type'] !== 'wooccmupload' &&
|
374 |
-
$btn['type'] !== 'multiselect' &&
|
375 |
-
$btn['type'] !== 'multicheckbox' &&
|
376 |
-
$btn['type'] == 'heading'
|
377 |
-
) {
|
378 |
-
echo '
|
379 |
-
<h2>' . wooccm_wpml_string($btn['label']) . '</h2>';
|
380 |
-
} elseif (
|
381 |
-
( get_post_meta($order_id, $btn['cow'], true) !== '' ) &&
|
382 |
-
!empty($btn['label']) &&
|
383 |
-
empty($btn['deny_receipt']) &&
|
384 |
-
$btn['type'] !== 'heading' &&
|
385 |
-
$btn['type'] !== 'wooccmupload' &&
|
386 |
-
(
|
387 |
-
$btn['type'] == 'multiselect' || $btn['type'] == 'multicheckbox'
|
388 |
-
)
|
389 |
-
) {
|
390 |
-
$value = get_post_meta($order_id, $btn['cow'], true);
|
391 |
-
$strings = maybe_unserialize($value);
|
392 |
-
echo '
|
393 |
-
<dt>' . wooccm_wpml_string($btn['label']) . ':</dt>
|
394 |
-
<dd>';
|
395 |
-
if (!empty($strings)) {
|
396 |
-
if (is_array($strings)) {
|
397 |
-
foreach ($strings as $key) {
|
398 |
-
echo wooccm_wpml_string($key) . ', ';
|
399 |
-
}
|
400 |
-
} else {
|
401 |
-
echo $strings;
|
402 |
-
}
|
403 |
-
} else {
|
404 |
-
echo '-';
|
405 |
-
}
|
406 |
-
echo '
|
407 |
-
</dd>';
|
408 |
-
} elseif ($btn['type'] == 'wooccmupload') {
|
409 |
-
$info = get_post_meta($order_id, $btn['cow'], true);
|
410 |
-
if (!empty($info)) {
|
411 |
-
// Check for delimiter
|
412 |
-
if (strstr($info, '||') !== false)
|
413 |
-
$info = explode('||', $info);
|
414 |
-
else if (strstr($info, ',') !== false)
|
415 |
-
$info = explode(',', $info);
|
416 |
-
else if (is_numeric($info))
|
417 |
-
$info = array($info);
|
418 |
-
if (is_array($info)) {
|
419 |
-
$num_files = count($info);
|
420 |
-
if (!empty($num_files))
|
421 |
-
$info = sprintf(_n('%s file', '%s files', $num_files, 'woocommerce-checkout-manager'), number_format_i18n($num_files));
|
422 |
-
else
|
423 |
-
$info = '-';
|
424 |
-
} else {
|
425 |
-
$info = '-';
|
426 |
-
}
|
427 |
-
} else {
|
428 |
-
$info = '-';
|
429 |
-
}
|
430 |
-
|
431 |
-
$btn['label'] = (!empty($btn['force_title2']) ? $btn['force_title2'] : $btn['label'] );
|
432 |
-
echo '
|
433 |
-
<dt>' . wooccm_wpml_string(trim($btn['label'])) . ':</dt>
|
434 |
-
<dd>' . $info . '</dd>';
|
435 |
-
}
|
436 |
-
}
|
437 |
-
}
|
438 |
-
echo '</div>';
|
439 |
-
echo '<!-- .wccs_custom_fields -->';
|
440 |
-
}
|
441 |
-
}
|
442 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/templates/functions/required/add_required.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function wooccm_custom_checkout_process() {
|
4 |
-
|
5 |
-
global $woocommerce;
|
6 |
-
|
7 |
-
$options = get_option('wccs_settings');
|
8 |
-
$buttons = ( isset($options['buttons']) ? $options['buttons'] : array() );
|
9 |
-
|
10 |
-
// Check if we have any buttons
|
11 |
-
if (empty($buttons))
|
12 |
-
return;
|
13 |
-
|
14 |
-
$categoryarraycm = array();
|
15 |
-
$productsarraycm = array();
|
16 |
-
|
17 |
-
foreach ($buttons as $btn) {
|
18 |
-
|
19 |
-
foreach ($woocommerce->cart->cart_contents as $key => $values) {
|
20 |
-
$multiproductsx = ( isset($btn['single_p']) ? $btn['single_p'] : '' );
|
21 |
-
$show_field_single = ( isset($btn['single_px']) ? $btn['single_px'] : '' );
|
22 |
-
$multiproductsx_cat = ( isset($btn['single_p_cat']) ? $btn['single_p_cat'] : '' );
|
23 |
-
$show_field_single_cat = ( isset($btn['single_px_cat']) ? $btn['single_px_cat'] : '' );
|
24 |
-
|
25 |
-
$productsarraycm[] = $values['product_id'];
|
26 |
-
|
27 |
-
// Products
|
28 |
-
// hide field
|
29 |
-
// show field without more
|
30 |
-
// -----------------------------------------------------------------------
|
31 |
-
if (!empty($btn['single_px']) && empty($btn['more_content'])) {
|
32 |
-
|
33 |
-
$show_field_array = explode('||', $show_field_single);
|
34 |
-
|
35 |
-
if (in_array($values['product_id'], $show_field_array) && ( count($woocommerce->cart->cart_contents) < 2 )) {
|
36 |
-
|
37 |
-
if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
|
38 |
-
|
39 |
-
if (empty($_POST[$btn['cow']])) {
|
40 |
-
$message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
|
41 |
-
wc_add_notice($message, 'error');
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
// Products
|
48 |
-
// hide field
|
49 |
-
// show field with more
|
50 |
-
// -------------------------------------------------------------------------
|
51 |
-
|
52 |
-
//error_log('test 1');
|
53 |
-
if (!empty($btn['single_px']) && !empty($btn['more_content'])) {
|
54 |
-
|
55 |
-
//error_log('test 2');
|
56 |
-
$show_field_array = explode('||', $show_field_single);
|
57 |
-
|
58 |
-
//error_log('test 3');
|
59 |
-
if (array_intersect($productsarraycm, $show_field_array)) {
|
60 |
-
|
61 |
-
//error_log('test 4');
|
62 |
-
if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
|
63 |
-
|
64 |
-
//error_log('test 5');
|
65 |
-
if (empty($_POST[$btn['cow']])) {
|
66 |
-
$message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
|
67 |
-
wc_add_notice($message, 'error');
|
68 |
-
}
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
// Category
|
74 |
-
// hide field
|
75 |
-
// with more
|
76 |
-
// show field without more
|
77 |
-
// -----------------------------------------------------------------------
|
78 |
-
$terms = get_the_terms($values['product_id'], 'product_cat');
|
79 |
-
|
80 |
-
if (!empty($terms)) {
|
81 |
-
|
82 |
-
foreach ($terms as $term) {
|
83 |
-
|
84 |
-
$categoryarraycm[] = $term->slug;
|
85 |
-
|
86 |
-
// without more
|
87 |
-
// show field without more
|
88 |
-
if (!empty($btn['single_px_cat']) && empty($btn['more_content'])) {
|
89 |
-
|
90 |
-
$show_field_array_cat = explode('||', $show_field_single_cat);
|
91 |
-
|
92 |
-
if (in_array($term->slug, $show_field_array_cat) && ( count($woocommerce->cart->cart_contents) < 2 )) {
|
93 |
-
|
94 |
-
if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
|
95 |
-
|
96 |
-
if (empty($_POST[$btn['cow']])) {
|
97 |
-
|
98 |
-
$message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
|
99 |
-
|
100 |
-
wc_add_notice($message, 'error');
|
101 |
-
}
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
// Category
|
110 |
-
// hide field
|
111 |
-
// with more
|
112 |
-
// show field with more
|
113 |
-
// -------------------------------------------------------------------------
|
114 |
-
|
115 |
-
if (!empty($btn['single_px_cat']) && !empty($btn['more_content'])) {
|
116 |
-
|
117 |
-
$show_field_array_cat = explode('||', $show_field_single_cat);
|
118 |
-
|
119 |
-
if (array_intersect($categoryarraycm, $show_field_array_cat)) {
|
120 |
-
|
121 |
-
if (!empty($btn['checkbox']) && !empty($btn['label']) && ( $btn['type'] !== 'changename' )) {
|
122 |
-
if (empty($_POST[$btn['cow']])) {
|
123 |
-
$message = sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . wooccm_wpml_string($btn['label']) . '</strong>');
|
124 |
-
wc_add_notice($message, 'error');
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
$categoryarraycm = array();
|
131 |
-
$productsarraycm = array();
|
132 |
-
}
|
133 |
-
}
|
|