Version Description
- Fix for required validation issue with default address fields.
Download this release
Release Info
Developer | ThemeHigh |
Plugin | WooCommerce Checkout Field Editor (Manager) Pro |
Version | 1.2.0 |
Comparing to | |
See all releases |
Version 1.2.0
- assets/css/thwcfd-style.css +150 -0
- assets/css/tick.png +0 -0
- assets/css/upgrade-btn.png +0 -0
- assets/js/thwcfd-admin.js +445 -0
- checkout-form-designer.php +435 -0
- classes/class-wc-checkout-field-editor-export-handler.php +74 -0
- classes/class-wc-checkout-field-editor.php +710 -0
- readme.txt +164 -0
assets/css/thwcfd-style.css
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.woocommerce-message {
|
2 |
+
margin-top: 10px;
|
3 |
+
}
|
4 |
+
#wc_checkout_fields {
|
5 |
+
margin-top: 10px;
|
6 |
+
}
|
7 |
+
#wc_checkout_fields thead th input {
|
8 |
+
margin: 2px 0 0 0 !important;
|
9 |
+
}
|
10 |
+
#wc_checkout_fields tbody .description {
|
11 |
+
display: none;
|
12 |
+
color: #999;
|
13 |
+
}
|
14 |
+
#wc_checkout_fields tbody td {
|
15 |
+
overflow: visible !important;
|
16 |
+
padding: 7px;
|
17 |
+
cursor: move;
|
18 |
+
vertical-align: middle;
|
19 |
+
}
|
20 |
+
#wc_checkout_fields tbody td:last-child,
|
21 |
+
#wc_checkout_fields tbody th:last-child {
|
22 |
+
padding-right: 14px;
|
23 |
+
}
|
24 |
+
#wc_checkout_fields tbody input.input-text,
|
25 |
+
#wc_checkout_fields tbody td select {
|
26 |
+
width: 100%;
|
27 |
+
}
|
28 |
+
#wc_checkout_fields tfoot .description {
|
29 |
+
color: #999;
|
30 |
+
}
|
31 |
+
#wc_checkout_fields .check-column {
|
32 |
+
padding: 7px 0 7px 14px;
|
33 |
+
}
|
34 |
+
#wc_checkout_fields strong.core-field {
|
35 |
+
color: #a4688d;
|
36 |
+
}
|
37 |
+
#wc_checkout_fields .field-type,
|
38 |
+
#wc_checkout_fields .field-options,
|
39 |
+
#wc_checkout_fields span.na,
|
40 |
+
#wc_checkout_fields .field-validation {
|
41 |
+
text-align: center;
|
42 |
+
color: #aaa;
|
43 |
+
}
|
44 |
+
#wc_checkout_fields .field-type select,
|
45 |
+
#wc_checkout_fields .field-options select,
|
46 |
+
#wc_checkout_fields span.na select,
|
47 |
+
#wc_checkout_fields .field-validation select,
|
48 |
+
#wc_checkout_fields .field-type div,
|
49 |
+
#wc_checkout_fields .field-options div,
|
50 |
+
#wc_checkout_fields span.na div,
|
51 |
+
#wc_checkout_fields .field-validation div,
|
52 |
+
#wc_checkout_fields .field-type input,
|
53 |
+
#wc_checkout_fields .field-options input,
|
54 |
+
#wc_checkout_fields span.na input,
|
55 |
+
#wc_checkout_fields .field-validation input {
|
56 |
+
text-align: left;
|
57 |
+
}
|
58 |
+
#wc_checkout_fields span.na {
|
59 |
+
display: block;
|
60 |
+
}
|
61 |
+
#wc_checkout_fields .clear {
|
62 |
+
text-align: center;
|
63 |
+
}
|
64 |
+
#wc_checkout_fields tr.disabled td {
|
65 |
+
opacity: 0.3;
|
66 |
+
text-decoration: line-through;
|
67 |
+
}
|
68 |
+
#wc_checkout_fields tr.disabled td:first-child {
|
69 |
+
opacity:1;
|
70 |
+
}
|
71 |
+
tr.strikeout1 td:before {
|
72 |
+
content: " ";
|
73 |
+
position: absolute;
|
74 |
+
top: 50%;
|
75 |
+
left: 0;
|
76 |
+
border-bottom: 1px solid #FF0000;
|
77 |
+
width: 100%;
|
78 |
+
}
|
79 |
+
|
80 |
+
#wcfd_checkout_fields tr.strikeout td {
|
81 |
+
background: rgba(255, 0, 0, .4)!important;
|
82 |
+
opacity: 0.6;
|
83 |
+
text-decoration: line-through;
|
84 |
+
}
|
85 |
+
|
86 |
+
#wcfd_checkout_fields tr.thwcfd-disabled td {
|
87 |
+
opacity: 0.4;
|
88 |
+
}
|
89 |
+
#wcfd_checkout_fields tr.thwcfd-disabled td.td_select {
|
90 |
+
opacity: 1;
|
91 |
+
}
|
92 |
+
|
93 |
+
.err_msgs{
|
94 |
+
color: #FF0000;
|
95 |
+
}
|
96 |
+
|
97 |
+
.thwcfd-sections {
|
98 |
+
list-style: outside none none;
|
99 |
+
margin: 8px 0 0;
|
100 |
+
padding: 0;
|
101 |
+
font-size: 13px;
|
102 |
+
color: #666;
|
103 |
+
}
|
104 |
+
.thwcfd-sections li {
|
105 |
+
display: inline-block;
|
106 |
+
margin: 0px;
|
107 |
+
padding: 0px;
|
108 |
+
white-space: nowrap;
|
109 |
+
}
|
110 |
+
.thwcfd-sections a.current {
|
111 |
+
font-weight: 600;
|
112 |
+
border: medium none;
|
113 |
+
color: #000;
|
114 |
+
}
|
115 |
+
.thwcfd-sections a {
|
116 |
+
line-height: 2;
|
117 |
+
padding: 0.2em;
|
118 |
+
text-decoration: none;
|
119 |
+
}
|
120 |
+
|
121 |
+
.thwcfd-notice a {
|
122 |
+
display:block;
|
123 |
+
padding:0;
|
124 |
+
height: 63px;
|
125 |
+
}
|
126 |
+
.thwcfd-notice p {
|
127 |
+
margin-bottom:0px;
|
128 |
+
}
|
129 |
+
.thwcfd-notice ul {
|
130 |
+
list-style-type: none;
|
131 |
+
margin: 0px;
|
132 |
+
}
|
133 |
+
.thwcfd-notice ul li {
|
134 |
+
background:url("tick.png") no-repeat 0 50%;
|
135 |
+
padding-left: 20px;
|
136 |
+
}
|
137 |
+
|
138 |
+
.wcfd_popup_wrapper input[type="text"]:disabled, .wcfd_popup_wrapper select:disabled {
|
139 |
+
background: #f6f6f6;
|
140 |
+
}
|
141 |
+
|
142 |
+
h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
143 |
+
border-bottom: 1px solid #CCC;
|
144 |
+
padding-bottom: 0px;
|
145 |
+
padding-left: 10px;
|
146 |
+
}
|
147 |
+
|
148 |
+
/*.select2-drop {
|
149 |
+
z-index: 999999!important;
|
150 |
+
}*/
|
assets/css/tick.png
ADDED
Binary file
|
assets/css/upgrade-btn.png
ADDED
Binary file
|
assets/js/thwcfd-admin.js
ADDED
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var wcfd_settings = (function($, window, document) {
|
2 |
+
$( "#wcfd_new_field_form_pp" ).dialog({
|
3 |
+
modal: true,
|
4 |
+
width: 500,
|
5 |
+
//height: 400,
|
6 |
+
resizable: false,
|
7 |
+
autoOpen: false,
|
8 |
+
buttons: [{
|
9 |
+
text: "Add New Field",
|
10 |
+
click: function() {
|
11 |
+
var result = wcfd_add_new_row( this );
|
12 |
+
if(result){
|
13 |
+
$( this ).dialog( "close" );
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}]
|
17 |
+
});
|
18 |
+
|
19 |
+
$( "#wcfd_edit_field_form_pp" ).dialog({
|
20 |
+
modal: true,
|
21 |
+
width: 500,
|
22 |
+
//height: 400,
|
23 |
+
resizable: false,
|
24 |
+
autoOpen: false,
|
25 |
+
buttons: [{
|
26 |
+
text: "Edit Field",
|
27 |
+
click: function() {
|
28 |
+
var result = wcfd_update_row( this );
|
29 |
+
if(result){
|
30 |
+
$( this ).dialog( "close" );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}]
|
34 |
+
});
|
35 |
+
|
36 |
+
$('select.thwcfd-enhanced-multi-select').select2({
|
37 |
+
minimumResultsForSearch: 10,
|
38 |
+
allowClear : true,
|
39 |
+
placeholder: $(this).data('placeholder')
|
40 |
+
}).addClass('enhanced');
|
41 |
+
|
42 |
+
$( ".wcfd_remove_field_btn" ).click( function() {
|
43 |
+
var form = $(this.form);
|
44 |
+
|
45 |
+
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
46 |
+
$(this).closest('tr').remove();
|
47 |
+
});
|
48 |
+
});
|
49 |
+
|
50 |
+
$('#wcfd_checkout_fields tbody').sortable({
|
51 |
+
items:'tr',
|
52 |
+
cursor:'move',
|
53 |
+
axis:'y',
|
54 |
+
handle: 'td.sort',
|
55 |
+
scrollSensitivity:40,
|
56 |
+
helper:function(e,ui){
|
57 |
+
ui.children().each(function(){
|
58 |
+
$(this).width($(this).width());
|
59 |
+
});
|
60 |
+
ui.css('left', '0');
|
61 |
+
return ui;
|
62 |
+
}
|
63 |
+
});
|
64 |
+
|
65 |
+
$("#wcfd_checkout_fields tbody").on("sortstart", function( event, ui ){
|
66 |
+
ui.item.css('background-color','#f6f6f6');
|
67 |
+
});
|
68 |
+
$("#wcfd_checkout_fields tbody").on("sortstop", function( event, ui ){
|
69 |
+
ui.item.removeAttr('style');
|
70 |
+
wcfd_prepare_field_order_indexes();
|
71 |
+
});
|
72 |
+
|
73 |
+
_openNewFieldForm = function openNewFieldForm(tabName){
|
74 |
+
if(tabName == 'billing' || tabName == 'shipping' || tabName == 'additional'){
|
75 |
+
tabName = tabName+'_';
|
76 |
+
}
|
77 |
+
|
78 |
+
var form = $("#wcfd_new_field_form_pp");
|
79 |
+
wcfd_clear_form(form);
|
80 |
+
form.find("input[name=fname]").val(tabName);
|
81 |
+
form.find("select[name=ftype]").change();
|
82 |
+
form.find("input[name=fclass]").val('form-row-wide');
|
83 |
+
|
84 |
+
$( "#wcfd_new_field_form_pp" ).dialog( "open" );
|
85 |
+
}
|
86 |
+
|
87 |
+
function wcfd_add_new_row(form){
|
88 |
+
var name = $(form).find("input[name=fname]").val();
|
89 |
+
var type = $(form).find("select[name=ftype]").val();
|
90 |
+
var label = $(form).find("input[name=flabel]").val();
|
91 |
+
var placeholder = $(form).find("input[name=fplaceholder]").val();
|
92 |
+
var optionsList = $(form).find("input[name=foptions]").val();
|
93 |
+
|
94 |
+
var fieldClass = $(form).find("input[name=fclass]").val();
|
95 |
+
var labelClass = $(form).find("input[name=flabelclass]").val();
|
96 |
+
|
97 |
+
var required = $(form).find("input[name=frequired]").prop('checked');
|
98 |
+
var clearRow = $(form).find("input[name=fclearRow]").prop('checked');
|
99 |
+
var enabled = $(form).find("input[name=fenabled]").prop('checked');
|
100 |
+
|
101 |
+
var showinemail = $(form).find("input[name=fshowinemail]").prop('checked');
|
102 |
+
var showinorder = $(form).find("input[name=fshowinorder]").prop('checked');
|
103 |
+
|
104 |
+
var validations = $(form).find("select[name=fvalidate]").val();
|
105 |
+
|
106 |
+
var err_msgs = '';
|
107 |
+
if(name == ''){
|
108 |
+
err_msgs = 'Name is required';
|
109 |
+
}else if(type == ''){
|
110 |
+
err_msgs = 'Type is required';
|
111 |
+
}
|
112 |
+
|
113 |
+
if(err_msgs != ''){
|
114 |
+
$(form).find('.err_msgs').html(err_msgs);
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
required = required ? 1 : 0;
|
119 |
+
clearRow = clearRow ? 1 : 0;
|
120 |
+
enabled = enabled ? 1 : 0;
|
121 |
+
|
122 |
+
showinemail = showinemail ? 1 : 0;
|
123 |
+
showinorder = showinorder ? 1 : 0;
|
124 |
+
|
125 |
+
validations = validations ? validations : '';
|
126 |
+
|
127 |
+
var index = $('#wcfd_checkout_fields tbody tr').size();
|
128 |
+
|
129 |
+
var newRow = '<tr class="row_'+index+'">';
|
130 |
+
newRow += '<td width="1%" class="sort ui-sortable-handle">';
|
131 |
+
newRow += '<input type="hidden" name="f_order['+index+']" class="f_order" value="'+index+'" />';
|
132 |
+
newRow += '<input type="hidden" name="f_name['+index+']" class="f_name" value="" />';
|
133 |
+
newRow += '<input type="hidden" name="f_name_new['+index+']" class="f_name_new" value="'+name+'" />';
|
134 |
+
newRow += '<input type="hidden" name="f_type['+index+']" class="f_type" value="'+type+'" />';
|
135 |
+
newRow += '<input type="hidden" name="f_label['+index+']" class="f_label" value="'+label+'" />';
|
136 |
+
newRow += '<input type="hidden" name="f_placeholder['+index+']" class="f_placeholder" value="'+placeholder+'" />';
|
137 |
+
newRow += '<input type="hidden" name="f_options['+index+']" class="f_options" value="'+optionsList+'" />';
|
138 |
+
|
139 |
+
newRow += '<input type="hidden" name="f_class['+index+']" class="f_class" value="'+fieldClass+'" />';
|
140 |
+
newRow += '<input type="hidden" name="f_label_class['+index+']" class="f_label_class" value="'+labelClass+'" />';
|
141 |
+
|
142 |
+
newRow += '<input type="hidden" name="f_required['+index+']" class="f_required" value="'+required+'" />';
|
143 |
+
newRow += '<input type="hidden" name="f_clear['+index+']" class="f_clear" value="'+clearRow+'" />';
|
144 |
+
newRow += '<input type="hidden" name="f_enabled['+index+']" class="f_enabled" value="'+enabled+'" />';
|
145 |
+
|
146 |
+
newRow += '<input type="hidden" name="f_show_in_email['+index+']" class="f_show_in_email" value="'+showinemail+'" />';
|
147 |
+
newRow += '<input type="hidden" name="f_show_in_order['+index+']" class="f_show_in_order" value="'+showinorder+'" />';
|
148 |
+
|
149 |
+
newRow += '<input type="hidden" name="f_validation['+index+']" class="f_validation" value="'+validations+'" />';
|
150 |
+
newRow += '<input type="hidden" name="f_deleted['+index+']" class="f_deleted" value="0" />';
|
151 |
+
newRow += '</td>';
|
152 |
+
newRow += '<td ><input type="checkbox" /></td>';
|
153 |
+
newRow += '<td class="name">'+name+'</td>';
|
154 |
+
newRow += '<td class="id">'+type+'</td>';
|
155 |
+
newRow += '<td>'+label+'</td>';
|
156 |
+
newRow += '<td>'+placeholder+'</td>';
|
157 |
+
newRow += '<td>'+validations+'</td>';
|
158 |
+
if(required == true){
|
159 |
+
newRow += '<td class="status"><span class="status-enabled tips">Yes</span></td>';
|
160 |
+
}else{
|
161 |
+
newRow += '<td class="status">-</td>';
|
162 |
+
}
|
163 |
+
if(clearRow == true){
|
164 |
+
newRow += '<td class="status"><span class="status-enabled tips">Yes</span></td>';
|
165 |
+
}else{
|
166 |
+
newRow += '<td class="status">-</td>';
|
167 |
+
}
|
168 |
+
if(enabled == true){
|
169 |
+
newRow += '<td class="status"><span class="status-enabled tips">Yes</span></td>';
|
170 |
+
}else{
|
171 |
+
newRow += '<td class="status">-</td>';
|
172 |
+
}
|
173 |
+
|
174 |
+
newRow += '<td><button type="button" onclick="openEditFieldForm(this)">Edit</button></td>';
|
175 |
+
newRow += '</tr>';
|
176 |
+
|
177 |
+
$('#wcfd_checkout_fields tbody tr:last').after(newRow);
|
178 |
+
return true;
|
179 |
+
}
|
180 |
+
|
181 |
+
_openEditFieldForm = function openEditFieldForm(elm, rowId){
|
182 |
+
var row = $(elm).closest('tr')
|
183 |
+
|
184 |
+
var is_custom = row.find(".f_custom").val();
|
185 |
+
var name = row.find(".f_name").val();
|
186 |
+
var type = row.find(".f_type").val();
|
187 |
+
var label = row.find(".f_label").val();
|
188 |
+
var placeholder = row.find(".f_placeholder").val();
|
189 |
+
var optionsList = row.find(".f_options").val();
|
190 |
+
|
191 |
+
var field_classes = row.find(".f_class").val();
|
192 |
+
var label_classes = row.find(".f_label_class").val();
|
193 |
+
|
194 |
+
var required = row.find(".f_required").val();
|
195 |
+
var clearRow = row.find(".f_clear").val();
|
196 |
+
|
197 |
+
var enabled = row.find(".f_enabled").val();
|
198 |
+
var validations = row.find(".f_validation").val();
|
199 |
+
|
200 |
+
var showinemail = row.find(".f_show_in_email").val();
|
201 |
+
var showinorder = row.find(".f_show_in_order").val();
|
202 |
+
|
203 |
+
is_custom = is_custom == 1 ? true : false;
|
204 |
+
|
205 |
+
required = required == 1 ? true : false;
|
206 |
+
clearRow = clearRow == 1 ? true : false;
|
207 |
+
enabled = enabled == 1 ? true : false;
|
208 |
+
|
209 |
+
validations = validations.split(",");
|
210 |
+
|
211 |
+
showinemail = showinemail == 1 ? true : false;
|
212 |
+
showinorder = showinorder == 1 ? true : false;
|
213 |
+
|
214 |
+
showinemail = is_custom == true ? showinemail : true;
|
215 |
+
showinorder = is_custom == true ? showinorder : true;
|
216 |
+
|
217 |
+
var form = $("#wcfd_edit_field_form_pp");
|
218 |
+
form.find("input[name=rowId]").val(rowId);
|
219 |
+
form.find("input[name=fname]").val(name);
|
220 |
+
form.find("input[name=fnameNew]").val(name);
|
221 |
+
form.find("select[name=ftype]").val(type);
|
222 |
+
form.find("input[name=flabel]").val(label);
|
223 |
+
form.find("input[name=fplaceholder]").val(placeholder);
|
224 |
+
form.find("input[name=foptions]").val(optionsList);
|
225 |
+
|
226 |
+
form.find("input[name=fclass]").val(field_classes);
|
227 |
+
form.find("input[name=flabelclass]").val(label_classes);
|
228 |
+
form.find("select[name=fvalidate]").val(validations).trigger("change");
|
229 |
+
|
230 |
+
form.find("input[name=frequired]").prop('checked', required);
|
231 |
+
form.find("input[name=fclearRow]").prop('checked', clearRow);
|
232 |
+
form.find("input[name=fenabled]").prop('checked', enabled);
|
233 |
+
|
234 |
+
form.find("input[name=fshowinemail]").prop('checked', showinemail);
|
235 |
+
form.find("input[name=fshowinorder]").prop('checked', showinorder);
|
236 |
+
|
237 |
+
form.find("select[name=ftype]").change();
|
238 |
+
$( "#wcfd_edit_field_form_pp" ).dialog( "open" );
|
239 |
+
|
240 |
+
/*if(type == 'email' || type == 'tel' || type == 'country' || type == 'state'){
|
241 |
+
|
242 |
+
}*/
|
243 |
+
|
244 |
+
if(is_custom == false){
|
245 |
+
form.find("input[name=fnameNew]").prop('disabled', true);
|
246 |
+
form.find("select[name=ftype]").prop('disabled', true);
|
247 |
+
form.find("input[name=fshowinemail]").prop('disabled', true);
|
248 |
+
form.find("input[name=fshowinorder]").prop('disabled', true);
|
249 |
+
form.find("input[name=flabel]").focus();
|
250 |
+
}else{
|
251 |
+
form.find("input[name=fnameNew]").prop('disabled', false);
|
252 |
+
form.find("select[name=ftype]").prop('disabled', false);
|
253 |
+
form.find("input[name=fshowinemail]").prop('disabled', false);
|
254 |
+
form.find("input[name=fshowinorder]").prop('disabled', false);
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
function wcfd_update_row(form){
|
259 |
+
var rowId = $(form).find("input[name=rowId]").val();
|
260 |
+
|
261 |
+
var name = $(form).find("input[name=fnameNew]").val();
|
262 |
+
var type = $(form).find("select[name=ftype]").val();
|
263 |
+
var label = $(form).find("input[name=flabel]").val();
|
264 |
+
var placeholder = $(form).find("input[name=fplaceholder]").val();
|
265 |
+
var optionsList = $(form).find("input[name=foptions]").val();
|
266 |
+
|
267 |
+
var fieldClass = $(form).find("input[name=fclass]").val();
|
268 |
+
var labelClass = $(form).find("input[name=flabelclass]").val();
|
269 |
+
|
270 |
+
var required = $(form).find("input[name=frequired]").prop('checked');
|
271 |
+
var clearRow = $(form).find("input[name=fclearRow]").prop('checked');
|
272 |
+
var enabled = $(form).find("input[name=fenabled]").prop('checked');
|
273 |
+
|
274 |
+
var showinemail = $(form).find("input[name=fshowinemail]").prop('checked');
|
275 |
+
var showinorder = $(form).find("input[name=fshowinorder]").prop('checked');
|
276 |
+
|
277 |
+
var validations = $(form).find("select[name=fvalidate]").val();
|
278 |
+
|
279 |
+
var err_msgs = '';
|
280 |
+
if(name == ''){
|
281 |
+
err_msgs = 'Name is required';
|
282 |
+
}else if(type == ''){
|
283 |
+
err_msgs = 'Type is required';
|
284 |
+
}
|
285 |
+
|
286 |
+
if(err_msgs != ''){
|
287 |
+
$(form).find('.err_msgs').html(err_msgs);
|
288 |
+
return false;
|
289 |
+
}
|
290 |
+
|
291 |
+
required = required ? 1 : 0;
|
292 |
+
clearRow = clearRow ? 1 : 0;
|
293 |
+
enabled = enabled ? 1 : 0;
|
294 |
+
|
295 |
+
showinemail = showinemail ? 1 : 0;
|
296 |
+
showinorder = showinorder ? 1 : 0;
|
297 |
+
|
298 |
+
validations = validations ? validations : '';
|
299 |
+
|
300 |
+
var row = $('#wcfd_checkout_fields tbody').find('.row_'+rowId);
|
301 |
+
row.find(".f_name").val(name);
|
302 |
+
row.find(".f_type").val(type);
|
303 |
+
row.find(".f_label").val(label);
|
304 |
+
row.find(".f_placeholder").val(placeholder);
|
305 |
+
row.find(".f_options").val(optionsList);
|
306 |
+
|
307 |
+
row.find(".f_class").val(fieldClass);
|
308 |
+
row.find(".f_label_class").val(labelClass);
|
309 |
+
|
310 |
+
row.find(".f_required").val(required);
|
311 |
+
row.find(".f_clear").val(clearRow);
|
312 |
+
row.find(".f_enabled").val(enabled);
|
313 |
+
|
314 |
+
row.find(".f_show_in_email").val(showinemail);
|
315 |
+
row.find(".f_show_in_order").val(showinorder);
|
316 |
+
row.find(".f_validation").val(validations);
|
317 |
+
|
318 |
+
row.find(".td_name").html(name);
|
319 |
+
row.find(".td_type").html(type);
|
320 |
+
row.find(".td_label").html(label);
|
321 |
+
row.find(".td_placeholder").html(placeholder);
|
322 |
+
row.find(".td_validate").html(""+validations+"");
|
323 |
+
row.find(".td_required").html(required == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
324 |
+
row.find(".td_clear").html(clearRow == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
325 |
+
row.find(".td_enabled").html(enabled == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
|
329 |
+
_removeSelectedFields = function removeSelectedFields(){
|
330 |
+
$('#wcfd_checkout_fields tbody tr').removeClass('strikeout');
|
331 |
+
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
332 |
+
//$(this).closest('tr').remove();
|
333 |
+
var row = $(this).closest('tr');
|
334 |
+
if(!row.hasClass("strikeout")){
|
335 |
+
row.addClass("strikeout");
|
336 |
+
}
|
337 |
+
row.find(".f_deleted").val(1);
|
338 |
+
row.find(".f_edit_btn").prop('disabled', true);
|
339 |
+
//row.find('.sort').removeClass('sort');
|
340 |
+
});
|
341 |
+
}
|
342 |
+
|
343 |
+
_enableDisableSelectedFields = function enableDisableSelectedFields(enabled){
|
344 |
+
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
345 |
+
var row = $(this).closest('tr');
|
346 |
+
if(enabled == 0){
|
347 |
+
if(!row.hasClass("thwcfd-disabled")){
|
348 |
+
row.addClass("thwcfd-disabled");
|
349 |
+
}
|
350 |
+
}else{
|
351 |
+
row.removeClass("thwcfd-disabled");
|
352 |
+
}
|
353 |
+
|
354 |
+
row.find(".f_edit_btn").prop('disabled', enabled == 1 ? false : true);
|
355 |
+
row.find(".td_enabled").html(enabled == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
356 |
+
row.find(".f_enabled").val(enabled);
|
357 |
+
});
|
358 |
+
}
|
359 |
+
|
360 |
+
function wcfd_clear_form( form ){
|
361 |
+
form.find("input[name=fname]").val('');
|
362 |
+
form.find("input[name=fnameNew]").val('');
|
363 |
+
form.find("select[name=ftype]").prop('selectedIndex',0);
|
364 |
+
form.find("input[name=flabel]").val('');
|
365 |
+
form.find("input[name=fplaceholder]").val('');
|
366 |
+
form.find("input[name=foptions]").val('');
|
367 |
+
|
368 |
+
form.find("input[name=fclass]").val('');
|
369 |
+
form.find("input[name=flabelclass]").val('');
|
370 |
+
form.find("select[name=fvalidate] option:selected").removeProp('selected');
|
371 |
+
|
372 |
+
form.find("input[name=frequired]").prop('checked', true);
|
373 |
+
form.find("input[name=fclearRow]").prop('checked', true);
|
374 |
+
form.find("input[name=fenabled]").prop('checked', true);
|
375 |
+
form.find("input[name=fshowinemail]").prop('checked', true);
|
376 |
+
form.find("input[name=fshowinorder]").prop('checked', true);
|
377 |
+
}
|
378 |
+
|
379 |
+
function wcfd_prepare_field_order_indexes() {
|
380 |
+
$('#wcfd_checkout_fields tbody tr').each(function(index, el){
|
381 |
+
$('input.f_order', el).val( parseInt( $(el).index('#wcfd_checkout_fields tbody tr') ) );
|
382 |
+
});
|
383 |
+
};
|
384 |
+
|
385 |
+
_fieldTypeChangeListner = function fieldTypeChangeListner(elm){
|
386 |
+
var type = $(elm).val();
|
387 |
+
var form = $(elm).closest('form');
|
388 |
+
|
389 |
+
showAllFields(form);
|
390 |
+
if(type === 'select'){
|
391 |
+
form.find('.rowPlaceholder').hide();
|
392 |
+
form.find('.rowValidate').hide();
|
393 |
+
}else{
|
394 |
+
form.find('.rowOptions').hide();
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
function showAllFields(form){
|
399 |
+
form.find('.rowOptions').show();
|
400 |
+
form.find('.rowPlaceholder').show();
|
401 |
+
form.find('.rowValidate').show();
|
402 |
+
}
|
403 |
+
|
404 |
+
_selectAllCheckoutFields = function selectAllCheckoutFields(elm){
|
405 |
+
var checkAll = $(elm).prop('checked');
|
406 |
+
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
407 |
+
}
|
408 |
+
|
409 |
+
return {
|
410 |
+
openNewFieldForm : _openNewFieldForm,
|
411 |
+
openEditFieldForm : _openEditFieldForm,
|
412 |
+
removeSelectedFields : _removeSelectedFields,
|
413 |
+
enableDisableSelectedFields : _enableDisableSelectedFields,
|
414 |
+
fieldTypeChangeListner : _fieldTypeChangeListner,
|
415 |
+
selectAllCheckoutFields : _selectAllCheckoutFields,
|
416 |
+
};
|
417 |
+
}(window.jQuery, window, document));
|
418 |
+
|
419 |
+
function openNewFieldForm(tabName){
|
420 |
+
wcfd_settings.openNewFieldForm(tabName);
|
421 |
+
}
|
422 |
+
|
423 |
+
function openEditFieldForm(elm, rowId){
|
424 |
+
wcfd_settings.openEditFieldForm(elm, rowId);
|
425 |
+
}
|
426 |
+
|
427 |
+
function removeSelectedFields(){
|
428 |
+
wcfd_settings.removeSelectedFields();
|
429 |
+
}
|
430 |
+
|
431 |
+
function enableSelectedFields(){
|
432 |
+
wcfd_settings.enableDisableSelectedFields(1);
|
433 |
+
}
|
434 |
+
|
435 |
+
function disableSelectedFields(){
|
436 |
+
wcfd_settings.enableDisableSelectedFields(0);
|
437 |
+
}
|
438 |
+
|
439 |
+
function fieldTypeChangeListner(elm){
|
440 |
+
wcfd_settings.fieldTypeChangeListner(elm);
|
441 |
+
}
|
442 |
+
|
443 |
+
function thwcfdSelectAllCheckoutFields(elm){
|
444 |
+
wcfd_settings.selectAllCheckoutFields(elm);
|
445 |
+
}
|
checkout-form-designer.php
ADDED
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Woo Checkout Field Editor Pro
|
4 |
+
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
+
* Author: ThemeHiGH
|
6 |
+
* Version: 1.2.0
|
7 |
+
* Author URI: https://www.themehigh.com
|
8 |
+
* Plugin URI: https://www.themehigh.com
|
9 |
+
* Text Domain: thwcfd
|
10 |
+
* Domain Path: /languages
|
11 |
+
*/
|
12 |
+
|
13 |
+
if(!defined( 'ABSPATH' )) exit;
|
14 |
+
|
15 |
+
if (!function_exists('is_woocommerce_active')){
|
16 |
+
function is_woocommerce_active(){
|
17 |
+
$active_plugins = (array) get_option('active_plugins', array());
|
18 |
+
if(is_multisite()){
|
19 |
+
$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
|
20 |
+
}
|
21 |
+
return in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
if(is_woocommerce_active()) {
|
26 |
+
load_plugin_textdomain( 'thwcfd', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
27 |
+
|
28 |
+
/**
|
29 |
+
* woocommerce_init_checkout_field_editor function.
|
30 |
+
*/
|
31 |
+
function thwcfd_init_checkout_field_editor_lite() {
|
32 |
+
global $supress_field_modification;
|
33 |
+
$supress_field_modification = false;
|
34 |
+
|
35 |
+
if(!class_exists('WC_Checkout_Field_Editor')){
|
36 |
+
require_once('classes/class-wc-checkout-field-editor.php');
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!class_exists('WC_Checkout_Field_Editor_Export_Handler')){
|
40 |
+
require_once('classes/class-wc-checkout-field-editor-export-handler.php');
|
41 |
+
}
|
42 |
+
new WC_Checkout_Field_Editor_Export_Handler();
|
43 |
+
|
44 |
+
$GLOBALS['WC_Checkout_Field_Editor'] = new WC_Checkout_Field_Editor();
|
45 |
+
}
|
46 |
+
add_action('init', 'thwcfd_init_checkout_field_editor_lite');
|
47 |
+
|
48 |
+
function thwcfd_is_locale_field( $field_name ){
|
49 |
+
if(!empty($field_name) && in_array($field_name, array(
|
50 |
+
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
51 |
+
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
52 |
+
))){
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
function thwcfd_woocommerce_version_check( $version = '3.0' ) {
|
59 |
+
if(function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
|
60 |
+
global $woocommerce;
|
61 |
+
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Hide Additional Fields title if no fields available.
|
70 |
+
*
|
71 |
+
* @param mixed $old
|
72 |
+
*/
|
73 |
+
function thwcfd_enable_order_notes_field() {
|
74 |
+
global $supress_field_modification;
|
75 |
+
|
76 |
+
if($supress_field_modification){
|
77 |
+
return $fields;
|
78 |
+
}
|
79 |
+
|
80 |
+
$additional_fields = get_option('wc_fields_additional');
|
81 |
+
if(is_array($additional_fields)){
|
82 |
+
$enabled = 0;
|
83 |
+
foreach($additional_fields as $field){
|
84 |
+
if($field['enabled']){
|
85 |
+
$enabled++;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return $enabled > 0 ? true : false;
|
89 |
+
}
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
add_filter('woocommerce_enable_order_notes_field', 'thwcfd_enable_order_notes_field', 1000);
|
93 |
+
|
94 |
+
function thwcfd_woo_default_address_fields( $original ) {
|
95 |
+
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
96 |
+
$address_fields = get_option('wc_fields_'.$sname);
|
97 |
+
|
98 |
+
if(is_array($address_fields) && !empty($address_fields) && !empty($original)){
|
99 |
+
$override_required = apply_filters( 'thwcfd_address_field_override_required', true );
|
100 |
+
|
101 |
+
foreach($original as $name => $ofield) {
|
102 |
+
$fname = $sname.'_'.$name;
|
103 |
+
|
104 |
+
if(thwcfd_is_locale_field($fname) && $override_required){
|
105 |
+
$new_field = isset($address_fields[$fname]) ? $address_fields[$fname] : false;
|
106 |
+
|
107 |
+
if($new_field && !( isset($new_field['enabled']) && $new_field['enabled'] == false )){
|
108 |
+
$original[$name]['required'] = isset($new_field['required']) && $new_field['required'] ? true : false;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return $original;
|
115 |
+
}
|
116 |
+
add_filter('woocommerce_default_address_fields' , 'thwcfd_woo_default_address_fields' );
|
117 |
+
|
118 |
+
function thwcfd_prepare_country_locale($fields) {
|
119 |
+
if(is_array($fields)){
|
120 |
+
foreach($fields as $key => $props){
|
121 |
+
$override_ph = apply_filters( 'thwcfd_address_field_override_placeholder', true );
|
122 |
+
$override_label = apply_filters( 'thwcfd_address_field_override_label', true );
|
123 |
+
$override_required = apply_filters( 'thwcfd_address_field_override_required', false );
|
124 |
+
|
125 |
+
if($override_ph && isset($props['placeholder'])){
|
126 |
+
unset($fields[$key]['placeholder']);
|
127 |
+
}
|
128 |
+
if($override_label && isset($props['label'])){
|
129 |
+
unset($fields[$key]['label']);
|
130 |
+
}
|
131 |
+
if($override_required && isset($props['required'])){
|
132 |
+
unset($fields[$key]['required']);
|
133 |
+
}
|
134 |
+
|
135 |
+
if(isset($props['priority'])){
|
136 |
+
unset($fields[$key]['priority']);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
return $fields;
|
141 |
+
}
|
142 |
+
add_filter('woocommerce_get_country_locale_default', 'thwcfd_prepare_country_locale');
|
143 |
+
add_filter('woocommerce_get_country_locale_base', 'thwcfd_prepare_country_locale');
|
144 |
+
|
145 |
+
function thwcfd_woo_get_country_locale($locale) {
|
146 |
+
if(is_array($locale)){
|
147 |
+
foreach($locale as $country => $fields){
|
148 |
+
$locale[$country] = thwcfd_prepare_country_locale($fields);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
return $locale;
|
152 |
+
}
|
153 |
+
add_filter('woocommerce_get_country_locale', 'thwcfd_woo_get_country_locale');
|
154 |
+
|
155 |
+
/**
|
156 |
+
* wc_checkout_fields_modify_billing_fields function.
|
157 |
+
*
|
158 |
+
* @param mixed $old
|
159 |
+
*/
|
160 |
+
function thwcfd_billing_fields_lite($old){
|
161 |
+
global $supress_field_modification;
|
162 |
+
|
163 |
+
if($supress_field_modification){
|
164 |
+
return $old;
|
165 |
+
}
|
166 |
+
|
167 |
+
return thwcfd_prepare_checkout_fields_lite(get_option('wc_fields_billing'), $old);
|
168 |
+
}
|
169 |
+
add_filter('woocommerce_billing_fields', 'thwcfd_billing_fields_lite', 1000);
|
170 |
+
|
171 |
+
/**
|
172 |
+
* wc_checkout_fields_modify_shipping_fields function.
|
173 |
+
*
|
174 |
+
* @param mixed $old
|
175 |
+
*/
|
176 |
+
function thwcfd_shipping_fields_lite($old){
|
177 |
+
global $supress_field_modification;
|
178 |
+
|
179 |
+
if ($supress_field_modification){
|
180 |
+
return $old;
|
181 |
+
}
|
182 |
+
|
183 |
+
return thwcfd_prepare_checkout_fields_lite(get_option('wc_fields_shipping'), $old);
|
184 |
+
}
|
185 |
+
add_filter('woocommerce_shipping_fields', 'thwcfd_shipping_fields_lite', 1000);
|
186 |
+
|
187 |
+
/**
|
188 |
+
* wc_checkout_fields_modify_shipping_fields function.
|
189 |
+
*
|
190 |
+
* @param mixed $old
|
191 |
+
*/
|
192 |
+
function thwcfd_checkout_fields_lite( $fields ) {
|
193 |
+
global $supress_field_modification;
|
194 |
+
|
195 |
+
if($supress_field_modification){
|
196 |
+
return $fields;
|
197 |
+
}
|
198 |
+
|
199 |
+
if($additional_fields = get_option('wc_fields_additional')){
|
200 |
+
if( isset($fields['order']) && is_array($fields['order']) ){
|
201 |
+
$fields['order'] = $additional_fields + $fields['order'];
|
202 |
+
}
|
203 |
+
|
204 |
+
// check if order_comments is enabled/disabled
|
205 |
+
if(isset($additional_fields) && !$additional_fields['order_comments']['enabled']){
|
206 |
+
unset($fields['order']['order_comments']);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
if(isset($fields['order']) && is_array($fields['order'])){
|
211 |
+
$fields['order'] = thwcfd_prepare_checkout_fields_lite($fields['order'], false);
|
212 |
+
}
|
213 |
+
|
214 |
+
return $fields;
|
215 |
+
}
|
216 |
+
add_filter('woocommerce_checkout_fields', 'thwcfd_checkout_fields_lite', 1000);
|
217 |
+
|
218 |
+
/**
|
219 |
+
* checkout_fields_modify_fields function.
|
220 |
+
*
|
221 |
+
* @param mixed $data
|
222 |
+
* @param mixed $old
|
223 |
+
*/
|
224 |
+
function thwcfd_prepare_checkout_fields_lite($fields, $original_fields) {
|
225 |
+
if(is_array($fields) && !empty($fields)) {
|
226 |
+
foreach($fields as $name => $field) {
|
227 |
+
if(isset($field['enabled']) && $field['enabled'] == false ) {
|
228 |
+
unset($fields[$name]);
|
229 |
+
}else{
|
230 |
+
$new_field = false;
|
231 |
+
|
232 |
+
if($original_fields && isset($original_fields[$name])){
|
233 |
+
$new_field = $original_fields[$name];
|
234 |
+
|
235 |
+
$new_field['label'] = isset($field['label']) ? $field['label'] : '';
|
236 |
+
$new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
|
237 |
+
|
238 |
+
$new_field['class'] = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
|
239 |
+
$new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
|
240 |
+
$new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
|
241 |
+
|
242 |
+
if(!thwcfd_is_locale_field($name)){
|
243 |
+
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
244 |
+
}
|
245 |
+
$new_field['clear'] = isset($field['clear']) ? $field['clear'] : 0;
|
246 |
+
}else{
|
247 |
+
$new_field = $field;
|
248 |
+
}
|
249 |
+
|
250 |
+
$new_field['order'] = isset($field['order']) && is_numeric($field['order']) ? $field['order'] : 0;
|
251 |
+
if(isset($new_field['order']) && is_numeric($new_field['order'])){
|
252 |
+
$new_field['priority'] = $new_field['order'];
|
253 |
+
}
|
254 |
+
|
255 |
+
if(isset($new_field['label'])){
|
256 |
+
$new_field['label'] = __($new_field['label'], 'woocommerce');
|
257 |
+
}
|
258 |
+
if(isset($new_field['placeholder'])){
|
259 |
+
$new_field['placeholder'] = __($new_field['placeholder'], 'woocommerce');
|
260 |
+
}
|
261 |
+
|
262 |
+
$fields[$name] = $new_field;
|
263 |
+
}
|
264 |
+
}
|
265 |
+
return $fields;
|
266 |
+
}else {
|
267 |
+
return $original_fields;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/*****************************************
|
272 |
+
----- Display Field Values - START ------
|
273 |
+
*****************************************/
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Display custom fields in emails
|
277 |
+
*
|
278 |
+
* @param array $keys
|
279 |
+
* @return array
|
280 |
+
*/
|
281 |
+
function thwcfd_display_custom_fields_in_emails_lite($keys){
|
282 |
+
$custom_keys = array();
|
283 |
+
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
284 |
+
WC_Checkout_Field_Editor::get_fields('additional'));
|
285 |
+
|
286 |
+
// Loop through all custom fields to see if it should be added
|
287 |
+
foreach( $fields as $name => $options ) {
|
288 |
+
if(isset($options['show_in_email']) && $options['show_in_email']){
|
289 |
+
$custom_keys[ esc_attr( $options['label'] ) ] = esc_attr( $name );
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
return array_merge( $keys, $custom_keys );
|
294 |
+
}
|
295 |
+
add_filter('woocommerce_email_order_meta_keys', 'thwcfd_display_custom_fields_in_emails_lite', 10, 1);
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Display custom checkout fields on view order pages
|
299 |
+
*
|
300 |
+
* @param object $order
|
301 |
+
*/
|
302 |
+
function thwcfd_order_details_after_customer_details_lite($order){
|
303 |
+
if(thwcfd_woocommerce_version_check()){
|
304 |
+
$order_id = $order->get_id();
|
305 |
+
}else{
|
306 |
+
$order_id = $order->id;
|
307 |
+
}
|
308 |
+
|
309 |
+
$fields = array();
|
310 |
+
if(!wc_ship_to_billing_address_only() && $order->needs_shipping_address()){
|
311 |
+
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
312 |
+
WC_Checkout_Field_Editor::get_fields('additional'));
|
313 |
+
}else{
|
314 |
+
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('additional'));
|
315 |
+
}
|
316 |
+
|
317 |
+
// Loop through all custom fields to see if it should be added
|
318 |
+
foreach($fields as $name => $options){
|
319 |
+
$enabled = (isset($options['enabled']) && $options['enabled'] == false) ? false : true;
|
320 |
+
$is_custom_field = (isset($options['custom']) && $options['custom'] == true) ? true : false;
|
321 |
+
|
322 |
+
if(isset($options['show_in_order']) && $options['show_in_order'] && $enabled && $is_custom_field){
|
323 |
+
$value = get_post_meta($order_id, $name, true);
|
324 |
+
|
325 |
+
if(!empty($value)){
|
326 |
+
$label = isset($options['label']) && !empty($options['label']) ? __( $options['label'], 'woocommerce' ) : $name;
|
327 |
+
echo '<tr><th>'. esc_attr($label) .':</th><td>'. wptexturize($value) .'</td></tr>';
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
add_action('woocommerce_order_details_after_customer_details', 'thwcfd_order_details_after_customer_details_lite', 20, 1);
|
333 |
+
|
334 |
+
/*****************************************
|
335 |
+
----- Display Field Values - END --------
|
336 |
+
*****************************************/
|
337 |
+
|
338 |
+
/*function thwcfd_prepare_checkout_fields_lite( $data, $old_fields ) {
|
339 |
+
global $WC_Checkout_Field_Editor;
|
340 |
+
|
341 |
+
if( empty( $data ) ) {
|
342 |
+
return $old_fields;
|
343 |
+
|
344 |
+
}else {
|
345 |
+
$fields = $data;
|
346 |
+
foreach( $fields as $name => $values ) {
|
347 |
+
// enabled
|
348 |
+
if ( $values['enabled'] == false ) {
|
349 |
+
unset( $fields[ $name ] );
|
350 |
+
}
|
351 |
+
|
352 |
+
// Replace locale field properties so they are unchanged
|
353 |
+
if ( in_array( $name, array(
|
354 |
+
'billing_country', 'billing_state', 'billing_city', 'billing_postcode',
|
355 |
+
'shipping_country', 'shipping_state', 'shipping_city', 'shipping_postcode',
|
356 |
+
'order_comments'
|
357 |
+
) ) ) {
|
358 |
+
if ( isset( $fields[ $name ] ) ) {
|
359 |
+
$fields[ $name ] = $old_fields[ $name ];
|
360 |
+
$fields[ $name ]['label'] = ! empty( $data[ $name ]['label'] ) ? $data[ $name ]['label'] : $old_fields[ $name ]['label'];
|
361 |
+
|
362 |
+
if ( ! empty( $data[ $name ]['placeholder'] ) ) {
|
363 |
+
$fields[ $name ]['placeholder'] = $data[ $name ]['placeholder'];
|
364 |
+
|
365 |
+
} elseif ( ! empty( $old_fields[ $name ]['placeholder'] ) ) {
|
366 |
+
$fields[ $name ]['placeholder'] = $old_fields[ $name ]['placeholder'];
|
367 |
+
|
368 |
+
} else {
|
369 |
+
$fields[ $name ]['placeholder'] = '';
|
370 |
+
}
|
371 |
+
|
372 |
+
$fields[ $name ]['class'] = $data[ $name ]['class'];
|
373 |
+
$fields[ $name ]['clear'] = $data[ $name ]['clear'];
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
if(isset($fields[$name])){
|
378 |
+
if(isset($fields[$name]['label'])){
|
379 |
+
$fields[ $name ]['label'] = __($fields[ $name ]['label'], 'woocommerce');
|
380 |
+
}
|
381 |
+
if(isset($fields[$name]['placeholder'])){
|
382 |
+
$fields[ $name ]['placeholder'] = __($fields[ $name ]['placeholder'], 'woocommerce');
|
383 |
+
}
|
384 |
+
if(isset($fields[$name]['order'])){
|
385 |
+
$fields[ $name ]['priority'] = is_numeric($fields[$name]['order']) ? $fields[$name]['order'] : '';
|
386 |
+
}
|
387 |
+
}
|
388 |
+
}
|
389 |
+
return $fields;
|
390 |
+
}
|
391 |
+
}*/
|
392 |
+
|
393 |
+
/**
|
394 |
+
* wc_checkout_fields_validation function.
|
395 |
+
*
|
396 |
+
* @param mixed $posted
|
397 |
+
*/
|
398 |
+
/*function thwcfd_checkout_fields_validation_lite($posted){
|
399 |
+
foreach(WC()->checkout->checkout_fields as $fieldset_key => $fieldset){
|
400 |
+
|
401 |
+
// Skip shipping if its not needed
|
402 |
+
if($fieldset_key === 'shipping' && (wc_ship_to_billing_address_only() || !empty($posted['shiptobilling']) ||
|
403 |
+
(!WC()->cart->needs_shipping() && get_option('woocommerce_require_shipping_address') === 'no'))){
|
404 |
+
continue;
|
405 |
+
}
|
406 |
+
|
407 |
+
foreach($fieldset as $key => $field){
|
408 |
+
if(!empty($field['validate']) && is_array($field['validate']) && !empty($posted[$key])){
|
409 |
+
foreach($field['validate'] as $rule){
|
410 |
+
switch($rule) {
|
411 |
+
case 'number' :
|
412 |
+
if(!is_numeric($posted[$key])){
|
413 |
+
if(defined('WC_VERSION') && version_compare(WC_VERSION, '2.3.0', '>=')){
|
414 |
+
wc_add_notice('<strong>'. $field['label'] .'</strong> '. sprintf(__('(%s) is not a valid number.', 'woocommerce'), $posted[$key]), 'error');
|
415 |
+
} else {
|
416 |
+
WC()->add_error('<strong>'. $field['label'] .'</strong> '. sprintf(__('(%s) is not a valid number.', 'woocommerce'), $posted[$key]));
|
417 |
+
}
|
418 |
+
}
|
419 |
+
break;
|
420 |
+
case 'email' :
|
421 |
+
if(!is_email($posted[$key])){
|
422 |
+
if(defined('WC_VERSION') && version_compare(WC_VERSION, '2.3.0', '<')){
|
423 |
+
WC()->add_error('<strong>'. $field['label'] .'</strong> '. sprintf(__('(%s) is not a valid email address.', 'woocommerce'), $posted[$key]));
|
424 |
+
}
|
425 |
+
}
|
426 |
+
break;
|
427 |
+
}
|
428 |
+
}
|
429 |
+
}
|
430 |
+
}
|
431 |
+
}
|
432 |
+
}*/
|
433 |
+
//add_action('woocommerce_after_checkout_validation', 'thwcfd_checkout_fields_validation_lite');
|
434 |
+
|
435 |
+
}
|
classes/class-wc-checkout-field-editor-export-handler.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if(!defined( 'ABSPATH' )) exit;
|
3 |
+
|
4 |
+
class WC_Checkout_Field_Editor_Export_Handler {
|
5 |
+
private $fields;
|
6 |
+
|
7 |
+
public function __construct() {
|
8 |
+
$this->fields = $this->get_fields();
|
9 |
+
|
10 |
+
// Customer / Order CSV Export column headers/data
|
11 |
+
//add_filter( 'wc_customer_order_csv_export_order_headers', array( $this, 'thwcfd_order_csv_export_order_headers' ), 10, 2 );
|
12 |
+
//add_filter( 'wc_customer_order_csv_export_order_row', array( $this, 'thwcfd_customer_order_csv_export_order_row' ), 10, 4 );
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Adds support for Customer/Order CSV Export by adding a vendor column header
|
17 |
+
*/
|
18 |
+
public function thwcfd_order_csv_export_order_headers($headers, $csv_generator) {
|
19 |
+
$field_headers = array();
|
20 |
+
|
21 |
+
foreach ( $this->fields as $name => $options ) {
|
22 |
+
$field_headers[ $name ] = $name;
|
23 |
+
}
|
24 |
+
|
25 |
+
return array_merge( $headers, $field_headers );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Adds support for Customer/Order CSV Export by adding checkout editor field data
|
30 |
+
*/
|
31 |
+
public function thwcfd_customer_order_csv_export_order_row( $order_data, $order, $csv_generator ) {
|
32 |
+
$field_data = array();
|
33 |
+
|
34 |
+
foreach ( $this->fields as $name => $options ) {
|
35 |
+
$field_data[ $name ] = get_post_meta( $order->id, $name, true );
|
36 |
+
}
|
37 |
+
|
38 |
+
$new_order_data = array();
|
39 |
+
|
40 |
+
if(isset($csv_generator->order_format) && ($csv_generator->order_format == 'default_one_row_per_item' || $csv_generator->order_format == 'legacy_one_row_per_item')){
|
41 |
+
foreach($order_data as $data){
|
42 |
+
$new_order_data[] = array_merge( $field_data, (array) $data );
|
43 |
+
}
|
44 |
+
} else {
|
45 |
+
$new_order_data = array_merge( $field_data, $order_data );
|
46 |
+
}
|
47 |
+
|
48 |
+
return $new_order_data;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get all checkout fields
|
53 |
+
*/
|
54 |
+
private function get_fields() {
|
55 |
+
$fields = array();
|
56 |
+
|
57 |
+
$billing_fields = get_option( 'wc_fields_billing' );
|
58 |
+
if($billing_fields !== false){
|
59 |
+
$fields = array_merge( $fields, $billing_fields );
|
60 |
+
}
|
61 |
+
|
62 |
+
$shipping_fields = get_option( 'wc_fields_shipping' );
|
63 |
+
if($shipping_fields !== false){
|
64 |
+
$fields = array_merge( $fields, $shipping_fields );
|
65 |
+
}
|
66 |
+
|
67 |
+
$additional_fields = get_option( 'wc_fields_additional' );
|
68 |
+
if($additional_fields !== false){
|
69 |
+
$fields = array_merge( $fields, $additional_fields );
|
70 |
+
}
|
71 |
+
|
72 |
+
return $fields;
|
73 |
+
}
|
74 |
+
}
|
classes/class-wc-checkout-field-editor.php
ADDED
@@ -0,0 +1,710 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if(!defined( 'ABSPATH' )) exit;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* WC_Checkout_Field_Editor class.
|
6 |
+
*/
|
7 |
+
class WC_Checkout_Field_Editor {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* __construct function.
|
11 |
+
*/
|
12 |
+
function __construct() {
|
13 |
+
// Validation rules are controlled by the local fields and can't be changed
|
14 |
+
$this->locale_fields = array(
|
15 |
+
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
16 |
+
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
17 |
+
'order_comments'
|
18 |
+
);
|
19 |
+
|
20 |
+
add_action('admin_menu', array($this, 'admin_menu'));
|
21 |
+
add_filter('woocommerce_screen_ids', array($this, 'add_screen_id'));
|
22 |
+
add_action('woocommerce_checkout_update_order_meta', array($this, 'save_data'), 10, 2);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* menu function.
|
27 |
+
*/
|
28 |
+
function admin_menu() {
|
29 |
+
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Form Designer', 'thwcfd'), __('Checkout Form', 'thwcfd'),
|
30 |
+
'manage_woocommerce', 'checkout_form_designer', array($this, 'the_designer'));
|
31 |
+
|
32 |
+
add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* scripts function.
|
37 |
+
*/
|
38 |
+
function enqueue_admin_scripts() {
|
39 |
+
wp_enqueue_style ('thwcfd-style', plugins_url('/assets/css/thwcfd-style.css', dirname(__FILE__)));
|
40 |
+
wp_enqueue_script('thwcfd-admin-script', plugins_url('/assets/js/thwcfd-admin.js', dirname(__FILE__)), array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable',
|
41 |
+
'woocommerce_admin', 'select2', 'jquery-tiptip'), '1.0', true);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function output_premium_version_notice(){
|
45 |
+
?>
|
46 |
+
<div id="message" class="wc-connect updated thwcfd-notice">
|
47 |
+
<div class="squeezer">
|
48 |
+
<table>
|
49 |
+
<tr>
|
50 |
+
<td width="70%">
|
51 |
+
<p><strong><i>WooCommerce Checkout Field Editor Pro</i></strong> premium version provides more features to design your checkout page.</p>
|
52 |
+
<ul>
|
53 |
+
<li>12 field types available,<br/>(<i>Text, Hidden, Password, Textarea, Radio, Checkbox, Select, Multi-select, Date Picker, Time Picker, Heading, Label</i>).</li>
|
54 |
+
<li>Conditionally display fields based on cart items and other field(s) values.</li>
|
55 |
+
<li>Add an extra cost to the cart total based on field selection.</li>
|
56 |
+
<li>Option to add more sections in addition to the core sections (billing, shipping and additional) in checkout page.</li>
|
57 |
+
</ul>
|
58 |
+
</td>
|
59 |
+
<td>
|
60 |
+
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/" class="">
|
61 |
+
<img src="<?php echo plugins_url( '../assets/css/upgrade-btn.png', __FILE__ ); ?>" />
|
62 |
+
</a>
|
63 |
+
</td>
|
64 |
+
</tr>
|
65 |
+
</table>
|
66 |
+
</div>
|
67 |
+
</div>
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* add_screen_id function.
|
73 |
+
*/
|
74 |
+
function add_screen_id($ids){
|
75 |
+
$ids[] = 'woocommerce_page_checkout_form_designer';
|
76 |
+
$ids[] = strtolower(__('WooCommerce', 'thwcfd')) .'_page_checkout_form_designer';
|
77 |
+
|
78 |
+
return $ids;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Reset checkout fields.
|
83 |
+
*/
|
84 |
+
function reset_checkout_fields() {
|
85 |
+
delete_option('wc_fields_billing');
|
86 |
+
delete_option('wc_fields_shipping');
|
87 |
+
delete_option('wc_fields_additional');
|
88 |
+
echo '<div class="updated"><p>'. __('SUCCESS: Checkout fields successfully reset', 'thwcfd') .'</p></div>';
|
89 |
+
}
|
90 |
+
|
91 |
+
function is_reserved_field_name( $field_name ){
|
92 |
+
if($field_name && in_array($field_name, array(
|
93 |
+
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
94 |
+
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
95 |
+
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state',
|
96 |
+
'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
97 |
+
))){
|
98 |
+
return true;
|
99 |
+
}
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
function is_default_field_name($field_name){
|
104 |
+
if($field_name && in_array($field_name, array(
|
105 |
+
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
106 |
+
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
107 |
+
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state',
|
108 |
+
'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
109 |
+
))){
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Save Data function.
|
117 |
+
*/
|
118 |
+
function save_data($order_id, $posted){
|
119 |
+
$types = array('billing', 'shipping', 'additional');
|
120 |
+
|
121 |
+
foreach($types as $type){
|
122 |
+
$fields = $this->get_fields($type);
|
123 |
+
|
124 |
+
foreach($fields as $name => $field){
|
125 |
+
if(isset($field['custom']) && $field['custom'] && isset($posted[$name])){
|
126 |
+
$value = wc_clean($posted[$name]);
|
127 |
+
if($value){
|
128 |
+
update_post_meta($order_id, $name, $value);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
public static function get_fields($key){
|
136 |
+
$fields = array_filter(get_option('wc_fields_'. $key, array()));
|
137 |
+
|
138 |
+
if(empty($fields) || sizeof($fields) == 0){
|
139 |
+
if($key === 'billing' || $key === 'shipping'){
|
140 |
+
$fields = WC()->countries->get_address_fields(WC()->countries->get_base_country(), $key . '_');
|
141 |
+
|
142 |
+
} else if($key === 'additional'){
|
143 |
+
$fields = array(
|
144 |
+
'order_comments' => array(
|
145 |
+
'type' => 'textarea',
|
146 |
+
'class' => array('notes'),
|
147 |
+
'label' => __('Order Notes', 'woocommerce'),
|
148 |
+
'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
|
149 |
+
)
|
150 |
+
);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return $fields;
|
154 |
+
}
|
155 |
+
|
156 |
+
function sort_fields_by_order($a, $b){
|
157 |
+
if(!isset($a['order']) || $a['order'] == $b['order']){
|
158 |
+
return 0;
|
159 |
+
}
|
160 |
+
return ($a['order'] < $b['order']) ? -1 : 1;
|
161 |
+
}
|
162 |
+
|
163 |
+
function get_field_types(){
|
164 |
+
return array(
|
165 |
+
'text' => 'Text',
|
166 |
+
'select' => 'Select',
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
/*
|
171 |
+
* New field form popup
|
172 |
+
*/
|
173 |
+
function wcfd_new_field_form_pp(){
|
174 |
+
$field_types = $this->get_field_types();
|
175 |
+
?>
|
176 |
+
<div id="wcfd_new_field_form_pp" title="New Checkout Field" class="wcfd_popup_wrapper">
|
177 |
+
<form>
|
178 |
+
<table>
|
179 |
+
<tr>
|
180 |
+
<td colspan="2" class="err_msgs"></td>
|
181 |
+
</tr>
|
182 |
+
<tr>
|
183 |
+
<td width="40%">Type</td>
|
184 |
+
<td>
|
185 |
+
<select name="ftype" style="width:150px;" onchange="fieldTypeChangeListner(this)">
|
186 |
+
<?php foreach($field_types as $value=>$label){ ?>
|
187 |
+
<option value="<?php echo trim($value); ?>"><?php echo $label; ?></option>
|
188 |
+
<?php } ?>
|
189 |
+
</select>
|
190 |
+
</td>
|
191 |
+
</tr>
|
192 |
+
<tr>
|
193 |
+
<td>Name</td>
|
194 |
+
<td><input type="text" name="fname" style="width:250px;"/></td>
|
195 |
+
</tr>
|
196 |
+
<tr>
|
197 |
+
<td>Label</td>
|
198 |
+
<td><input type="text" name="flabel" style="width:250px;"/></td>
|
199 |
+
</tr>
|
200 |
+
<tr class="rowPlaceholder">
|
201 |
+
<td>Placeholder</td>
|
202 |
+
<td><input type="text" name="fplaceholder" style="width:250px;"/></td>
|
203 |
+
</tr>
|
204 |
+
<tr class="rowOptions">
|
205 |
+
<td>Options</td>
|
206 |
+
<td><input type="text" name="foptions" placeholder="Seperate options with pipe(|)" style="width:250px;"/></td>
|
207 |
+
</tr>
|
208 |
+
<tr class="rowClass">
|
209 |
+
<td>Class</td>
|
210 |
+
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
211 |
+
</tr>
|
212 |
+
<!--<tr class="rowLabelClass">
|
213 |
+
<td>Label Class</td>
|
214 |
+
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
215 |
+
</tr>-->
|
216 |
+
<tr class="rowValidate">
|
217 |
+
<td>Validation</td>
|
218 |
+
<td>
|
219 |
+
<select multiple="multiple" name="fvalidate" placeholder="Select validations" class="thwcfd-enhanced-multi-select"
|
220 |
+
style="width: 250px; height:30px;">
|
221 |
+
<option value="email">Email</option>
|
222 |
+
<option value="phone">Phone</option>
|
223 |
+
</select>
|
224 |
+
</td>
|
225 |
+
</tr>
|
226 |
+
<tr class="rowRequired">
|
227 |
+
<td> </td>
|
228 |
+
<td>
|
229 |
+
<input type="checkbox" name="frequired" value="yes" checked/>
|
230 |
+
<label>Required</label><br/>
|
231 |
+
|
232 |
+
<input type="checkbox" name="fclearRow" value="yes" checked/>
|
233 |
+
<label>Clear Row</label><br/>
|
234 |
+
|
235 |
+
<input type="checkbox" name="fenabled" value="yes" checked/>
|
236 |
+
<label>Enabled</label>
|
237 |
+
</td>
|
238 |
+
</tr>
|
239 |
+
<tr class="rowShowInEmail">
|
240 |
+
<td> </td>
|
241 |
+
<td>
|
242 |
+
<input type="checkbox" name="fshowinemail" value="email" checked/>
|
243 |
+
<label>Display in Emails</label>
|
244 |
+
</td>
|
245 |
+
</tr>
|
246 |
+
<tr class="rowShowInOrder">
|
247 |
+
<td> </td>
|
248 |
+
<td>
|
249 |
+
<input type="checkbox" name="fshowinorder" value="order-review" checked/>
|
250 |
+
<label>Display in Order Detail Pages</label>
|
251 |
+
</td>
|
252 |
+
</tr>
|
253 |
+
</table>
|
254 |
+
</form>
|
255 |
+
</div>
|
256 |
+
<?php
|
257 |
+
}
|
258 |
+
|
259 |
+
/*
|
260 |
+
* New field form popup
|
261 |
+
*/
|
262 |
+
function wcfd_edit_field_form_pp(){
|
263 |
+
$field_types = $this->get_field_types();
|
264 |
+
?>
|
265 |
+
<div id="wcfd_edit_field_form_pp" title="Edit Checkout Field" class="wcfd_popup_wrapper">
|
266 |
+
<form>
|
267 |
+
<table>
|
268 |
+
<tr>
|
269 |
+
<td colspan="2" class="err_msgs"></td>
|
270 |
+
</tr>
|
271 |
+
<tr>
|
272 |
+
<td width="40%">Name</td>
|
273 |
+
<td>
|
274 |
+
<input type="hidden" name="rowId"/>
|
275 |
+
<input type="hidden" name="fname"/>
|
276 |
+
<input type="text" name="fnameNew" style="width:250px;"/>
|
277 |
+
</td>
|
278 |
+
</tr>
|
279 |
+
<tr>
|
280 |
+
<td>Type</td>
|
281 |
+
<td>
|
282 |
+
<select name="ftype" style="width:150px;" onchange="fieldTypeChangeListner(this)">
|
283 |
+
<?php foreach($field_types as $value=>$label){ ?>
|
284 |
+
<option value="<?php echo trim($value); ?>"><?php echo $label; ?></option>
|
285 |
+
<?php } ?>
|
286 |
+
</select>
|
287 |
+
</td>
|
288 |
+
</tr>
|
289 |
+
<tr>
|
290 |
+
<td>Label</td>
|
291 |
+
<td><input type="text" name="flabel" style="width:250px;"/></td>
|
292 |
+
</tr>
|
293 |
+
<tr class="rowPlaceholder">
|
294 |
+
<td>Placeholder</td>
|
295 |
+
<td><input type="text" name="fplaceholder" style="width:250px;"/></td>
|
296 |
+
</tr>
|
297 |
+
<tr class="rowOptions">
|
298 |
+
<td>Options</td>
|
299 |
+
<td><input type="text" name="foptions" placeholder="Seperate options with pipe(|)" style="width:250px;"/></td>
|
300 |
+
</tr>
|
301 |
+
<tr class="rowClass">
|
302 |
+
<td>Class</td>
|
303 |
+
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
304 |
+
</tr>
|
305 |
+
<!--<tr class="rowLabelClass">
|
306 |
+
<td>Label Class</td>
|
307 |
+
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
308 |
+
</tr>-->
|
309 |
+
<tr class="rowValidate">
|
310 |
+
<td>Validation</td>
|
311 |
+
<td>
|
312 |
+
<select multiple="multiple" name="fvalidate" placeholder="Select validations" class="thwcfd-enhanced-multi-select"
|
313 |
+
style="width: 250px; height:30px;">
|
314 |
+
<option value="email">Email</option>
|
315 |
+
<option value="phone">Phone</option>
|
316 |
+
</select>
|
317 |
+
</td>
|
318 |
+
</tr>
|
319 |
+
<tr class="rowRequired">
|
320 |
+
<td> </td>
|
321 |
+
<td>
|
322 |
+
<input type="checkbox" name="frequired" value="yes" checked/>
|
323 |
+
<label>Required</label><br/>
|
324 |
+
|
325 |
+
<input type="checkbox" name="fclearRow" value="yes" checked/>
|
326 |
+
<label>Clear Row</label><br/>
|
327 |
+
|
328 |
+
<input type="checkbox" name="fenabled" value="yes" checked/>
|
329 |
+
<label>Enabled</label>
|
330 |
+
</td>
|
331 |
+
</tr>
|
332 |
+
<tr class="rowShowInEmail">
|
333 |
+
<td> </td>
|
334 |
+
<td>
|
335 |
+
<input type="checkbox" name="fshowinemail" value="email" checked/>
|
336 |
+
<label>Display in Emails</label>
|
337 |
+
</td>
|
338 |
+
</tr>
|
339 |
+
<tr class="rowShowInOrder">
|
340 |
+
<td> </td>
|
341 |
+
<td>
|
342 |
+
<input type="checkbox" name="fshowinorder" value="order-review" checked/>
|
343 |
+
<label>Display in Order Detail Pages</label>
|
344 |
+
</td>
|
345 |
+
</tr>
|
346 |
+
</table>
|
347 |
+
</form>
|
348 |
+
</div>
|
349 |
+
<?php
|
350 |
+
}
|
351 |
+
|
352 |
+
function render_tabs_and_sections(){
|
353 |
+
$tabs = array( 'fields' => 'Checkout Fields' );
|
354 |
+
$tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
355 |
+
|
356 |
+
$sections = ''; $section = '';
|
357 |
+
if($tab === 'fields'){
|
358 |
+
$sections = array( 'billing', 'shipping', 'additional' );
|
359 |
+
$section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
|
360 |
+
}
|
361 |
+
|
362 |
+
echo '<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">';
|
363 |
+
foreach( $tabs as $key => $value ) {
|
364 |
+
$active = ( $key == $tab ) ? 'nav-tab-active' : '';
|
365 |
+
echo '<a class="nav-tab '.$active.'" href="'.admin_url('admin.php?page=checkout_form_designer&tab='.$key).'">'.$value.'</a>';
|
366 |
+
}
|
367 |
+
echo '</h2>';
|
368 |
+
|
369 |
+
if(!empty($sections)){
|
370 |
+
echo '<ul class="thwcfd-sections">';
|
371 |
+
$size = sizeof($sections); $i = 0;
|
372 |
+
foreach( $sections as $key ) {
|
373 |
+
$i++;
|
374 |
+
$active = ( $key == $section ) ? 'current' : '';
|
375 |
+
$url = 'admin.php?page=checkout_form_designer&tab=fields§ion='.$key;
|
376 |
+
echo '<li>';
|
377 |
+
echo '<a href="'.admin_url($url).'" class="'.$active.'" >'.ucwords($key).' '.__('Fields', 'thwcfd').'</a>';
|
378 |
+
echo ($size > $i) ? ' | ' : '';
|
379 |
+
echo '</li>';
|
380 |
+
}
|
381 |
+
echo '</ul>';
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->output_premium_version_notice();
|
385 |
+
}
|
386 |
+
|
387 |
+
function get_current_tab(){
|
388 |
+
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
389 |
+
}
|
390 |
+
|
391 |
+
function get_current_section(){
|
392 |
+
$tab = $this->get_current_tab();
|
393 |
+
$section = '';
|
394 |
+
if($tab === 'fields'){
|
395 |
+
$section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
|
396 |
+
}
|
397 |
+
return $section;
|
398 |
+
}
|
399 |
+
|
400 |
+
function render_checkout_fields_heading_row(){
|
401 |
+
?>
|
402 |
+
<th class="sort"></th>
|
403 |
+
<th class="check-column" style="padding-left:0px !important;"><input type="checkbox" style="margin-left:7px;" onclick="thwcfdSelectAllCheckoutFields(this)"/></th>
|
404 |
+
<th class="name">Name</th>
|
405 |
+
<th class="id">Type</th>
|
406 |
+
<th>Label</th>
|
407 |
+
<th>Placeholder</th>
|
408 |
+
<th>Validation Rules</th>
|
409 |
+
<th class="status">Required</th>
|
410 |
+
<th class="status">Clear Row</th>
|
411 |
+
<th class="status">Enabled</th>
|
412 |
+
<th class="status">Edit</th>
|
413 |
+
<?php
|
414 |
+
}
|
415 |
+
|
416 |
+
function render_actions_row($section){
|
417 |
+
?>
|
418 |
+
<th colspan="7">
|
419 |
+
<button type="button" class="button button-primary" onclick="openNewFieldForm('<?php echo $section; ?>')"><?php _e( '+ Add field', 'thwcfd' ); ?></button>
|
420 |
+
<button type="button" class="button" onclick="removeSelectedFields()"><?php _e( 'Remove', 'thwcfd' ); ?></button>
|
421 |
+
<button type="button" class="button" onclick="enableSelectedFields()"><?php _e( 'Enable', 'thwcfd' ); ?></button>
|
422 |
+
<button type="button" class="button" onclick="disableSelectedFields()"><?php _e( 'Disable', 'thwcfd' ); ?></button>
|
423 |
+
</th>
|
424 |
+
<th colspan="4">
|
425 |
+
<input type="submit" name="save_fields" class="button-primary" value="<?php _e( 'Save changes', 'thwcfd' ) ?>" style="float:right" />
|
426 |
+
<input type="submit" name="reset_fields" class="button" value="<?php _e( 'Reset to default fields', 'thwcfd' ) ?>" style="float:right; margin-right: 5px;" />
|
427 |
+
</th>
|
428 |
+
<?php
|
429 |
+
}
|
430 |
+
|
431 |
+
function the_designer() {
|
432 |
+
$tab = $this->get_current_tab();
|
433 |
+
if($tab === 'fields'){
|
434 |
+
$this->checkout_form_field_editor();
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
function checkout_form_field_editor() {
|
439 |
+
$section = $this->get_current_section();
|
440 |
+
|
441 |
+
echo '<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>';
|
442 |
+
$this->render_tabs_and_sections();
|
443 |
+
|
444 |
+
if ( isset( $_POST['save_fields'] ) )
|
445 |
+
echo $this->save_options( $section );
|
446 |
+
|
447 |
+
if ( isset( $_POST['reset_fields'] ) )
|
448 |
+
echo $this->reset_checkout_fields();
|
449 |
+
|
450 |
+
global $supress_field_modification;
|
451 |
+
$supress_field_modification = false;
|
452 |
+
?>
|
453 |
+
|
454 |
+
<form method="post" id="wcfd_checkout_fields_form" action="">
|
455 |
+
<table id="wcfd_checkout_fields" class="wc_gateways widefat" cellspacing="0">
|
456 |
+
<thead>
|
457 |
+
<tr><?php $this->render_actions_row($section); ?></tr>
|
458 |
+
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
459 |
+
</thead>
|
460 |
+
<tfoot>
|
461 |
+
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
462 |
+
<tr><?php $this->render_actions_row($section); ?></tr>
|
463 |
+
</tfoot>
|
464 |
+
<tbody class="ui-sortable">
|
465 |
+
<?php
|
466 |
+
$i=0;
|
467 |
+
foreach( $this->get_fields( $section ) as $name => $options ) :
|
468 |
+
if ( isset( $options['custom'] ) && $options['custom'] == 1 ) {
|
469 |
+
$options['custom'] = '1';
|
470 |
+
} else {
|
471 |
+
$options['custom'] = '0';
|
472 |
+
}
|
473 |
+
|
474 |
+
if ( !isset( $options['label'] ) ) {
|
475 |
+
$options['label'] = '';
|
476 |
+
}
|
477 |
+
|
478 |
+
if ( !isset( $options['placeholder'] ) ) {
|
479 |
+
$options['placeholder'] = '';
|
480 |
+
}
|
481 |
+
|
482 |
+
if( isset( $options['options'] ) && is_array($options['options']) ) {
|
483 |
+
$options['options'] = implode("|", $options['options']);
|
484 |
+
}else{
|
485 |
+
$options['options'] = '';
|
486 |
+
}
|
487 |
+
|
488 |
+
if( isset( $options['class'] ) && is_array($options['class']) ) {
|
489 |
+
$options['class'] = implode(",", $options['class']);
|
490 |
+
}else{
|
491 |
+
$options['class'] = '';
|
492 |
+
}
|
493 |
+
|
494 |
+
if( isset( $options['label_class'] ) && is_array($options['label_class']) ) {
|
495 |
+
$options['label_class'] = implode(",", $options['label_class']);
|
496 |
+
}else{
|
497 |
+
$options['label_class'] = '';
|
498 |
+
}
|
499 |
+
|
500 |
+
if( isset( $options['validate'] ) && is_array($options['validate']) ) {
|
501 |
+
$options['validate'] = implode(",", $options['validate']);
|
502 |
+
}else{
|
503 |
+
$options['validate'] = '';
|
504 |
+
}
|
505 |
+
|
506 |
+
if ( isset( $options['required'] ) && $options['required'] == 1 ) {
|
507 |
+
$options['required'] = '1';
|
508 |
+
} else {
|
509 |
+
$options['required'] = '0';
|
510 |
+
}
|
511 |
+
|
512 |
+
if ( isset( $options['clear'] ) && $options['clear'] == 1 ) {
|
513 |
+
$options['clear'] = '1';
|
514 |
+
} else {
|
515 |
+
$options['clear'] = '0';
|
516 |
+
}
|
517 |
+
|
518 |
+
if ( !isset( $options['enabled'] ) || $options['enabled'] == 1 ) {
|
519 |
+
$options['enabled'] = '1';
|
520 |
+
} else {
|
521 |
+
$options['enabled'] = '0';
|
522 |
+
}
|
523 |
+
|
524 |
+
if ( !isset( $options['type'] ) ) {
|
525 |
+
$options['type'] = 'text';
|
526 |
+
}
|
527 |
+
|
528 |
+
if ( isset( $options['show_in_email'] ) && $options['show_in_email'] == 1 ) {
|
529 |
+
$options['show_in_email'] = '1';
|
530 |
+
} else {
|
531 |
+
$options['show_in_email'] = '0';
|
532 |
+
}
|
533 |
+
|
534 |
+
if ( isset( $options['show_in_order'] ) && $options['show_in_order'] == 1 ) {
|
535 |
+
$options['show_in_order'] = '1';
|
536 |
+
} else {
|
537 |
+
$options['show_in_order'] = '0';
|
538 |
+
}
|
539 |
+
?>
|
540 |
+
<tr class="row_<?php echo $i; echo($options['enabled'] == 1 ? '' : ' thwcfd-disabled') ?>">
|
541 |
+
<td width="1%" class="sort ui-sortable-handle">
|
542 |
+
<input type="hidden" name="f_custom[<?php echo $i; ?>]" class="f_custom" value="<?php echo $options['custom']; ?>" />
|
543 |
+
<input type="hidden" name="f_order[<?php echo $i; ?>]" class="f_order" value="<?php echo $i; ?>" />
|
544 |
+
|
545 |
+
<input type="hidden" name="f_name[<?php echo $i; ?>]" class="f_name" value="<?php echo esc_attr( $name ); ?>" />
|
546 |
+
<input type="hidden" name="f_name_new[<?php echo $i; ?>]" class="f_name_new" value="" />
|
547 |
+
<input type="hidden" name="f_type[<?php echo $i; ?>]" class="f_type" value="<?php echo $options['type']; ?>" />
|
548 |
+
<input type="hidden" name="f_label[<?php echo $i; ?>]" class="f_label" value="<?php echo $options['label']; ?>" />
|
549 |
+
<input type="hidden" name="f_placeholder[<?php echo $i; ?>]" class="f_placeholder" value="<?php echo $options['placeholder']; ?>" />
|
550 |
+
<input type="hidden" name="f_options[<?php echo $i; ?>]" class="f_options" value="<?php echo($options['options']) ?>" />
|
551 |
+
|
552 |
+
<input type="hidden" name="f_class[<?php echo $i; ?>]" class="f_class" value="<?php echo $options['class']; ?>" />
|
553 |
+
<input type="hidden" name="f_label_class[<?php echo $i; ?>]" class="f_label_class" value="<?php echo $options['label_class']; ?>" />
|
554 |
+
|
555 |
+
<input type="hidden" name="f_required[<?php echo $i; ?>]" class="f_required" value="<?php echo($options['required']) ?>" />
|
556 |
+
<input type="hidden" name="f_clear[<?php echo $i; ?>]" class="f_clear" value="<?php echo($options['clear']) ?>" />
|
557 |
+
|
558 |
+
<input type="hidden" name="f_enabled[<?php echo $i; ?>]" class="f_enabled" value="<?php echo($options['enabled']) ?>" />
|
559 |
+
<input type="hidden" name="f_validation[<?php echo $i; ?>]" class="f_validation" value="<?php echo($options['validate']) ?>" />
|
560 |
+
<input type="hidden" name="f_show_in_email[<?php echo $i; ?>]" class="f_show_in_email" value="<?php echo($options['show_in_email']) ?>" />
|
561 |
+
<input type="hidden" name="f_show_in_order[<?php echo $i; ?>]" class="f_show_in_order" value="<?php echo($options['show_in_order']) ?>" />
|
562 |
+
<input type="hidden" name="f_deleted[<?php echo $i; ?>]" class="f_deleted" value="0" />
|
563 |
+
|
564 |
+
<!--$properties = array('type', 'label', 'placeholder', 'class', 'required', 'clear', 'label_class', 'options');-->
|
565 |
+
</td>
|
566 |
+
<td class="td_select"><input type="checkbox" name="select_field"/></td>
|
567 |
+
<td class="td_name"><?php echo esc_attr( $name ); ?></td>
|
568 |
+
<td class="td_type"><?php echo $options['type']; ?></td>
|
569 |
+
<td class="td_label"><?php echo $options['label']; ?></td>
|
570 |
+
<td class="td_placeholder"><?php echo $options['placeholder']; ?></td>
|
571 |
+
<td class="td_validate"><?php echo $options['validate']; ?></td>
|
572 |
+
<td class="td_required status"><?php echo($options['required'] == 1 ? '<span class="status-enabled tips">Yes</span>' : '-' ) ?></td>
|
573 |
+
<td class="td_clear status"><?php echo($options['clear'] == 1 ? '<span class="status-enabled tips">Yes</span>' : '-' ) ?></td>
|
574 |
+
<td class="td_enabled status"><?php echo($options['enabled'] == 1 ? '<span class="status-enabled tips">Yes</span>' : '-' ) ?></td>
|
575 |
+
<td class="td_edit">
|
576 |
+
<button type="button" class="f_edit_btn" <?php echo($options['enabled'] == 1 ? '' : 'disabled') ?>
|
577 |
+
onclick="openEditFieldForm(this,<?php echo $i; ?>)"><?php _e( 'Edit', 'thwcfd' ); ?></button>
|
578 |
+
</td>
|
579 |
+
</tr>
|
580 |
+
<?php $i++; endforeach; ?>
|
581 |
+
</tbody>
|
582 |
+
</table>
|
583 |
+
</form>
|
584 |
+
<?php
|
585 |
+
$this->wcfd_new_field_form_pp();
|
586 |
+
$this->wcfd_edit_field_form_pp();
|
587 |
+
?>
|
588 |
+
</div>
|
589 |
+
<?php
|
590 |
+
}
|
591 |
+
|
592 |
+
function save_options( $section ) {
|
593 |
+
$o_fields = $this->get_fields( $section );
|
594 |
+
$fields = $o_fields;
|
595 |
+
//$core_fields = array_keys( WC()->countries->get_address_fields( WC()->countries->get_base_country(), $section . '_' ) );
|
596 |
+
//$core_fields[] = 'order_comments';
|
597 |
+
|
598 |
+
$f_order = ! empty( $_POST['f_order'] ) ? $_POST['f_order'] : array();
|
599 |
+
|
600 |
+
$f_names = ! empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
|
601 |
+
$f_names_new = ! empty( $_POST['f_name_new'] ) ? $_POST['f_name_new'] : array();
|
602 |
+
$f_types = ! empty( $_POST['f_type'] ) ? $_POST['f_type'] : array();
|
603 |
+
$f_labels = ! empty( $_POST['f_label'] ) ? $_POST['f_label'] : array();
|
604 |
+
$f_placeholder = ! empty( $_POST['f_placeholder'] ) ? $_POST['f_placeholder'] : array();
|
605 |
+
$f_options = ! empty( $_POST['f_options'] ) ? $_POST['f_options'] : array();
|
606 |
+
|
607 |
+
$f_class = ! empty( $_POST['f_class'] ) ? $_POST['f_class'] : array();
|
608 |
+
$f_label_class = ! empty( $_POST['f_label_class'] ) ? $_POST['f_label_class'] : array();
|
609 |
+
|
610 |
+
$f_required = ! empty( $_POST['f_required'] ) ? $_POST['f_required'] : array();
|
611 |
+
$f_clear = ! empty( $_POST['f_clear'] ) ? $_POST['f_clear'] : array();
|
612 |
+
$f_enabled = ! empty( $_POST['f_enabled'] ) ? $_POST['f_enabled'] : array();
|
613 |
+
|
614 |
+
$f_show_in_email = ! empty( $_POST['f_show_in_email'] ) ? $_POST['f_show_in_email'] : array();
|
615 |
+
$f_show_in_order = ! empty( $_POST['f_show_in_order'] ) ? $_POST['f_show_in_order'] : array();
|
616 |
+
|
617 |
+
$f_validation = ! empty( $_POST['f_validation'] ) ? $_POST['f_validation'] : array();
|
618 |
+
$f_deleted = ! empty( $_POST['f_deleted'] ) ? $_POST['f_deleted'] : array();
|
619 |
+
|
620 |
+
$f_position = ! empty( $_POST['f_position'] ) ? $_POST['f_position'] : array();
|
621 |
+
$f_display_options = ! empty( $_POST['f_display_options'] ) ? $_POST['f_display_options'] : array();
|
622 |
+
$max = max( array_map( 'absint', array_keys( $f_names ) ) );
|
623 |
+
|
624 |
+
for ( $i = 0; $i <= $max; $i ++ ) {
|
625 |
+
$name = empty( $f_names[$i] ) ? '' : urldecode( sanitize_title( wc_clean( stripslashes( $f_names[$i] ) ) ) );
|
626 |
+
$new_name = empty( $f_names_new[$i] ) ? '' : urldecode( sanitize_title( wc_clean( stripslashes( $f_names_new[$i] ) ) ) );
|
627 |
+
|
628 |
+
if(!empty($f_deleted[$i]) && $f_deleted[$i] == 1){
|
629 |
+
unset( $fields[$name] );
|
630 |
+
continue;
|
631 |
+
}
|
632 |
+
|
633 |
+
// Check reserved names
|
634 |
+
if($this->is_reserved_field_name( $new_name )){
|
635 |
+
continue;
|
636 |
+
}
|
637 |
+
|
638 |
+
//if update field
|
639 |
+
if( $name && $new_name && $new_name !== $name ){
|
640 |
+
if ( isset( $fields[$name] ) ) {
|
641 |
+
$fields[$new_name] = $fields[$name];
|
642 |
+
} else {
|
643 |
+
$fields[$new_name] = array();
|
644 |
+
}
|
645 |
+
|
646 |
+
unset( $fields[$name] );
|
647 |
+
$name = $new_name;
|
648 |
+
} else {
|
649 |
+
$name = $name ? $name : $new_name;
|
650 |
+
}
|
651 |
+
|
652 |
+
if(!$name){
|
653 |
+
continue;
|
654 |
+
}
|
655 |
+
|
656 |
+
//if new field
|
657 |
+
if ( !isset( $fields[$name] ) ) {
|
658 |
+
$fields[$name] = array();
|
659 |
+
}
|
660 |
+
|
661 |
+
$o_type = isset( $o_fields[$name]['type'] ) ? $o_fields[$name]['type'] : 'text';
|
662 |
+
|
663 |
+
//$o_class = isset( $o_fields[$name]['class'] ) ? $o_fields[$name]['class'] : array();
|
664 |
+
//$classes = array_diff( $o_class, array( 'form-row-first', 'form-row-last', 'form-row-wide' ) );
|
665 |
+
|
666 |
+
$fields[$name]['type'] = empty( $f_types[$i] ) ? $o_type : wc_clean( $f_types[$i] );
|
667 |
+
$fields[$name]['label'] = empty( $f_labels[$i] ) ? '' : wp_kses_post( trim( stripslashes( $f_labels[$i] ) ) );
|
668 |
+
$fields[$name]['placeholder'] = empty( $f_placeholder[$i] ) ? '' : wc_clean( stripslashes( $f_placeholder[$i] ) );
|
669 |
+
$fields[$name]['options'] = empty( $f_options[$i] ) ? array() : array_map( 'wc_clean', explode( '|', trim(stripslashes($f_options[$i])) ) );
|
670 |
+
|
671 |
+
$fields[$name]['class'] = empty( $f_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_class[$i] ) );
|
672 |
+
$fields[$name]['label_class'] = empty( $f_label_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_label_class[$i] ) );
|
673 |
+
|
674 |
+
$fields[$name]['required'] = empty( $f_required[$i] ) ? false : true;
|
675 |
+
$fields[$name]['clear'] = empty( $f_clear[$i] ) ? false : true;
|
676 |
+
|
677 |
+
$fields[$name]['enabled'] = empty( $f_enabled[$i] ) ? false : true;
|
678 |
+
$fields[$name]['order'] = empty( $f_order[$i] ) ? '' : wc_clean( $f_order[$i] );
|
679 |
+
|
680 |
+
if (!empty( $fields[$name]['options'] )) {
|
681 |
+
$fields[$name]['options'] = array_combine( $fields[$name]['options'], $fields[$name]['options'] );
|
682 |
+
}
|
683 |
+
|
684 |
+
if (!in_array( $name, $this->locale_fields )){
|
685 |
+
$fields[$name]['validate'] = empty( $f_validation[$i] ) ? array() : explode( ',', $f_validation[$i] );
|
686 |
+
}
|
687 |
+
|
688 |
+
if (!$this->is_default_field_name( $name )){
|
689 |
+
$fields[$name]['custom'] = true;
|
690 |
+
$fields[$name]['show_in_email'] = empty( $f_show_in_email[$i] ) ? false : true;
|
691 |
+
$fields[$name]['show_in_order'] = empty( $f_show_in_order[$i] ) ? false : true;
|
692 |
+
} else {
|
693 |
+
$fields[$name]['custom'] = false;
|
694 |
+
}
|
695 |
+
|
696 |
+
$fields[$name]['label'] = __($fields[$name]['label'], 'woocommerce');
|
697 |
+
$fields[$name]['placeholder'] = __($fields[$name]['placeholder'], 'woocommerce');
|
698 |
+
}
|
699 |
+
|
700 |
+
uasort( $fields, array( $this, 'sort_fields_by_order' ) );
|
701 |
+
$result = update_option( 'wc_fields_' . $section, $fields );
|
702 |
+
|
703 |
+
if ( $result == true ) {
|
704 |
+
echo '<div class="updated"><p>' . __( 'Your changes were saved.', 'thwcfd' ) . '</p></div>';
|
705 |
+
} else {
|
706 |
+
echo '<div class="error"><p> ' . __( 'Your changes were not saved due to an error (or you made none!).', 'thwcfd' ) . '</p></div>';
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WooCommerce Checkout Field Editor (Manager) Pro ===
|
2 |
+
Contributors: ThemeHigh
|
3 |
+
Donate link: https://themehigh.com/
|
4 |
+
Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, checkout
|
5 |
+
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 1.2.0
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
WooCommerce Checkout Field Editor Pro - The best WooCommerce checkout manager plugin to customize checkout fields on your WooCommerce checkout page.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
= Introduction =
|
16 |
+
If you are wondering how to add custom field in WooCommerce checkout page, you are at the right place. Woo Checkout Field Editor Pro plugin provides an easy way to customise (add, edit, delete and change display order) your fields displayed on WooCommerce checkout page. This plugin requires WooCommerce to be installed, activated, and configured.
|
17 |
+
|
18 |
+
= BASIC FEATURES =
|
19 |
+
* <strong>Add new custom field(s).</strong> Adding custom fields to the WooCommerce checkout page is a breeze now. You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
|
20 |
+
* <strong>Edit field(s).</strong> You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
|
21 |
+
* Available field types are <strong>Input Text</strong> and <strong>Select</strong>
|
22 |
+
* <strong>Display in Order Details page and Email.</strong> You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are availabe in both the ‘New Field’ and ‘Edit Field’ forms.
|
23 |
+
* <strong>Remove field(s).</strong> You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
|
24 |
+
* <strong>Enable/Disable field(s).</strong> You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
|
25 |
+
* <strong>Change checkout fields order.</strong> You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
|
26 |
+
* <strong>Reset to default field set.</strong> You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
|
27 |
+
|
28 |
+
= BUY PREMIUM VERSION =
|
29 |
+
Check out the premium version of WooCommerce Checkout Field Editor Pro - The best WooCommerce checkout manager plugin which helps you to customize checkout fields displayed on your WooCommerce checkout page. Add custom fields to WooCommerce checkout page easily.
|
30 |
+
<a rel="nofollow" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking">Buy Now!</a>
|
31 |
+
|
32 |
+
<blockquote>
|
33 |
+
= PREMIUM VERSION FEATURES =
|
34 |
+
<ul>
|
35 |
+
<li><strong>12 field types are available:</strong> In Add New Field form and Edit Field form you can choose field type from a list of 12 including 10 input fields and one field for title/heading and one for label.
|
36 |
+
<p>Available field types:</p>
|
37 |
+
<ol>
|
38 |
+
<li><strong>Text</strong> – A basic input text field.</li>
|
39 |
+
<li><strong>Hidden</strong> – A hidden field.</li>
|
40 |
+
<li><strong>Password</strong> – An input password text box.</li>
|
41 |
+
<li><strong>Textarea</strong> – A textarea field.</li>
|
42 |
+
<li><strong>Radio</strong> – Radio button input (for selecting one of many choices)</li>
|
43 |
+
<li><strong>Checkbox</strong> – A checkbox field.</li>
|
44 |
+
<li><strong>Select</strong> – A drop-down list (for selecting one of many choices)</li>
|
45 |
+
<li><strong>Multi-select</strong> – A drop-down list (allows multiple selections from many choices)</li>
|
46 |
+
<li><strong>Date picker</strong> – Select a date from a popup.</li>
|
47 |
+
<li><strong>Time picker</strong> – Select a time from a popup.</li>
|
48 |
+
<li><strong>Heading</strong> – Display a heading/ title</li>
|
49 |
+
<li><strong>Label</strong> – Display a label/ text</li>
|
50 |
+
</ol>
|
51 |
+
</li>
|
52 |
+
<li><strong>Conditional Fields:</strong> Conditionally display fields based on cart items and other field(s) values.</li>
|
53 |
+
<li><strong>Price Fields:</strong> Add an extra cost to the cart total based on field selection.</li>
|
54 |
+
<li><strong>Add new section:</strong> Add new section(s) in predefined positions in checkout page.
|
55 |
+
<p>Available positions:</p>
|
56 |
+
<ol>
|
57 |
+
<li>Before customer details</li>
|
58 |
+
<li>After customer details</li>
|
59 |
+
<li>Before billing form</li>
|
60 |
+
<li>After billing form</li>
|
61 |
+
<li>Before shipping form</li>
|
62 |
+
<li>After shipping form</li>
|
63 |
+
<li>Before registration form</li>
|
64 |
+
<li>After registration form</li>
|
65 |
+
<li>Before order_notes</li>
|
66 |
+
<li>After order notes</li>
|
67 |
+
</ol>
|
68 |
+
</li>
|
69 |
+
<li><strong>Edit section(s) properties:</strong> Edit custom added section(s) label and display position.</li>
|
70 |
+
<li><strong>Delete section(s):</strong> Delete custom added section(s).</li>
|
71 |
+
</ul>
|
72 |
+
</blockquote>
|
73 |
+
|
74 |
+
== Installation ==
|
75 |
+
= Minimum Requirements =
|
76 |
+
* WooCommerce 2.2 +
|
77 |
+
* WordPress 3.8 or greater
|
78 |
+
* PHP version 5.2.4 or greater
|
79 |
+
* MySQL version 5.0 or greater
|
80 |
+
|
81 |
+
= Automatic installation =
|
82 |
+
1. Log in to your WordPress dashboard
|
83 |
+
2. Navigate to the Plugins menu and click Add New.
|
84 |
+
3. Search and locate 'WooCommerce Checkout Field Editor Pro' plugin.
|
85 |
+
4. Click 'Install Now'
|
86 |
+
|
87 |
+
= Manual installation =
|
88 |
+
The manual installation method involves downloading 'WooCommerce Checkout Field Editor Pro' plugin and uploading it to your webserver via FTP application. You may find more instructions on how to do this here (http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
|
89 |
+
|
90 |
+
== Frequently Asked Questions ==
|
91 |
+
= Can I go back to WooCommerce default settings at a later point? =
|
92 |
+
Yes. There is a button 'reset to default fields' to go back to the WooCommerce default fields.
|
93 |
+
|
94 |
+
== Screenshots ==
|
95 |
+
1. WooCommerce > Checkout Form
|
96 |
+
2. Reset to default field set
|
97 |
+
3. Save changes.
|
98 |
+
4. Enable, disable or remove field(s).
|
99 |
+
5. Change field(s) order.
|
100 |
+
6. Add new field popup form.
|
101 |
+
7. Edit field popup form.
|
102 |
+
8. Newly added field
|
103 |
+
|
104 |
+
== Changelog ==
|
105 |
+
= 1.2.0 =
|
106 |
+
* Fix for required validation issue with default address fields.
|
107 |
+
|
108 |
+
= 1.1.9 =
|
109 |
+
* Fix for required validation issue with default address fields.
|
110 |
+
|
111 |
+
= 1.1.8 =
|
112 |
+
* Fix for the issue of showing wrong value for placeholder text.
|
113 |
+
|
114 |
+
= 1.1.7 =
|
115 |
+
* Fix for checkout fields sorting(display order) issue.
|
116 |
+
|
117 |
+
= 1.1.6 =
|
118 |
+
* Multisite support added
|
119 |
+
* Removed deprecated function call.
|
120 |
+
|
121 |
+
= 1.1.5 =
|
122 |
+
* Updated plugin to make it compatible with WooCommerce version 3.0.0
|
123 |
+
|
124 |
+
= 1.1.4 =
|
125 |
+
* Fix for unsupported operand types issue.
|
126 |
+
|
127 |
+
= 1.1.3 =
|
128 |
+
* Fix for Address Fields property modification issues.
|
129 |
+
|
130 |
+
= 1.1.2 =
|
131 |
+
* Fix for 'Invalid argument passed' warning message.
|
132 |
+
|
133 |
+
= 1.1.1 =
|
134 |
+
* Fix for 'Undefined index' warning/error message.
|
135 |
+
|
136 |
+
= 1.0.9 =
|
137 |
+
* Fix for enhanced select pre populate issue in admin settings page.
|
138 |
+
|
139 |
+
= 1.0.8 =
|
140 |
+
* Fix for translation issue with default checkout fields.
|
141 |
+
* Fix for additional field(s) display issue in order details page.
|
142 |
+
* Fix for additional field(s) disable feature not working issue.
|
143 |
+
|
144 |
+
= 1.0.7 =
|
145 |
+
* Fix for Additional Filed title display issue when Additional Fields are not available.
|
146 |
+
|
147 |
+
= 1.0.6 =
|
148 |
+
* Fix for the issue, custom field(s) value in additional filed section not displaying in order review page.
|
149 |
+
|
150 |
+
= 1.0.3 =
|
151 |
+
* Change checkout field order JavaScript conflict workaround added
|
152 |
+
|
153 |
+
= 1.0.2 =
|
154 |
+
* Display custom fields in order review issue fix
|
155 |
+
|
156 |
+
= 1.0.1 =
|
157 |
+
* Added the reset to default button
|
158 |
+
|
159 |
+
= 1.0.0 =
|
160 |
+
* First Release
|
161 |
+
* Add new checkout fields.
|
162 |
+
* Edit checkout fields.
|
163 |
+
* Remove checkout fields.
|
164 |
+
* Change the display order of checkout fields.
|