Version Description
- New field types added (Textarea, Radio, Email, Phone, Password).
Download this release
Release Info
Developer | ThemeHigh |
Plugin | WooCommerce Checkout Field Editor (Manager) Pro |
Version | 1.3.6 |
Comparing to | |
See all releases |
Code changes from version 1.3.5 to 1.3.6
- assets/css/thwcfd-admin.css +312 -0
- assets/css/thwcfd-public.css +0 -0
- assets/css/thwcfd-style.css +0 -173
- assets/js/thwcfd-admin.js +438 -389
- assets/js/{thwcfd-checkout-field-editor-frontend.js → thwcfd-checkout.js} +0 -0
- checkout-form-designer.php +11 -472
- classes/class-thwcfd-checkout.php +448 -0
- classes/class-thwcfd-settings-general.php +689 -0
- classes/class-thwcfd-settings.php +115 -0
- classes/class-thwcfd-utils.php +300 -0
- classes/class-thwcfd.php +69 -0
- classes/class-wc-checkout-field-editor.php +0 -795
- readme.txt +29 -20
assets/css/thwcfd-admin.css
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
/***** TABS & SECTIONS ******
|
3 |
+
****************************/
|
4 |
+
.thpladmin-tabs a{
|
5 |
+
font-size: 16px;
|
6 |
+
}
|
7 |
+
.thpladmin-sections {
|
8 |
+
list-style: outside none none;
|
9 |
+
margin: 8px 0 0;
|
10 |
+
padding: 0;
|
11 |
+
font-size: 15px;
|
12 |
+
color: #666;
|
13 |
+
}
|
14 |
+
.thpladmin-sections li {
|
15 |
+
display: inline-block;
|
16 |
+
margin: 0px;
|
17 |
+
padding: 0px;
|
18 |
+
white-space: nowrap;
|
19 |
+
}
|
20 |
+
.thpladmin-sections a {
|
21 |
+
line-height: 2;
|
22 |
+
padding: 0.2em;
|
23 |
+
text-decoration: none;
|
24 |
+
}
|
25 |
+
.thpladmin-sections a.current {
|
26 |
+
font-weight: 600;
|
27 |
+
border: medium none;
|
28 |
+
color: #000;
|
29 |
+
}
|
30 |
+
|
31 |
+
/***** FIELDS TABLE ******
|
32 |
+
*************************/
|
33 |
+
.err_msgs{
|
34 |
+
color: #FF0000;
|
35 |
+
}
|
36 |
+
|
37 |
+
table.thpladmin_fields_table{
|
38 |
+
position: relative;
|
39 |
+
background: #fff;
|
40 |
+
border: 1px solid #e5e5e5;
|
41 |
+
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
42 |
+
border-spacing: 0;
|
43 |
+
width: 100%;
|
44 |
+
clear: both;
|
45 |
+
margin: 0;
|
46 |
+
}
|
47 |
+
|
48 |
+
table.thpladmin_fields_table thead th,
|
49 |
+
table.thpladmin_fields_table tfoot th {
|
50 |
+
color: #32373c;
|
51 |
+
font-weight: 400;
|
52 |
+
text-align: left;
|
53 |
+
font-size: 14px;
|
54 |
+
}
|
55 |
+
table.thpladmin_fields_table thead th {
|
56 |
+
border-bottom: 1px solid #e1e1e1;
|
57 |
+
border-bottom-color: rgb(225, 225, 225);
|
58 |
+
border-bottom-style: solid;
|
59 |
+
border-bottom-width: 1px;
|
60 |
+
}
|
61 |
+
|
62 |
+
.thpladmin_fields_table tfoot td,
|
63 |
+
.thpladmin_fields_table tfoot th {
|
64 |
+
border-top: 1px solid #e1e1e1;
|
65 |
+
border-bottom: none;
|
66 |
+
}
|
67 |
+
|
68 |
+
table.thpladmin_fields_table td{
|
69 |
+
color: #555;
|
70 |
+
}
|
71 |
+
table.thpladmin_fields_table tr:nth-child(2n+1) td{
|
72 |
+
background: #f9f9f9;
|
73 |
+
}
|
74 |
+
|
75 |
+
table.thpladmin_fields_table td,
|
76 |
+
table.thpladmin_fields_table th{
|
77 |
+
display: table-cell !important;
|
78 |
+
padding: 13px !important;
|
79 |
+
vertical-align: top;
|
80 |
+
line-height: 22px;
|
81 |
+
}
|
82 |
+
|
83 |
+
table.thpladmin_fields_table thead th.status,
|
84 |
+
table.thpladmin_fields_table tfoot th.status,
|
85 |
+
table.thpladmin_fields_table tbody td.status {
|
86 |
+
text-align: center;
|
87 |
+
}
|
88 |
+
|
89 |
+
table.thpladmin_fields_table td.sort{
|
90 |
+
cursor: move;
|
91 |
+
font-size: 20px !important;
|
92 |
+
padding: 13px !important;
|
93 |
+
text-align: center;
|
94 |
+
}
|
95 |
+
table.thpladmin_fields_table td.sort::before{
|
96 |
+
content: '\f333';
|
97 |
+
font-family: Dashicons;
|
98 |
+
text-align: center;
|
99 |
+
line-height: 1;
|
100 |
+
color: #999;
|
101 |
+
display: block;
|
102 |
+
width: 17px;
|
103 |
+
float: left;
|
104 |
+
height: 100%;
|
105 |
+
line-height: 24px;
|
106 |
+
}
|
107 |
+
|
108 |
+
table.thpladmin_fields_table td.action{
|
109 |
+
padding: 10px 12px !important;
|
110 |
+
}
|
111 |
+
table.thpladmin_fields_table td.action .action-btn{
|
112 |
+
padding: 2px 4px;
|
113 |
+
line-height: 15px;
|
114 |
+
height: 22px;
|
115 |
+
/*background-color: #f7f7f7;*/
|
116 |
+
}
|
117 |
+
|
118 |
+
table.thpladmin_fields_table tr.thpladmin-strikeout td {
|
119 |
+
background: rgba(255, 0, 0, .4)!important;
|
120 |
+
opacity: 0.6;
|
121 |
+
text-decoration: line-through;
|
122 |
+
}
|
123 |
+
|
124 |
+
table.thpladmin_fields_table tr.thpladmin-disabled td {
|
125 |
+
opacity: 0.4;
|
126 |
+
}
|
127 |
+
table.thpladmin_fields_table tr.thpladmin-disabled td.td_select {
|
128 |
+
opacity: 1;
|
129 |
+
}
|
130 |
+
|
131 |
+
.thpladmin-dynamic-row-table .action-cell{
|
132 |
+
width: 30px;
|
133 |
+
text-align: center;
|
134 |
+
}
|
135 |
+
.thpladmin-dynamic-row-table .action-cell a.btn{
|
136 |
+
background-color:#00A0D2;
|
137 |
+
border:1px solid #0073AA;
|
138 |
+
color:#FFFFFF;
|
139 |
+
padding:2px 5px;
|
140 |
+
border-radius: 3px;
|
141 |
+
font-size:12px;
|
142 |
+
text-decoration:none;
|
143 |
+
}
|
144 |
+
.thpladmin-dynamic-row-table .action-cell a.btn-blue{
|
145 |
+
background-color:#00A0D2;
|
146 |
+
border:1px solid #0073AA;
|
147 |
+
}
|
148 |
+
.thpladmin-dynamic-row-table .action-cell a.btn-red{
|
149 |
+
background-color:#ff6666;
|
150 |
+
border:1px solid #ff4c4c;
|
151 |
+
}
|
152 |
+
|
153 |
+
.thpladmin-dynamic-row-table .action-cell a.dashicons{
|
154 |
+
line-height: inherit;
|
155 |
+
font-size: 18px;
|
156 |
+
color: #fff;
|
157 |
+
border-radius: 3px;
|
158 |
+
box-shadow: 0 1px 0 #ccc;
|
159 |
+
}
|
160 |
+
.thpladmin-dynamic-row-table .action-cell a.dashicons-plus{
|
161 |
+
background-color:#00A0D2;
|
162 |
+
border:1px solid #0073AA;
|
163 |
+
}
|
164 |
+
.thpladmin-dynamic-row-table .action-cell a.dashicons-no-alt{
|
165 |
+
background-color:#ff6666;
|
166 |
+
border:1px solid #ff4c4c;
|
167 |
+
}
|
168 |
+
|
169 |
+
/***** PREMIUM NOTICE ******
|
170 |
+
****************************/
|
171 |
+
.thpladmin-notice a {
|
172 |
+
display:block;
|
173 |
+
padding:0;
|
174 |
+
height: 63px;
|
175 |
+
}
|
176 |
+
.thpladmin-notice p {
|
177 |
+
margin-bottom:0px;
|
178 |
+
}
|
179 |
+
.thpladmin-notice ul {
|
180 |
+
list-style-type: none;
|
181 |
+
margin: 0px;
|
182 |
+
}
|
183 |
+
.thpladmin-notice ul li {
|
184 |
+
background:url("tick.png") no-repeat 0 50%;
|
185 |
+
padding-left: 20px;
|
186 |
+
}
|
187 |
+
|
188 |
+
/***** SELECT2 OVERRIDE ******
|
189 |
+
****************************/
|
190 |
+
.select2-drop-mask {
|
191 |
+
z-index: 99999998!important;
|
192 |
+
}
|
193 |
+
.select2-drop {
|
194 |
+
z-index: 99999999!important;
|
195 |
+
}
|
196 |
+
.select2-container {
|
197 |
+
z-index: 99999999!important;
|
198 |
+
}
|
199 |
+
.select2-container .select2-search--inline .select2-search__field {
|
200 |
+
margin-top: 0px !important;
|
201 |
+
margin-bottom: 0px !important;
|
202 |
+
}
|
203 |
+
.select2-container .select2-search__field{
|
204 |
+
min-width: 0 !important;
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
|
209 |
+
.woocommerce-message {
|
210 |
+
margin-top: 10px;
|
211 |
+
}
|
212 |
+
#wc_checkout_fields {
|
213 |
+
margin-top: 10px;
|
214 |
+
}
|
215 |
+
#wc_checkout_fields thead th input {
|
216 |
+
margin: 2px 0 0 0 !important;
|
217 |
+
}
|
218 |
+
#wc_checkout_fields tbody .description {
|
219 |
+
display: none;
|
220 |
+
color: #999;
|
221 |
+
}
|
222 |
+
#wc_checkout_fields tbody td {
|
223 |
+
overflow: visible !important;
|
224 |
+
padding: 7px;
|
225 |
+
cursor: move;
|
226 |
+
vertical-align: middle;
|
227 |
+
}
|
228 |
+
#wc_checkout_fields tbody td:last-child,
|
229 |
+
#wc_checkout_fields tbody th:last-child {
|
230 |
+
padding-right: 14px;
|
231 |
+
}
|
232 |
+
#wc_checkout_fields tbody input.input-text,
|
233 |
+
#wc_checkout_fields tbody td select {
|
234 |
+
width: 100%;
|
235 |
+
}
|
236 |
+
#wc_checkout_fields tfoot .description {
|
237 |
+
color: #999;
|
238 |
+
}
|
239 |
+
#wc_checkout_fields .check-column {
|
240 |
+
padding: 7px 0 7px 14px;
|
241 |
+
}
|
242 |
+
#wc_checkout_fields strong.core-field {
|
243 |
+
color: #a4688d;
|
244 |
+
}
|
245 |
+
#wc_checkout_fields .field-type,
|
246 |
+
#wc_checkout_fields .field-options,
|
247 |
+
#wc_checkout_fields span.na,
|
248 |
+
#wc_checkout_fields .field-validation {
|
249 |
+
text-align: center;
|
250 |
+
color: #aaa;
|
251 |
+
}
|
252 |
+
#wc_checkout_fields .field-type select,
|
253 |
+
#wc_checkout_fields .field-options select,
|
254 |
+
#wc_checkout_fields span.na select,
|
255 |
+
#wc_checkout_fields .field-validation select,
|
256 |
+
#wc_checkout_fields .field-type div,
|
257 |
+
#wc_checkout_fields .field-options div,
|
258 |
+
#wc_checkout_fields span.na div,
|
259 |
+
#wc_checkout_fields .field-validation div,
|
260 |
+
#wc_checkout_fields .field-type input,
|
261 |
+
#wc_checkout_fields .field-options input,
|
262 |
+
#wc_checkout_fields span.na input,
|
263 |
+
#wc_checkout_fields .field-validation input {
|
264 |
+
text-align: left;
|
265 |
+
}
|
266 |
+
#wc_checkout_fields span.na {
|
267 |
+
display: block;
|
268 |
+
}
|
269 |
+
#wc_checkout_fields .clear {
|
270 |
+
text-align: center;
|
271 |
+
}
|
272 |
+
#wc_checkout_fields tr.disabled td {
|
273 |
+
opacity: 0.3;
|
274 |
+
text-decoration: line-through;
|
275 |
+
}
|
276 |
+
#wc_checkout_fields tr.disabled td:first-child {
|
277 |
+
opacity:1;
|
278 |
+
}
|
279 |
+
tr.strikeout1 td:before {
|
280 |
+
content: " ";
|
281 |
+
position: absolute;
|
282 |
+
top: 50%;
|
283 |
+
left: 0;
|
284 |
+
border-bottom: 1px solid #FF0000;
|
285 |
+
width: 100%;
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
|
290 |
+
|
291 |
+
|
292 |
+
|
293 |
+
|
294 |
+
|
295 |
+
|
296 |
+
.wcfd_popup_wrapper input[type="text"]:disabled, .wcfd_popup_wrapper select:disabled {
|
297 |
+
background: #f6f6f6;
|
298 |
+
}
|
299 |
+
|
300 |
+
h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
301 |
+
border-bottom: 1px solid #CCC;
|
302 |
+
padding-bottom: 0px;
|
303 |
+
padding-left: 10px;
|
304 |
+
}
|
305 |
+
|
306 |
+
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-title {
|
307 |
+
line-height: 20px;
|
308 |
+
}
|
309 |
+
|
310 |
+
/*.select2-drop {
|
311 |
+
z-index: 999999!important;
|
312 |
+
}*/
|
assets/css/thwcfd-public.css
ADDED
File without changes
|
assets/css/thwcfd-style.css
DELETED
@@ -1,173 +0,0 @@
|
|
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 |
-
table.thpladmin_fields_table td.sort{
|
94 |
-
cursor: move;
|
95 |
-
font-size: 15px;
|
96 |
-
text-align: center;
|
97 |
-
}
|
98 |
-
|
99 |
-
table.thpladmin_fields_table td.sort::before{
|
100 |
-
content: '\f333';
|
101 |
-
font-family: Dashicons;
|
102 |
-
text-align: center;
|
103 |
-
line-height: 1;
|
104 |
-
color: #999;
|
105 |
-
display: block;
|
106 |
-
width: 17px;
|
107 |
-
float: left;
|
108 |
-
height: 100%;
|
109 |
-
line-height: 24px;
|
110 |
-
}
|
111 |
-
|
112 |
-
.err_msgs{
|
113 |
-
color: #FF0000;
|
114 |
-
}
|
115 |
-
|
116 |
-
.thwcfd-sections {
|
117 |
-
list-style: outside none none;
|
118 |
-
margin: 8px 0 0;
|
119 |
-
padding: 0;
|
120 |
-
font-size: 13px;
|
121 |
-
color: #666;
|
122 |
-
}
|
123 |
-
.thwcfd-sections li {
|
124 |
-
display: inline-block;
|
125 |
-
margin: 0px;
|
126 |
-
padding: 0px;
|
127 |
-
white-space: nowrap;
|
128 |
-
}
|
129 |
-
.thwcfd-sections a.current {
|
130 |
-
font-weight: 600;
|
131 |
-
border: medium none;
|
132 |
-
color: #000;
|
133 |
-
}
|
134 |
-
.thwcfd-sections a {
|
135 |
-
line-height: 2;
|
136 |
-
padding: 0.2em;
|
137 |
-
text-decoration: none;
|
138 |
-
}
|
139 |
-
|
140 |
-
.thwcfd-notice a {
|
141 |
-
display:block;
|
142 |
-
padding:0;
|
143 |
-
height: 63px;
|
144 |
-
}
|
145 |
-
.thwcfd-notice p {
|
146 |
-
margin-bottom:0px;
|
147 |
-
}
|
148 |
-
.thwcfd-notice ul {
|
149 |
-
list-style-type: none;
|
150 |
-
margin: 0px;
|
151 |
-
}
|
152 |
-
.thwcfd-notice ul li {
|
153 |
-
background:url("tick.png") no-repeat 0 50%;
|
154 |
-
padding-left: 20px;
|
155 |
-
}
|
156 |
-
|
157 |
-
.wcfd_popup_wrapper input[type="text"]:disabled, .wcfd_popup_wrapper select:disabled {
|
158 |
-
background: #f6f6f6;
|
159 |
-
}
|
160 |
-
|
161 |
-
h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
162 |
-
border-bottom: 1px solid #CCC;
|
163 |
-
padding-bottom: 0px;
|
164 |
-
padding-left: 10px;
|
165 |
-
}
|
166 |
-
|
167 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-title {
|
168 |
-
line-height: 20px;
|
169 |
-
}
|
170 |
-
|
171 |
-
/*.select2-drop {
|
172 |
-
z-index: 999999!important;
|
173 |
-
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/thwcfd-admin.js
CHANGED
@@ -1,453 +1,502 @@
|
|
1 |
-
var
|
|
|
|
|
2 |
var MSG_INVALID_NAME = 'NAME/ID must begin with a lowercase letter ([a-z]) and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")';
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
});
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
});
|
50 |
-
});
|
51 |
-
|
52 |
-
$('#wcfd_checkout_fields tbody').sortable({
|
53 |
-
items:'tr',
|
54 |
-
cursor:'move',
|
55 |
-
axis:'y',
|
56 |
-
handle: 'td.sort',
|
57 |
-
scrollSensitivity:40,
|
58 |
-
helper:function(e,ui){
|
59 |
-
ui.children().each(function(){
|
60 |
-
$(this).width($(this).width());
|
61 |
-
});
|
62 |
-
ui.css('left', '0');
|
63 |
-
return ui;
|
64 |
-
}
|
65 |
-
});
|
66 |
-
|
67 |
-
$("#wcfd_checkout_fields tbody").on("sortstart", function( event, ui ){
|
68 |
-
ui.item.css('background-color','#f6f6f6');
|
69 |
-
});
|
70 |
-
$("#wcfd_checkout_fields tbody").on("sortstop", function( event, ui ){
|
71 |
-
ui.item.removeAttr('style');
|
72 |
-
wcfd_prepare_field_order_indexes();
|
73 |
-
});
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
-
var form = $("#
|
81 |
-
|
82 |
-
form.find("
|
83 |
-
|
84 |
-
form
|
85 |
-
|
86 |
-
|
|
|
87 |
}
|
88 |
-
|
89 |
-
function
|
90 |
-
var
|
91 |
-
var
|
92 |
-
|
93 |
-
var
|
94 |
-
|
95 |
-
|
96 |
-
var
|
97 |
-
var
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
var err_msgs = '';
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
err_msgs = 'Name is required';
|
111 |
}else if(!isHtmlIdValid(name)){
|
112 |
err_msgs = MSG_INVALID_NAME;
|
113 |
-
}
|
114 |
-
err_msgs = 'Type is required';
|
115 |
-
}
|
116 |
|
117 |
if(err_msgs != ''){
|
118 |
-
|
119 |
return false;
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
showinorder = showinorder ? 1 : 0;
|
128 |
-
|
129 |
-
validations = validations ? validations : '';
|
130 |
-
|
131 |
-
var index = $('#wcfd_checkout_fields tbody tr').size();
|
132 |
-
|
133 |
-
var newRow = '<tr class="row_'+index+'">';
|
134 |
-
newRow += '<td width="1%" class="sort ui-sortable-handle">';
|
135 |
-
newRow += '<input type="hidden" name="f_order['+index+']" class="f_order" value="'+index+'" />';
|
136 |
-
newRow += '<input type="hidden" name="f_name['+index+']" class="f_name" value="" />';
|
137 |
-
newRow += '<input type="hidden" name="f_name_new['+index+']" class="f_name_new" value="'+name+'" />';
|
138 |
-
newRow += '<input type="hidden" name="f_type['+index+']" class="f_type" value="'+type+'" />';
|
139 |
-
newRow += '<input type="hidden" name="f_label['+index+']" class="f_label" value="'+label+'" />';
|
140 |
-
newRow += '<input type="hidden" name="f_placeholder['+index+']" class="f_placeholder" value="'+placeholder+'" />';
|
141 |
-
newRow += '<input type="hidden" name="f_options['+index+']" class="f_options" value="'+optionsList+'" />';
|
142 |
-
|
143 |
-
newRow += '<input type="hidden" name="f_class['+index+']" class="f_class" value="'+fieldClass+'" />';
|
144 |
-
newRow += '<input type="hidden" name="f_label_class['+index+']" class="f_label_class" value="'+labelClass+'" />';
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
}else{
|
170 |
-
|
171 |
}
|
172 |
-
|
173 |
-
newRow += '<td><button type="button" onclick="openEditFieldForm(this)">Edit</button></td>';
|
174 |
-
newRow += '</tr>';
|
175 |
-
|
176 |
-
$('#wcfd_checkout_fields tbody tr:last').after(newRow);
|
177 |
-
return true;
|
178 |
}
|
179 |
-
|
180 |
-
|
181 |
-
var
|
182 |
-
|
183 |
-
var is_custom = row.find(".f_custom").val();
|
184 |
-
var name = row.find(".f_name").val();
|
185 |
-
var type = row.find(".f_type").val();
|
186 |
-
var label = row.find(".f_label").val();
|
187 |
-
var placeholder = row.find(".f_placeholder").val();
|
188 |
-
var optionsList = row.find(".f_options").val();
|
189 |
-
|
190 |
-
var field_classes = row.find(".f_class").val();
|
191 |
-
var label_classes = row.find(".f_label_class").val();
|
192 |
-
|
193 |
-
var required = row.find(".f_required").val();
|
194 |
-
var clearRow = row.find(".f_clear").val();
|
195 |
-
|
196 |
-
var enabled = row.find(".f_enabled").val();
|
197 |
-
var validations = row.find(".f_validation").val();
|
198 |
-
|
199 |
-
var showinemail = row.find(".f_show_in_email").val();
|
200 |
-
var showinorder = row.find(".f_show_in_order").val();
|
201 |
-
|
202 |
-
is_custom = is_custom == 1 ? true : false;
|
203 |
-
|
204 |
-
required = required == 1 ? true : false;
|
205 |
-
clearRow = clearRow == 1 ? true : false;
|
206 |
-
enabled = enabled == 1 ? true : false;
|
207 |
-
|
208 |
-
validations = validations.split(",");
|
209 |
-
|
210 |
-
showinemail = showinemail == 1 ? true : false;
|
211 |
-
showinorder = showinorder == 1 ? true : false;
|
212 |
-
|
213 |
-
showinemail = is_custom == true ? showinemail : true;
|
214 |
-
showinorder = is_custom == true ? showinorder : true;
|
215 |
-
|
216 |
-
var form = $("#wcfd_edit_field_form_pp");
|
217 |
-
form.find('.err_msgs').html('');
|
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 |
-
|
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
|
259 |
-
var
|
260 |
-
|
261 |
-
var
|
262 |
-
|
263 |
-
|
264 |
-
|
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(!isHtmlIdValid(name)){
|
283 |
-
err_msgs = MSG_INVALID_NAME;
|
284 |
-
}else if(type == ''){
|
285 |
-
err_msgs = 'Type is required';
|
286 |
-
}
|
287 |
-
|
288 |
-
if(err_msgs != ''){
|
289 |
-
$(form).find('.err_msgs').html(err_msgs);
|
290 |
-
return false;
|
291 |
}
|
292 |
-
|
293 |
-
required = required ? 1 : 0;
|
294 |
-
clearRow = clearRow ? 1 : 0;
|
295 |
-
enabled = enabled ? 1 : 0;
|
296 |
-
|
297 |
-
showinemail = showinemail ? 1 : 0;
|
298 |
-
showinorder = showinorder ? 1 : 0;
|
299 |
-
|
300 |
-
validations = validations ? validations : '';
|
301 |
-
|
302 |
-
var row = $('#wcfd_checkout_fields tbody').find('.row_'+rowId);
|
303 |
-
row.find(".f_name").val(name);
|
304 |
-
row.find(".f_type").val(type);
|
305 |
-
row.find(".f_label").val(label);
|
306 |
-
row.find(".f_placeholder").val(placeholder);
|
307 |
-
row.find(".f_options").val(optionsList);
|
308 |
-
|
309 |
-
row.find(".f_class").val(fieldClass);
|
310 |
-
row.find(".f_label_class").val(labelClass);
|
311 |
-
|
312 |
-
row.find(".f_required").val(required);
|
313 |
-
row.find(".f_clear").val(clearRow);
|
314 |
-
row.find(".f_enabled").val(enabled);
|
315 |
-
|
316 |
-
row.find(".f_show_in_email").val(showinemail);
|
317 |
-
row.find(".f_show_in_order").val(showinorder);
|
318 |
-
row.find(".f_validation").val(validations);
|
319 |
-
|
320 |
-
row.find(".td_name").html(name);
|
321 |
-
row.find(".td_type").html(type);
|
322 |
-
row.find(".td_label").html(label);
|
323 |
-
row.find(".td_placeholder").html(placeholder);
|
324 |
-
row.find(".td_validate").html(""+validations+"");
|
325 |
-
row.find(".td_required").html(required == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
326 |
-
row.find(".td_clear").html(clearRow == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
327 |
-
row.find(".td_enabled").html(enabled == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
328 |
-
return true;
|
329 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
-
|
332 |
-
$(
|
333 |
-
$('#
|
334 |
-
|
|
|
|
|
|
|
|
|
335 |
var row = $(this).closest('tr');
|
336 |
-
|
337 |
-
|
|
|
338 |
}
|
|
|
339 |
row.find(".f_deleted").val(1);
|
340 |
row.find(".f_edit_btn").prop('disabled', true);
|
341 |
-
//row.find('.sort').removeClass('sort');
|
342 |
});
|
343 |
}
|
344 |
-
|
345 |
-
|
346 |
-
$('#
|
347 |
var row = $(this).closest('tr');
|
|
|
|
|
348 |
if(enabled == 0){
|
349 |
-
if(!row.hasClass("
|
350 |
-
row.addClass("
|
351 |
}
|
|
|
|
|
|
|
352 |
}else{
|
353 |
-
row.removeClass("
|
|
|
|
|
|
|
354 |
}
|
355 |
-
|
356 |
-
row.find(".f_edit_btn").prop('disabled', enabled == 1 ? false : true);
|
357 |
-
row.find(".td_enabled").html(enabled == 1 ? '<span class="status-enabled tips">Yes</span>' : '-');
|
358 |
-
row.find(".f_enabled").val(enabled);
|
359 |
});
|
360 |
}
|
361 |
|
362 |
-
function wcfd_clear_form( form ){
|
363 |
-
form.find('.err_msgs').html('');
|
364 |
-
form.find("input[name=fname]").val('');
|
365 |
-
form.find("input[name=fnameNew]").val('');
|
366 |
-
form.find("select[name=ftype]").prop('selectedIndex',0);
|
367 |
-
form.find("input[name=flabel]").val('');
|
368 |
-
form.find("input[name=fplaceholder]").val('');
|
369 |
-
form.find("input[name=foptions]").val('');
|
370 |
-
|
371 |
-
form.find("input[name=fclass]").val('');
|
372 |
-
form.find("input[name=flabelclass]").val('');
|
373 |
-
form.find("select[name=fvalidate] option:selected").removeProp('selected');
|
374 |
-
|
375 |
-
form.find("input[name=frequired]").prop('checked', true);
|
376 |
-
form.find("input[name=fclearRow]").prop('checked', true);
|
377 |
-
form.find("input[name=fenabled]").prop('checked', true);
|
378 |
-
form.find("input[name=fshowinemail]").prop('checked', true);
|
379 |
-
form.find("input[name=fshowinorder]").prop('checked', true);
|
380 |
-
}
|
381 |
-
|
382 |
-
function wcfd_prepare_field_order_indexes() {
|
383 |
-
$('#wcfd_checkout_fields tbody tr').each(function(index, el){
|
384 |
-
$('input.f_order', el).val( parseInt( $(el).index('#wcfd_checkout_fields tbody tr') ) );
|
385 |
-
});
|
386 |
-
};
|
387 |
-
|
388 |
-
_fieldTypeChangeListner = function fieldTypeChangeListner(elm){
|
389 |
-
var type = $(elm).val();
|
390 |
-
var form = $(elm).closest('form');
|
391 |
-
|
392 |
-
showAllFields(form);
|
393 |
-
if(type === 'select'){
|
394 |
-
//form.find('.rowPlaceholder').hide();
|
395 |
-
form.find('.rowValidate').hide();
|
396 |
-
}else{
|
397 |
-
form.find('.rowOptions').hide();
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
function showAllFields(form){
|
402 |
-
form.find('.rowOptions').show();
|
403 |
-
form.find('.rowPlaceholder').show();
|
404 |
-
form.find('.rowValidate').show();
|
405 |
-
}
|
406 |
-
|
407 |
-
_selectAllCheckoutFields = function selectAllCheckoutFields(elm){
|
408 |
-
var checkAll = $(elm).prop('checked');
|
409 |
-
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
410 |
-
}
|
411 |
-
|
412 |
-
function isHtmlIdValid(id) {
|
413 |
-
var re = /^[a-z\_]+[a-z0-9\_]*$/;
|
414 |
-
return re.test(id.trim());
|
415 |
-
}
|
416 |
-
|
417 |
return {
|
418 |
-
openNewFieldForm :
|
419 |
-
openEditFieldForm :
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
|
|
|
|
424 |
};
|
425 |
}(window.jQuery, window, document));
|
426 |
|
427 |
-
function
|
428 |
-
|
429 |
}
|
430 |
|
431 |
-
function
|
432 |
-
|
433 |
}
|
434 |
|
435 |
-
function
|
436 |
-
|
437 |
}
|
438 |
|
439 |
-
function
|
440 |
-
|
441 |
}
|
442 |
|
443 |
-
function
|
444 |
-
|
445 |
}
|
446 |
|
447 |
-
function
|
448 |
-
|
449 |
}
|
450 |
|
451 |
function thwcfdSelectAllCheckoutFields(elm){
|
452 |
-
|
453 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var thwcfd_settings = (function($, window, document) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
var MSG_INVALID_NAME = 'NAME/ID must begin with a lowercase letter ([a-z]) and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")';
|
5 |
+
var OPTION_ROW_HTML = '<tr>';
|
6 |
+
OPTION_ROW_HTML += '<td style="width:150px;"><input type="text" name="i_options_key[]" placeholder="Option Value" style="width:140px;"/></td>';
|
7 |
+
OPTION_ROW_HTML += '<td style="width:190px;"><input type="text" name="i_options_text[]" placeholder="Option Text" style="width:180px;"/></td>';
|
8 |
+
OPTION_ROW_HTML += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>';
|
9 |
+
OPTION_ROW_HTML += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>';
|
10 |
+
OPTION_ROW_HTML += '<td class="action-cell sort ui-sortable-handle"></td>';
|
11 |
+
OPTION_ROW_HTML += '</tr>';
|
12 |
+
|
13 |
+
$(function() {
|
14 |
+
$( "#thwcfd_new_field_form_pp" ).dialog({
|
15 |
+
modal: true,
|
16 |
+
width: 600,
|
17 |
+
resizable: false,
|
18 |
+
autoOpen: false,
|
19 |
+
buttons: [{
|
20 |
+
text: "Save",
|
21 |
+
click: function() {
|
22 |
+
var form = $("#thwcfd_new_field_form");
|
23 |
+
var valid = validate_field_form(form);
|
24 |
+
if(valid){
|
25 |
+
prepare_field_form(form);
|
26 |
+
form.submit();
|
27 |
+
}
|
28 |
}
|
29 |
+
}]
|
30 |
+
});
|
31 |
+
|
32 |
+
$( "#thwcfd_edit_field_form_pp" ).dialog({
|
33 |
+
modal: true,
|
34 |
+
width: 600,
|
35 |
+
resizable: false,
|
36 |
+
autoOpen: false,
|
37 |
+
buttons: [{
|
38 |
+
text: "Save",
|
39 |
+
click: function() {
|
40 |
+
var form = $("#thwcfd_edit_field_form");
|
41 |
+
var valid = validate_field_form(form);
|
42 |
+
if(valid){
|
43 |
+
prepare_field_form(form);
|
44 |
+
form.submit();
|
45 |
+
}
|
46 |
}
|
47 |
+
}]
|
48 |
+
});
|
49 |
+
|
50 |
+
$('select.thwcfd-enhanced-multi-select').select2({
|
51 |
+
minimumResultsForSearch: 10,
|
52 |
+
allowClear : true,
|
53 |
+
placeholder: $(this).data('placeholder')
|
54 |
+
}).addClass('enhanced');
|
55 |
+
|
56 |
+
$('#thwcfd_checkout_fields tbody').sortable({
|
57 |
+
items:'tr',
|
58 |
+
cursor:'move',
|
59 |
+
axis:'y',
|
60 |
+
handle: 'td.sort',
|
61 |
+
scrollSensitivity:40,
|
62 |
+
helper:function(e,ui){
|
63 |
+
ui.children().each(function(){
|
64 |
+
$(this).width($(this).width());
|
65 |
+
});
|
66 |
+
ui.css('left', '0');
|
67 |
+
return ui;
|
68 |
}
|
69 |
+
});
|
70 |
+
|
71 |
+
$("#thwcfd_checkout_fields tbody").on("sortstart", function( event, ui ){
|
72 |
+
ui.item.css('background-color','#f6f6f6');
|
73 |
+
});
|
74 |
+
$("#thwcfd_checkout_fields tbody").on("sortstop", function( event, ui ){
|
75 |
+
ui.item.removeAttr('style');
|
76 |
+
prepare_field_order_indexes();
|
77 |
+
});
|
78 |
});
|
79 |
+
|
80 |
+
function isHtmlIdValid(id) {
|
81 |
+
var re = /^[a-z\_]+[a-z0-9\_]*$/;
|
82 |
+
return re.test(id.trim());
|
83 |
+
}
|
84 |
+
|
85 |
+
function decodeHtml(str) {
|
86 |
+
if($.type(str)=== "string"){
|
87 |
+
var map = {
|
88 |
+
'&': '&',
|
89 |
+
'<': '<',
|
90 |
+
'>': '>',
|
91 |
+
'"': '"',
|
92 |
+
''': "'"
|
93 |
+
};
|
94 |
+
return str.replace(/&|<|>|"|'/g, function(m) {return map[m];});
|
95 |
+
}
|
96 |
+
return str;
|
97 |
+
}
|
98 |
+
|
99 |
+
function get_property_field_value(form, type, name){
|
100 |
+
var value = '';
|
101 |
+
|
102 |
+
switch(type) {
|
103 |
+
case 'select':
|
104 |
+
value = form.find("select[name=i_"+name+"]").val();
|
105 |
+
value = value == null ? '' : value;
|
106 |
+
break;
|
107 |
+
|
108 |
+
case 'checkbox':
|
109 |
+
value = form.find("input[name=i_"+name+"]").prop('checked');
|
110 |
+
value = value ? 1 : 0;
|
111 |
+
break;
|
112 |
+
|
113 |
+
case 'textarea':
|
114 |
+
value = form.find("textarea[name=i_"+name+"]").val();
|
115 |
+
value = value == null ? '' : value;
|
116 |
|
117 |
+
default:
|
118 |
+
value = form.find("input[name=i_"+name+"]").val();
|
119 |
+
value = value == null ? '' : value;
|
120 |
+
}
|
121 |
|
122 |
+
return value;
|
123 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
function set_property_field_value(form, type, name, value, multiple){
|
126 |
+
switch(type) {
|
127 |
+
case 'select':
|
128 |
+
if(multiple == 1){
|
129 |
+
value = typeof(value) === 'string' ? value.split(",") : value;
|
130 |
+
name = name+"[]";
|
131 |
+
form.find('select[name="i_'+name+'"]').val(value).trigger("change");
|
132 |
+
}else{
|
133 |
+
form.find('select[name="i_'+name+'"]').val(value);
|
134 |
+
}
|
135 |
+
break;
|
136 |
+
|
137 |
+
case 'checkbox':
|
138 |
+
value = value == 1 ? true : false;
|
139 |
+
form.find("input[name=i_"+name+"]").prop('checked', value);
|
140 |
+
break;
|
141 |
+
|
142 |
+
case 'textarea':
|
143 |
+
value = value ? decodeHtml(value) : value;
|
144 |
+
form.find("textarea[name=i_"+name+"]").val(value);
|
145 |
+
break;
|
146 |
+
|
147 |
+
default:
|
148 |
+
value = value ? decodeHtml(value) : value;
|
149 |
+
form.find("input[name=i_"+name+"]").val(value);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
function openNewFieldForm(sname){
|
154 |
+
if(sname == 'billing' || sname == 'shipping' || sname == 'additional'){
|
155 |
+
sname = sname+'_';
|
156 |
}
|
157 |
|
158 |
+
var form = $("#thwcfd_new_field_form");
|
159 |
+
clear_field_form(form);
|
160 |
+
form.find("select[name=i_type]").change();
|
161 |
+
|
162 |
+
set_property_field_value(form, 'text', 'name', sname, 0);
|
163 |
+
set_property_field_value(form, 'text', 'class', 'form-row-wide', 0);
|
164 |
+
|
165 |
+
$("#thwcfd_new_field_form_pp").dialog("open");
|
166 |
}
|
167 |
+
|
168 |
+
function openEditFieldForm(elm, rowId){
|
169 |
+
var row = $(elm).closest('tr');
|
170 |
+
var form = $("#thwcfd_edit_field_form");
|
171 |
+
|
172 |
+
var props_json = row.find(".f_props").val();
|
173 |
+
//props_json = decodeHtml(props_json);
|
174 |
+
console.log(props_json);
|
175 |
+
var props = JSON.parse(props_json);
|
176 |
+
//var type = props.type;
|
177 |
+
|
178 |
+
populate_field_form_general(form, props)
|
179 |
+
form.find("select[name=i_type]").change();
|
180 |
+
populate_field_form(row, form, props);
|
181 |
+
|
182 |
+
$("#thwcfd_edit_field_form_pp").dialog("open");
|
183 |
+
}
|
184 |
+
|
185 |
+
function clear_field_form( form ){
|
186 |
+
form.find('.err_msgs').html('');
|
187 |
+
|
188 |
+
set_property_field_value(form, 'hidden', 'autocomplete', '', 0);
|
189 |
+
set_property_field_value(form, 'hidden', 'priority', '', 0);
|
190 |
+
set_property_field_value(form, 'hidden', 'custom', '', 0);
|
191 |
+
set_property_field_value(form, 'hidden', 'oname', '', 0);
|
192 |
+
set_property_field_value(form, 'hidden', 'otype', '', 0);
|
193 |
+
|
194 |
+
set_property_field_value(form, 'select', 'type', 'text', 0);
|
195 |
+
set_property_field_value(form, 'text', 'name', '', 0);
|
196 |
+
set_property_field_value(form, 'text', 'label', '', 0);
|
197 |
+
set_property_field_value(form, 'text', 'placeholder', '', 0);
|
198 |
+
set_property_field_value(form, 'text', 'default', '', 0);
|
199 |
+
//set_property_field_value(form, 'text', 'options', '', 0);
|
200 |
+
set_property_field_value(form, 'text', 'class', '', 0);
|
201 |
+
set_property_field_value(form, 'select', 'validate', '', 1);
|
202 |
+
|
203 |
+
set_property_field_value(form, 'checkbox', 'required', 1, 0);
|
204 |
+
//set_property_field_value(form, 'checkbox', 'clear', 1, 0);
|
205 |
+
set_property_field_value(form, 'checkbox', 'enabled', 1, 0);
|
206 |
+
set_property_field_value(form, 'checkbox', 'show_in_email', 1, 0);
|
207 |
+
set_property_field_value(form, 'checkbox', 'show_in_order', 1, 0);
|
208 |
+
|
209 |
+
populate_options_list(form, false);
|
210 |
+
}
|
211 |
+
|
212 |
+
function populate_field_form_general(form, props){
|
213 |
+
var autocomplete = props['autocomplete'] ? props['autocomplete'] : '';
|
214 |
+
var priority = props['priority'] ? props['priority'] : '';
|
215 |
+
var custom = props['custom'] ? props['custom'] : '';
|
216 |
+
|
217 |
+
var type = props['type'] ? props['type'] : 'text';
|
218 |
+
var name = props['name'] ? props['name'] : '';
|
219 |
+
|
220 |
+
set_property_field_value(form, 'hidden', 'autocomplete', autocomplete, 0);
|
221 |
+
set_property_field_value(form, 'hidden', 'priority', priority, 0);
|
222 |
+
set_property_field_value(form, 'hidden', 'custom', custom, 0);
|
223 |
+
set_property_field_value(form, 'hidden', 'oname', name, 0);
|
224 |
+
set_property_field_value(form, 'hidden', 'otype', type, 0);
|
225 |
+
|
226 |
+
set_property_field_value(form, 'select', 'type', type, 0);
|
227 |
+
set_property_field_value(form, 'text', 'name', name, 0);
|
228 |
+
}
|
229 |
+
|
230 |
+
function populate_field_form(row, form, props, custom){
|
231 |
+
var custom = props['custom'] ? props['custom'] : '';
|
232 |
+
|
233 |
+
var label = props['label'] ? props['label'] : '';
|
234 |
+
var placeholder = props['placeholder'] ? props['placeholder'] : '';
|
235 |
+
var default_val = props['default'] ? props['default'] : '';
|
236 |
+
//var options = props['options'] ? props['options'] : '';
|
237 |
+
var cssclass = props['class'] ? props['class'] : '';
|
238 |
+
var validate = props['validate'] ? props['validate'] : '';
|
239 |
+
|
240 |
+
var required = props['required'] && (props['required'] || props['required'] === 'yes') ? 1 : 0;
|
241 |
+
//var clear = props['clear'] && (props['clear'] || props['clear'] === 'yes') ? 1 : 0;
|
242 |
+
var enabled = props['enabled'] && (props['enabled'] || props['enabled'] === 'yes') ? 1 : 0;
|
243 |
+
var show_in_email = props['show_in_email'] && (props['show_in_email'] || props['show_in_email'] === 'yes') ? 1 : 0;
|
244 |
+
var show_in_order = props['show_in_order'] && (props['show_in_order'] || props['show_in_order'] === 'yes') ? 1 : 0;
|
245 |
+
|
246 |
+
show_in_email = custom == 1 ? show_in_email : true;
|
247 |
+
show_in_order = custom == 1 ? show_in_order : true;
|
248 |
+
|
249 |
+
set_property_field_value(form, 'text', 'label', label, 0);
|
250 |
+
set_property_field_value(form, 'text', 'placeholder', placeholder, 0);
|
251 |
+
set_property_field_value(form, 'text', 'default', default_val, 0);
|
252 |
+
//set_property_field_value(form, 'text', 'options', options, 0);
|
253 |
+
set_property_field_value(form, 'text', 'class', cssclass, 0);
|
254 |
+
set_property_field_value(form, 'select', 'validate', validate, 1);
|
255 |
+
|
256 |
+
set_property_field_value(form, 'checkbox', 'required', required, 0);
|
257 |
+
//set_property_field_value(form, 'checkbox', 'clear', clear, 0);
|
258 |
+
set_property_field_value(form, 'checkbox', 'enabled', enabled, 0);
|
259 |
+
set_property_field_value(form, 'checkbox', 'show_in_email', show_in_email, 0);
|
260 |
+
set_property_field_value(form, 'checkbox', 'show_in_order', show_in_order, 0);
|
261 |
+
|
262 |
+
var optionsJson = row.find(".f_options").val();
|
263 |
+
populate_options_list(form, optionsJson);
|
264 |
+
|
265 |
+
if(custom == 1){
|
266 |
+
form.find("input[name=i_name]").prop('disabled', false);
|
267 |
+
form.find("select[name=i_type]").prop('disabled', false);
|
268 |
+
form.find("input[name=i_show_in_email]").prop('disabled', false);
|
269 |
+
form.find("input[name=i_show_in_order]").prop('disabled', false);
|
270 |
+
}else{
|
271 |
+
form.find("input[name=i_name]").prop('disabled', true);
|
272 |
+
form.find("select[name=i_type]").prop('disabled', true);
|
273 |
+
form.find("input[name=i_show_in_email]").prop('disabled', true);
|
274 |
+
form.find("input[name=i_show_in_order]").prop('disabled', true);
|
275 |
+
form.find("input[name=i_label]").focus();
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
function prepare_field_form(form){
|
280 |
+
var options_json = get_options(form);
|
281 |
+
set_property_field_value(form, 'hidden', 'options_json', options_json, 0);
|
282 |
+
}
|
283 |
+
|
284 |
+
function validate_field_form(form){
|
285 |
var err_msgs = '';
|
286 |
+
var name = get_property_field_value(form, 'text', 'name');
|
287 |
+
var type = get_property_field_value(form, 'select', 'type');
|
288 |
+
var otype = get_property_field_value(form, 'select', 'otype');
|
289 |
+
|
290 |
+
if(type == '' && otype != 'country' && otype == 'state'){
|
291 |
+
err_msgs = 'Type is required';
|
292 |
+
}else if(name == ''){
|
293 |
err_msgs = 'Name is required';
|
294 |
}else if(!isHtmlIdValid(name)){
|
295 |
err_msgs = MSG_INVALID_NAME;
|
296 |
+
}
|
|
|
|
|
297 |
|
298 |
if(err_msgs != ''){
|
299 |
+
form.find('.err_msgs').html(err_msgs);
|
300 |
return false;
|
301 |
}
|
302 |
+
return true;
|
303 |
+
}
|
304 |
+
|
305 |
+
function fieldTypeChangeListner(elm){
|
306 |
+
var type = $(elm).val();
|
307 |
+
var form = $(elm).closest('form');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
+
showAllFields(form);
|
310 |
+
|
311 |
+
if(type === 'select'){
|
312 |
+
form.find('.row-validate').hide();
|
313 |
+
|
314 |
+
}else if(type === 'radio'){
|
315 |
+
form.find('.row-validate').hide();
|
316 |
+
form.find('.row-placeholder').hide();
|
317 |
+
|
318 |
+
}else{
|
319 |
+
form.find('.row-options').hide();
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
function showAllFields(form){
|
324 |
+
form.find('.row-options').show();
|
325 |
+
form.find('.row-placeholder').show();
|
326 |
+
form.find('.row-validate').show();
|
327 |
+
}
|
328 |
+
|
329 |
+
/*------------------------------------
|
330 |
+
*---- OPTIONS FUNCTIONS - SATRT ------
|
331 |
+
*------------------------------------*/
|
332 |
+
function get_options(form){
|
333 |
+
var optionsKey = form.find("input[name='i_options_key[]']").map(function(){ return $(this).val(); }).get();
|
334 |
+
var optionsText = form.find("input[name='i_options_text[]']").map(function(){ return $(this).val(); }).get();
|
335 |
+
|
336 |
+
var optionsSize = optionsText.length;
|
337 |
+
var optionsArr = [];
|
338 |
+
|
339 |
+
for(var i=0; i<optionsSize; i++){
|
340 |
+
var optionDetails = {};
|
341 |
+
optionDetails["key"] = optionsKey[i];
|
342 |
+
optionDetails["text"] = optionsText[i];
|
343 |
+
|
344 |
+
optionsArr.push(optionDetails);
|
345 |
+
}
|
346 |
|
347 |
+
var optionsJson = optionsArr.length > 0 ? JSON.stringify(optionsArr) : '';
|
348 |
+
optionsJson = encodeURIComponent(optionsJson);
|
349 |
+
return optionsJson;
|
350 |
+
}
|
351 |
+
|
352 |
+
function populate_options_list(form, optionsJson){
|
353 |
+
var optionsHtml = "";
|
354 |
+
|
355 |
+
if(optionsJson){
|
356 |
+
try{
|
357 |
+
optionsJson = decodeURIComponent(optionsJson);
|
358 |
+
console.log(optionsJson);
|
359 |
+
var optionsList = $.parseJSON(optionsJson);
|
360 |
+
if(optionsList){
|
361 |
+
jQuery.each(optionsList, function() {
|
362 |
+
var html = '<tr>';
|
363 |
+
html += '<td style="width:150px;"><input type="text" name="i_options_key[]" value="'+this.key+'" placeholder="Option Value" style="width:140px;"/></td>';
|
364 |
+
html += '<td style="width:190px;"><input type="text" name="i_options_text[]" value="'+this.text+'" placeholder="Option Text" style="width:180px;"/></td>';
|
365 |
+
html += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>';
|
366 |
+
html += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>';
|
367 |
+
html += '<td class="action-cell sort ui-sortable-handle"></td>';
|
368 |
+
html += '</tr>';
|
369 |
+
|
370 |
+
optionsHtml += html;
|
371 |
+
});
|
372 |
+
}
|
373 |
+
}catch(err) {
|
374 |
+
console.log(err);
|
375 |
+
alert(err);
|
376 |
+
}
|
377 |
}
|
378 |
+
|
379 |
+
var optionsTable = form.find(".thwcfd-option-list tbody");
|
380 |
+
if(optionsHtml){
|
381 |
+
optionsTable.html(optionsHtml);
|
382 |
}else{
|
383 |
+
optionsTable.html(OPTION_ROW_HTML);
|
384 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
+
|
387 |
+
function add_new_option_row(elm){
|
388 |
+
var ptable = $(elm).closest('table');
|
389 |
+
var optionsSize = ptable.find('tbody tr').size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
+
if(optionsSize > 0){
|
392 |
+
ptable.find('tbody tr:last').after(OPTION_ROW_HTML);
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
}else{
|
394 |
+
ptable.find('tbody').append(OPTION_ROW_HTML);
|
|
|
|
|
|
|
395 |
}
|
396 |
}
|
397 |
|
398 |
+
function remove_option_row(elm){
|
399 |
+
var ptable = $(elm).closest('table');
|
400 |
+
$(elm).closest('tr').remove();
|
401 |
+
var optionsSize = ptable.find('tbody tr').size();
|
402 |
+
|
403 |
+
if(optionsSize == 0){
|
404 |
+
ptable.find('tbody').append(OPTION_ROW_HTML);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
}
|
407 |
+
/*------------------------------------
|
408 |
+
*---- OPTIONS FUNCTIONS - END --------
|
409 |
+
*------------------------------------*/
|
410 |
+
|
411 |
+
function prepare_field_order_indexes() {
|
412 |
+
$('#thwcfd_checkout_fields tbody tr').each(function(index, el){
|
413 |
+
$('input.f_order', el).val( parseInt( $(el).index('#thwcfd_checkout_fields tbody tr') ) );
|
414 |
+
});
|
415 |
+
};
|
416 |
|
417 |
+
function selectAllCheckoutFields(elm){
|
418 |
+
var checkAll = $(elm).prop('checked');
|
419 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
420 |
+
}
|
421 |
+
|
422 |
+
function removeSelectedFields(){
|
423 |
+
$('#thwcfd_checkout_fields tbody tr').removeClass('thpladmin-strikeout');
|
424 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
425 |
var row = $(this).closest('tr');
|
426 |
+
|
427 |
+
if(!row.hasClass("thpladmin-strikeout")){
|
428 |
+
row.addClass("thpladmin-strikeout");
|
429 |
}
|
430 |
+
|
431 |
row.find(".f_deleted").val(1);
|
432 |
row.find(".f_edit_btn").prop('disabled', true);
|
|
|
433 |
});
|
434 |
}
|
435 |
+
|
436 |
+
function enableDisableSelectedFields(enabled){
|
437 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
438 |
var row = $(this).closest('tr');
|
439 |
+
row.find(".f_enabled").val(enabled);
|
440 |
+
|
441 |
if(enabled == 0){
|
442 |
+
if(!row.hasClass("thpladmin-disabled")){
|
443 |
+
row.addClass("thpladmin-disabled");
|
444 |
}
|
445 |
+
|
446 |
+
row.find(".f_edit_btn").prop('disabled', true);
|
447 |
+
row.find(".td_enabled").html('-');
|
448 |
}else{
|
449 |
+
row.removeClass("thpladmin-disabled");
|
450 |
+
|
451 |
+
row.find(".f_edit_btn").prop('disabled', false);
|
452 |
+
row.find(".td_enabled").html('<span class="dashicons dashicons-yes"></span>');
|
453 |
}
|
|
|
|
|
|
|
|
|
454 |
});
|
455 |
}
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
return {
|
458 |
+
openNewFieldForm : openNewFieldForm,
|
459 |
+
openEditFieldForm : openEditFieldForm,
|
460 |
+
selectAllCheckoutFields : selectAllCheckoutFields,
|
461 |
+
removeSelectedFields : removeSelectedFields,
|
462 |
+
enableDisableSelectedFields : enableDisableSelectedFields,
|
463 |
+
fieldTypeChangeListner : fieldTypeChangeListner,
|
464 |
+
addNewOptionRow : add_new_option_row,
|
465 |
+
removeOptionRow : remove_option_row,
|
466 |
};
|
467 |
}(window.jQuery, window, document));
|
468 |
|
469 |
+
function thwcfdOpenNewFieldForm(tabName){
|
470 |
+
thwcfd_settings.openNewFieldForm(tabName);
|
471 |
}
|
472 |
|
473 |
+
function thwcfdOpenEditFieldForm(elm, rowId){
|
474 |
+
thwcfd_settings.openEditFieldForm(elm, rowId);
|
475 |
}
|
476 |
|
477 |
+
function thwcfdRemoveSelectedFields(){
|
478 |
+
thwcfd_settings.removeSelectedFields();
|
479 |
}
|
480 |
|
481 |
+
function thwcfdEnableSelectedFields(){
|
482 |
+
thwcfd_settings.enableDisableSelectedFields(1);
|
483 |
}
|
484 |
|
485 |
+
function thwcfdDisableSelectedFields(){
|
486 |
+
thwcfd_settings.enableDisableSelectedFields(0);
|
487 |
}
|
488 |
|
489 |
+
function thwcfdFieldTypeChangeListner(elm){
|
490 |
+
thwcfd_settings.fieldTypeChangeListner(elm);
|
491 |
}
|
492 |
|
493 |
function thwcfdSelectAllCheckoutFields(elm){
|
494 |
+
thwcfd_settings.selectAllCheckoutFields(elm);
|
495 |
+
}
|
496 |
+
|
497 |
+
function thwcfdAddNewOptionRow(elm){
|
498 |
+
thwcfd_settings.addNewOptionRow(elm);
|
499 |
+
}
|
500 |
+
function thwcfdRemoveOptionRow(elm){
|
501 |
+
thwcfd_settings.removeOptionRow(elm);
|
502 |
+
}
|
assets/js/{thwcfd-checkout-field-editor-frontend.js → thwcfd-checkout.js}
RENAMED
File without changes
|
checkout-form-designer.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Checkout Field Editor for WooCommerce
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHiGH
|
6 |
-
* Version: 1.3.
|
7 |
* Author URI: https://www.themehigh.com
|
8 |
* Plugin URI: https://www.themehigh.com
|
9 |
* Text Domain: woo-checkout-field-editor-pro
|
@@ -20,482 +20,21 @@ if (!function_exists('is_woocommerce_active')){
|
|
20 |
if(is_multisite()){
|
21 |
$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
|
22 |
}
|
23 |
-
return in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
|
24 |
}
|
25 |
}
|
26 |
|
27 |
if(is_woocommerce_active()) {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* woocommerce_init_checkout_field_editor function.
|
37 |
-
*/
|
38 |
-
function thwcfd_init_checkout_field_editor_lite() {
|
39 |
-
global $supress_field_modification;
|
40 |
-
$supress_field_modification = false;
|
41 |
-
|
42 |
-
define('TH_WCFD_VERSION', '1.3.5');
|
43 |
-
!defined('TH_WCFD_BASE_NAME') && define('TH_WCFD_BASE_NAME', plugin_basename( __FILE__ ));
|
44 |
-
!defined('TH_WCFD_URL') && define('TH_WCFD_URL', plugins_url( '/', __FILE__ ));
|
45 |
-
!defined('TH_WCFD_ASSETS_URL') && define('TH_WCFD_ASSETS_URL', TH_WCFD_URL . 'assets/');
|
46 |
-
|
47 |
-
thwcfd_load_plugin_textdomain();
|
48 |
-
|
49 |
-
if(!class_exists('WC_Checkout_Field_Editor')){
|
50 |
-
require_once('classes/class-wc-checkout-field-editor.php');
|
51 |
-
}
|
52 |
-
|
53 |
-
$GLOBALS['WC_Checkout_Field_Editor'] = new WC_Checkout_Field_Editor();
|
54 |
-
}
|
55 |
-
add_action('init', 'thwcfd_init_checkout_field_editor_lite');
|
56 |
-
|
57 |
-
function thwcfd_is_locale_field( $field_name ){
|
58 |
-
if(!empty($field_name) && in_array($field_name, array(
|
59 |
-
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
60 |
-
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
61 |
-
))){
|
62 |
-
return true;
|
63 |
-
}
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
|
67 |
-
function thwcfd_woocommerce_version_check( $version = '3.0' ) {
|
68 |
-
if(function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
|
69 |
-
global $woocommerce;
|
70 |
-
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
function thwcfd_enqueue_scripts(){
|
78 |
-
global $wp_scripts;
|
79 |
-
|
80 |
-
if(is_checkout()){
|
81 |
-
$in_footer = apply_filters( 'thwcfd_enqueue_script_in_footer', true );
|
82 |
-
|
83 |
-
wp_register_script('thwcfd-field-editor-script', TH_WCFD_ASSETS_URL.'js/thwcfd-checkout-field-editor-frontend.js',
|
84 |
-
array('jquery', 'select2'), TH_WCFD_VERSION, $in_footer);
|
85 |
-
|
86 |
-
wp_enqueue_script('thwcfd-field-editor-script');
|
87 |
-
}
|
88 |
-
}
|
89 |
-
add_action('wp_enqueue_scripts', 'thwcfd_enqueue_scripts');
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Hide Additional Fields title if no fields available.
|
93 |
-
*
|
94 |
-
* @param mixed $old
|
95 |
-
*/
|
96 |
-
function thwcfd_enable_order_notes_field() {
|
97 |
-
global $supress_field_modification;
|
98 |
-
|
99 |
-
if($supress_field_modification){
|
100 |
-
return $fields;
|
101 |
-
}
|
102 |
-
|
103 |
-
$additional_fields = get_option('wc_fields_additional');
|
104 |
-
if(is_array($additional_fields)){
|
105 |
-
$enabled = 0;
|
106 |
-
foreach($additional_fields as $field){
|
107 |
-
if($field['enabled']){
|
108 |
-
$enabled++;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
return $enabled > 0 ? true : false;
|
112 |
-
}
|
113 |
-
return true;
|
114 |
-
}
|
115 |
-
add_filter('woocommerce_enable_order_notes_field', 'thwcfd_enable_order_notes_field', 1000);
|
116 |
-
|
117 |
-
function thwcfd_woo_default_address_fields( $fields ) {
|
118 |
-
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
119 |
-
|
120 |
-
if($sname === 'billing' || $sname === 'shipping'){
|
121 |
-
$address_fields = get_option('wc_fields_'.$sname);
|
122 |
-
|
123 |
-
if(is_array($address_fields) && !empty($address_fields) && !empty($fields)){
|
124 |
-
$override_required = apply_filters( 'thwcfd_address_field_override_required', true );
|
125 |
-
|
126 |
-
foreach($fields as $name => $field) {
|
127 |
-
$fname = $sname.'_'.$name;
|
128 |
-
|
129 |
-
if(thwcfd_is_locale_field($fname) && $override_required){
|
130 |
-
$custom_field = isset($address_fields[$fname]) ? $address_fields[$fname] : false;
|
131 |
-
|
132 |
-
if($custom_field && !( isset($custom_field['enabled']) && $custom_field['enabled'] == false )){
|
133 |
-
$fields[$name]['required'] = isset($custom_field['required']) && $custom_field['required'] ? true : false;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
return $fields;
|
141 |
-
}
|
142 |
-
add_filter('woocommerce_default_address_fields' , 'thwcfd_woo_default_address_fields', apply_filters('thwcfd_default_address_fields_priority', 1000) );
|
143 |
-
|
144 |
-
function thwcfd_prepare_country_locale($fields) {
|
145 |
-
if(is_array($fields)){
|
146 |
-
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
147 |
-
$address_fields = get_option('wc_fields_'.$sname);
|
148 |
-
|
149 |
-
foreach($fields as $key => $props){
|
150 |
-
$override_ph = apply_filters('thwcfd_address_field_override_placeholder', true);
|
151 |
-
$override_label = apply_filters('thwcfd_address_field_override_label', true);
|
152 |
-
$override_required = apply_filters('thwcfd_address_field_override_required', false);
|
153 |
-
$override_priority = apply_filters('thwcfd_address_field_override_priority', true);
|
154 |
-
|
155 |
-
if($override_ph && isset($props['placeholder'])){
|
156 |
-
unset($fields[$key]['placeholder']);
|
157 |
-
}
|
158 |
-
if($override_label && isset($props['label'])){
|
159 |
-
unset($fields[$key]['label']);
|
160 |
-
}
|
161 |
-
if($override_required && isset($props['required'])){
|
162 |
-
$fkey = $sname.'_'.$key;
|
163 |
-
if(is_array($address_fields) && isset($address_fields[$fkey])){
|
164 |
-
$cf_props = $address_fields[$fkey];
|
165 |
-
if(is_array($cf_props) && isset($cf_props['required'])){
|
166 |
-
$fields[$key]['required'] = $cf_props['required'] ? true : false;
|
167 |
-
}
|
168 |
-
}
|
169 |
-
//unset($fields[$key]['required']);
|
170 |
-
}
|
171 |
-
|
172 |
-
if($override_priority && isset($props['priority'])){
|
173 |
-
unset($fields[$key]['priority']);
|
174 |
-
//unset($fields[$key]['order']);
|
175 |
-
}
|
176 |
-
}
|
177 |
-
}
|
178 |
-
return $fields;
|
179 |
-
}
|
180 |
-
add_filter('woocommerce_get_country_locale_default', 'thwcfd_prepare_country_locale');
|
181 |
-
add_filter('woocommerce_get_country_locale_base', 'thwcfd_prepare_country_locale');
|
182 |
-
|
183 |
-
function thwcfd_woo_get_country_locale($locale) {
|
184 |
-
if(is_array($locale)){
|
185 |
-
foreach($locale as $country => $fields){
|
186 |
-
$locale[$country] = thwcfd_prepare_country_locale($fields);
|
187 |
-
}
|
188 |
-
}
|
189 |
-
return $locale;
|
190 |
-
}
|
191 |
-
add_filter('woocommerce_get_country_locale', 'thwcfd_woo_get_country_locale');
|
192 |
-
|
193 |
-
/**
|
194 |
-
* wc_checkout_fields_modify_billing_fields function.
|
195 |
-
*
|
196 |
-
* @param mixed $fields
|
197 |
-
*/
|
198 |
-
function thwcfd_billing_fields_lite($fields, $country){
|
199 |
-
global $supress_field_modification;
|
200 |
-
|
201 |
-
if($supress_field_modification){
|
202 |
-
return $fields;
|
203 |
-
}
|
204 |
-
if(is_wc_endpoint_url('edit-address')){
|
205 |
-
return $fields;
|
206 |
-
}else{
|
207 |
-
return thwcfd_prepare_address_fields(get_option('wc_fields_billing'), $fields, 'billing', $country);
|
208 |
-
}
|
209 |
-
}
|
210 |
-
add_filter('woocommerce_billing_fields', 'thwcfd_billing_fields_lite', apply_filters('thwcfd_billing_fields_priority', 1000), 2);
|
211 |
|
212 |
-
|
213 |
-
* wc_checkout_fields_modify_shipping_fields function.
|
214 |
-
*
|
215 |
-
* @param mixed $old
|
216 |
-
*/
|
217 |
-
function thwcfd_shipping_fields_lite($fields, $country){
|
218 |
-
global $supress_field_modification;
|
219 |
-
|
220 |
-
if ($supress_field_modification){
|
221 |
-
return $fields;
|
222 |
-
}
|
223 |
-
if(is_wc_endpoint_url('edit-address')){
|
224 |
-
return $fields;
|
225 |
-
}else{
|
226 |
-
return thwcfd_prepare_address_fields(get_option('wc_fields_shipping'), $fields, 'shipping', $country);
|
227 |
-
}
|
228 |
-
}
|
229 |
-
add_filter('woocommerce_shipping_fields', 'thwcfd_shipping_fields_lite', apply_filters('thwcfd_shipping_fields_priority', 1000), 2);
|
230 |
-
|
231 |
-
/**
|
232 |
-
* wc_checkout_fields_modify_shipping_fields function.
|
233 |
-
*
|
234 |
-
* @param mixed $old
|
235 |
-
*/
|
236 |
-
function thwcfd_checkout_fields_lite( $fields ) {
|
237 |
-
global $supress_field_modification;
|
238 |
-
|
239 |
-
if($supress_field_modification){
|
240 |
-
return $fields;
|
241 |
-
}
|
242 |
-
|
243 |
-
if($additional_fields = get_option('wc_fields_additional')){
|
244 |
-
if( isset($fields['order']) && is_array($fields['order']) ){
|
245 |
-
$fields['order'] = $additional_fields + $fields['order'];
|
246 |
-
}
|
247 |
-
|
248 |
-
// check if order_comments is enabled/disabled
|
249 |
-
if(is_array($additional_fields) && !$additional_fields['order_comments']['enabled']){
|
250 |
-
unset($fields['order']['order_comments']);
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
if(isset($fields['order']) && is_array($fields['order'])){
|
255 |
-
$fields['order'] = thwcfd_prepare_checkout_fields_lite($fields['order'], false);
|
256 |
-
}
|
257 |
-
|
258 |
-
if(isset($fields['order']) && !is_array($fields['order'])){
|
259 |
-
unset($fields['order']);
|
260 |
-
}
|
261 |
-
|
262 |
-
return $fields;
|
263 |
-
}
|
264 |
-
add_filter('woocommerce_checkout_fields', 'thwcfd_checkout_fields_lite', apply_filters('thwcfd_checkout_fields_priority', 1000));
|
265 |
-
|
266 |
-
/**
|
267 |
-
*
|
268 |
-
*/
|
269 |
-
function thwcfd_prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
|
270 |
-
if(is_array($fieldset) && !empty($fieldset)) {
|
271 |
-
$locale = WC()->countries->get_country_locale();
|
272 |
-
if(isset($locale[ $country ]) && is_array($locale[ $country ])) {
|
273 |
-
foreach($locale[ $country ] as $key => $value){
|
274 |
-
if(is_array($value) && isset($fieldset[$sname.'_'.$key])){
|
275 |
-
if(isset($value['required'])){
|
276 |
-
$fieldset[$sname.'_'.$key]['required'] = $value['required'];
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
$fieldset = thwcfd_prepare_checkout_fields_lite($fieldset, $original_fieldset);
|
282 |
-
return $fieldset;
|
283 |
-
}else {
|
284 |
-
return $original_fieldset;
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* checkout_fields_modify_fields function.
|
290 |
-
*
|
291 |
-
* @param mixed $data
|
292 |
-
* @param mixed $old
|
293 |
-
*/
|
294 |
-
function thwcfd_prepare_checkout_fields_lite($fields, $original_fields) {
|
295 |
-
if(is_array($fields) && !empty($fields)) {
|
296 |
-
foreach($fields as $name => $field) {
|
297 |
-
if(isset($field['enabled']) && $field['enabled'] == false ) {
|
298 |
-
unset($fields[$name]);
|
299 |
-
}else{
|
300 |
-
$new_field = false;
|
301 |
-
$allow_override = apply_filters('thwcfd_allow_default_field_override_'.$name, false);
|
302 |
-
|
303 |
-
if($original_fields && isset($original_fields[$name]) && !$allow_override){
|
304 |
-
$new_field = $original_fields[$name];
|
305 |
-
|
306 |
-
$new_field['label'] = isset($field['label']) ? $field['label'] : '';
|
307 |
-
$new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
|
308 |
-
|
309 |
-
$new_field['class'] = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
|
310 |
-
$new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
|
311 |
-
$new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
|
312 |
-
|
313 |
-
/*if(!thwcfd_is_locale_field($name)){
|
314 |
-
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
315 |
-
}*/
|
316 |
-
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
317 |
-
$new_field['clear'] = isset($field['clear']) ? $field['clear'] : 0;
|
318 |
-
}else{
|
319 |
-
$new_field = $field;
|
320 |
-
}
|
321 |
-
|
322 |
-
if(isset($new_field['type']) && $new_field['type'] === 'select'){
|
323 |
-
if(apply_filters('thwcfd_enable_select2_for_select_fields', true)){
|
324 |
-
$new_field['input_class'][] = 'thwcfd-enhanced-select';
|
325 |
-
}
|
326 |
-
|
327 |
-
if(isset($new_field['options']) && is_array($new_field['options'])){
|
328 |
-
$options = array();
|
329 |
-
foreach($new_field['options'] as $key => $value) {
|
330 |
-
$options[$key] = __($value, 'woo-checkout-field-editor-pro');
|
331 |
-
}
|
332 |
-
$new_field['options'] = $options;
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
$new_field['order'] = isset($field['order']) && is_numeric($field['order']) ? $field['order'] : 0;
|
337 |
-
if(isset($new_field['order']) && is_numeric($new_field['order'])){
|
338 |
-
$priority = ($new_field['order']+1)*10;
|
339 |
-
$new_field['priority'] = $priority;
|
340 |
-
//$new_field['priority'] = $new_field['order'];
|
341 |
-
}
|
342 |
-
|
343 |
-
if(isset($new_field['label'])){
|
344 |
-
$new_field['label'] = thwcfd__t($new_field['label']); //__($new_field['label'], 'woocommerce');
|
345 |
-
}
|
346 |
-
if(isset($new_field['placeholder'])){
|
347 |
-
$new_field['placeholder'] = thwcfd__t($new_field['placeholder']); //__($new_field['placeholder'], 'woocommerce');
|
348 |
-
}
|
349 |
-
|
350 |
-
$fields[$name] = $new_field;
|
351 |
-
}
|
352 |
-
}
|
353 |
-
return $fields;
|
354 |
-
}else {
|
355 |
-
return $original_fields;
|
356 |
-
}
|
357 |
-
}
|
358 |
-
|
359 |
-
/*****************************************
|
360 |
-
----- Display Field Values - START ------
|
361 |
-
*****************************************/
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Display custom fields in emails
|
365 |
-
*
|
366 |
-
* @param array $keys
|
367 |
-
* @return array
|
368 |
-
*/
|
369 |
-
function thwcfd_display_custom_fields_in_emails_lite($ofields, $sent_to_admin, $order){
|
370 |
-
$custom_fields = array();
|
371 |
-
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
372 |
-
WC_Checkout_Field_Editor::get_fields('additional'));
|
373 |
-
|
374 |
-
// Loop through all custom fields to see if it should be added
|
375 |
-
foreach( $fields as $key => $options ) {
|
376 |
-
if(isset($options['show_in_email']) && $options['show_in_email']){
|
377 |
-
$value = '';
|
378 |
-
if(thwcfd_woo_version_check()){
|
379 |
-
$value = get_post_meta( $order->get_id(), $key, true );
|
380 |
-
}else{
|
381 |
-
$value = get_post_meta( $order->id, $key, true );
|
382 |
-
}
|
383 |
-
|
384 |
-
if(!empty($value)){
|
385 |
-
$label = isset($options['label']) && $options['label'] ? $options['label'] : $key;
|
386 |
-
$label = esc_attr($label);
|
387 |
-
|
388 |
-
$custom_field = array();
|
389 |
-
$custom_field['label'] = thwcfd__t($label);
|
390 |
-
$custom_field['value'] = $value;
|
391 |
-
|
392 |
-
$custom_fields[$key] = $custom_field;
|
393 |
-
}
|
394 |
-
}
|
395 |
-
}
|
396 |
-
|
397 |
-
return array_merge($ofields, $custom_fields);
|
398 |
-
}
|
399 |
-
add_filter('woocommerce_email_order_meta_fields', 'thwcfd_display_custom_fields_in_emails_lite', 10, 3);
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Display custom checkout fields on view order pages
|
403 |
-
*
|
404 |
-
* @param object $order
|
405 |
-
*/
|
406 |
-
function thwcfd_order_details_after_customer_details_lite($order){
|
407 |
-
if(thwcfd_woocommerce_version_check()){
|
408 |
-
$order_id = $order->get_id();
|
409 |
-
}else{
|
410 |
-
$order_id = $order->id;
|
411 |
-
}
|
412 |
-
|
413 |
-
$fields = array();
|
414 |
-
if(!wc_ship_to_billing_address_only() && $order->needs_shipping_address()){
|
415 |
-
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
416 |
-
WC_Checkout_Field_Editor::get_fields('additional'));
|
417 |
-
}else{
|
418 |
-
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('additional'));
|
419 |
-
}
|
420 |
-
|
421 |
-
if(is_array($fields) && !empty($fields)){
|
422 |
-
$fields_html = '';
|
423 |
-
// Loop through all custom fields to see if it should be added
|
424 |
-
foreach($fields as $name => $options){
|
425 |
-
$enabled = (isset($options['enabled']) && $options['enabled'] == false) ? false : true;
|
426 |
-
$is_custom_field = (isset($options['custom']) && $options['custom'] == true) ? true : false;
|
427 |
-
|
428 |
-
if(isset($options['show_in_order']) && $options['show_in_order'] && $enabled && $is_custom_field){
|
429 |
-
$value = get_post_meta($order_id, $name, true);
|
430 |
-
|
431 |
-
if(!empty($value)){
|
432 |
-
$label = isset($options['label']) && !empty($options['label']) ? __( $options['label'], 'woo-checkout-field-editor-pro' ) : $name;
|
433 |
-
|
434 |
-
if(is_account_page()){
|
435 |
-
if(apply_filters( 'thwcfd_view_order_customer_details_table_view', true )){
|
436 |
-
$fields_html .= '<tr><th>'. esc_attr($label) .':</th><td>'. wptexturize($value) .'</td></tr>';
|
437 |
-
}else{
|
438 |
-
$fields_html .= '<br/><dt>'. esc_attr($label) .':</dt><dd>'. wptexturize($value) .'</dd>';
|
439 |
-
}
|
440 |
-
}else{
|
441 |
-
if(apply_filters( 'thwcfd_thankyou_customer_details_table_view', true )){
|
442 |
-
$fields_html .= '<tr><th>'. esc_attr($label) .':</th><td>'. wptexturize($value) .'</td></tr>';
|
443 |
-
}else{
|
444 |
-
$fields_html .= '<br/><dt>'. esc_attr($label) .':</dt><dd>'. wptexturize($value) .'</dd>';
|
445 |
-
}
|
446 |
-
}
|
447 |
-
}
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
if($fields_html){
|
452 |
-
do_action( 'thwcfd_order_details_before_custom_fields_table', $order );
|
453 |
-
?>
|
454 |
-
<table class="woocommerce-table woocommerce-table--custom-fields shop_table custom-fields">
|
455 |
-
<?php
|
456 |
-
echo $fields_html;
|
457 |
-
?>
|
458 |
-
</table>
|
459 |
-
<?php
|
460 |
-
do_action( 'thwcfd_order_details_after_custom_fields_table', $order );
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
add_action('woocommerce_order_details_after_order_table', 'thwcfd_order_details_after_customer_details_lite', 20, 1);
|
465 |
-
|
466 |
-
/*****************************************
|
467 |
-
----- Display Field Values - END --------
|
468 |
-
*****************************************/
|
469 |
-
|
470 |
-
function thwcfd__t($text){
|
471 |
-
if(!empty($text)){
|
472 |
-
$otext = $text;
|
473 |
-
$text = __($text, 'woo-checkout-field-editor-pro');
|
474 |
-
if($text === $otext){
|
475 |
-
$text = __($text, 'woocommerce');
|
476 |
-
}
|
477 |
-
}
|
478 |
-
return $text;
|
479 |
-
}
|
480 |
-
function thwcfd_et($text){
|
481 |
-
if(!empty($text)){
|
482 |
-
$otext = $text;
|
483 |
-
$text = __($text, 'woo-checkout-field-editor-pro');
|
484 |
-
if($text === $otext){
|
485 |
-
$text = __($text, 'woocommerce');
|
486 |
-
}
|
487 |
-
}
|
488 |
-
echo $text;
|
489 |
-
}
|
490 |
|
491 |
-
function
|
492 |
-
|
493 |
-
global $woocommerce;
|
494 |
-
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
495 |
-
return true;
|
496 |
-
}
|
497 |
-
}
|
498 |
-
return false;
|
499 |
}
|
500 |
-
|
501 |
}
|
3 |
* Plugin Name: Checkout Field Editor for WooCommerce
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHiGH
|
6 |
+
* Version: 1.3.6
|
7 |
* Author URI: https://www.themehigh.com
|
8 |
* Plugin URI: https://www.themehigh.com
|
9 |
* Text Domain: woo-checkout-field-editor-pro
|
20 |
if(is_multisite()){
|
21 |
$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
|
22 |
}
|
23 |
+
return in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins) || class_exists('WooCommerce');
|
24 |
}
|
25 |
}
|
26 |
|
27 |
if(is_woocommerce_active()) {
|
28 |
+
define('THWCFD_VERSION', '1.3.6');
|
29 |
+
!defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
|
30 |
+
!defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
|
31 |
+
!defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
|
32 |
+
!defined('THWCFD_ASSETS_URL') && define('THWCFD_ASSETS_URL', THWCFD_URL .'assets/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
require THWCFD_PATH . 'classes/class-thwcfd.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
function run_thwcfd() {
|
37 |
+
$plugin = new THWCFD();
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
+
run_thwcfd();
|
40 |
}
|
classes/class-thwcfd-checkout.php
ADDED
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Woo Checkout Field Editor Public
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.3.6
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
|
14 |
+
if(!class_exists('THWCFD_Checkout')) :
|
15 |
+
|
16 |
+
class THWCFD_Checkout {
|
17 |
+
public function __construct() {
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
public function enqueue_styles_and_scripts() {
|
22 |
+
if(is_checkout()){
|
23 |
+
$in_footer = apply_filters( 'thwcfd_enqueue_script_in_footer', true );
|
24 |
+
$deps = array('jquery', 'select2');
|
25 |
+
|
26 |
+
wp_register_script('thwcfd-checkout-script', THWCFD_ASSETS_URL.'js/thwcfd-checkout.js', $deps, THWCFD_VERSION, $in_footer);
|
27 |
+
wp_enqueue_script('thwcfd-checkout-script');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function define_public_hooks(){
|
32 |
+
$hp_default_address_fields = apply_filters('thwcfd_default_address_fields_priority', 1000);
|
33 |
+
$hp_billing_fields = apply_filters('thwcfd_billing_fields_priority', 1000);
|
34 |
+
$hp_shipping_fields = apply_filters('thwcfd_shipping_fields_priority', 1000);
|
35 |
+
$hp_checkout_fields = apply_filters('thwcfd_checkout_fields_priority', 1000);
|
36 |
+
|
37 |
+
add_filter('woocommerce_enable_order_notes_field', array($this, 'enable_order_notes_field'), 1000);
|
38 |
+
|
39 |
+
add_filter('woocommerce_get_country_locale_default', array($this, 'prepare_country_locale'));
|
40 |
+
add_filter('woocommerce_get_country_locale_base', array($this, 'prepare_country_locale'));
|
41 |
+
add_filter('woocommerce_get_country_locale', array($this, 'get_country_locale'));
|
42 |
+
|
43 |
+
add_filter('woocommerce_billing_fields', array($this, 'billing_fields'), $hp_billing_fields, 2);
|
44 |
+
add_filter('woocommerce_shipping_fields', array($this, 'shipping_fields'), $hp_shipping_fields, 2);
|
45 |
+
add_filter('woocommerce_checkout_fields', array($this, 'checkout_fields'), $hp_checkout_fields);
|
46 |
+
add_filter('woocommerce_default_address_fields' , array($this, 'default_address_fields'), $hp_default_address_fields);
|
47 |
+
|
48 |
+
add_action('woocommerce_after_checkout_validation', array($this, 'checkout_fields_validation'), 10, 2);
|
49 |
+
add_action('woocommerce_checkout_update_order_meta', array($this, 'checkout_update_order_meta'), 10, 2);
|
50 |
+
|
51 |
+
add_filter('woocommerce_email_order_meta_fields', array($this, 'display_custom_fields_in_emails'), 10, 3);
|
52 |
+
add_action('woocommerce_order_details_after_order_table', array($this, 'order_details_after_customer_details'), 20, 1);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Hide Additional Fields title if no fields available.
|
57 |
+
*/
|
58 |
+
public function enable_order_notes_field() {
|
59 |
+
$additional_fields = get_option('wc_fields_additional');
|
60 |
+
if(is_array($additional_fields)){
|
61 |
+
$enabled = 0;
|
62 |
+
foreach($additional_fields as $field){
|
63 |
+
if($field['enabled']){
|
64 |
+
$enabled++;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return $enabled > 0 ? true : false;
|
68 |
+
}
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function prepare_country_locale($fields) {
|
73 |
+
if(is_array($fields)){
|
74 |
+
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
75 |
+
$address_fields = get_option('wc_fields_'.$sname);
|
76 |
+
|
77 |
+
foreach($fields as $key => $props){
|
78 |
+
$override_ph = apply_filters('thwcfd_address_field_override_placeholder', true);
|
79 |
+
$override_label = apply_filters('thwcfd_address_field_override_label', true);
|
80 |
+
$override_required = apply_filters('thwcfd_address_field_override_required', false);
|
81 |
+
$override_priority = apply_filters('thwcfd_address_field_override_priority', true);
|
82 |
+
|
83 |
+
if($override_ph && isset($props['placeholder'])){
|
84 |
+
unset($fields[$key]['placeholder']);
|
85 |
+
}
|
86 |
+
|
87 |
+
if($override_label && isset($props['label'])){
|
88 |
+
unset($fields[$key]['label']);
|
89 |
+
}
|
90 |
+
|
91 |
+
if($override_required && isset($props['required'])){
|
92 |
+
$fkey = $sname.'_'.$key;
|
93 |
+
if(is_array($address_fields) && isset($address_fields[$fkey])){
|
94 |
+
$cf_props = $address_fields[$fkey];
|
95 |
+
if(is_array($cf_props) && isset($cf_props['required'])){
|
96 |
+
$fields[$key]['required'] = $cf_props['required'] ? true : false;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
//unset($fields[$key]['required']);
|
100 |
+
}
|
101 |
+
|
102 |
+
if($override_priority && isset($props['priority'])){
|
103 |
+
unset($fields[$key]['priority']);
|
104 |
+
//unset($fields[$key]['order']);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
return $fields;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function get_country_locale($locale) {
|
112 |
+
if(is_array($locale)){
|
113 |
+
foreach($locale as $country => $fields){
|
114 |
+
$locale[$country] = $this->prepare_country_locale($fields);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
return $locale;
|
118 |
+
}
|
119 |
+
|
120 |
+
public function billing_fields($fields, $country){
|
121 |
+
if(is_wc_endpoint_url('edit-address')){
|
122 |
+
return $fields;
|
123 |
+
}else{
|
124 |
+
return $this->prepare_address_fields(get_option('wc_fields_billing'), $fields, 'billing', $country);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
public function shipping_fields($fields, $country){
|
129 |
+
if(is_wc_endpoint_url('edit-address')){
|
130 |
+
return $fields;
|
131 |
+
}else{
|
132 |
+
return $this->prepare_address_fields(get_option('wc_fields_shipping'), $fields, 'shipping', $country);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
public function checkout_fields($fields) {
|
137 |
+
$additional_fields = get_option('wc_fields_additional');
|
138 |
+
|
139 |
+
if(is_array($additional_fields)){
|
140 |
+
if(isset($fields['order']) && is_array($fields['order'])){
|
141 |
+
$fields['order'] = $additional_fields + $fields['order'];
|
142 |
+
}
|
143 |
+
|
144 |
+
// check if order_comments is enabled/disabled
|
145 |
+
if(isset($additional_fields['order_comments']['enabled']) && !$additional_fields['order_comments']['enabled']){
|
146 |
+
unset($fields['order']['order_comments']);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
if(isset($fields['order']) && is_array($fields['order'])){
|
151 |
+
$fields['order'] = $this->prepare_checkout_fields($fields['order'], false);
|
152 |
+
}
|
153 |
+
|
154 |
+
if(isset($fields['order']) && !is_array($fields['order'])){
|
155 |
+
unset($fields['order']);
|
156 |
+
}
|
157 |
+
|
158 |
+
return $fields;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function default_address_fields($fields) {
|
162 |
+
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
163 |
+
|
164 |
+
if($sname === 'billing' || $sname === 'shipping'){
|
165 |
+
$address_fields = get_option('wc_fields_'.$sname);
|
166 |
+
|
167 |
+
if(is_array($address_fields) && !empty($address_fields) && !empty($fields)){
|
168 |
+
$override_required = apply_filters( 'thwcfd_address_field_override_required', true );
|
169 |
+
|
170 |
+
foreach($fields as $name => $field) {
|
171 |
+
$fname = $sname.'_'.$name;
|
172 |
+
|
173 |
+
if(THWCFD_Utils::is_address_field($fname) && $override_required){
|
174 |
+
$custom_field = isset($address_fields[$fname]) ? $address_fields[$fname] : false;
|
175 |
+
|
176 |
+
if(THWCFD_Utils::is_enabled($custom_field)){
|
177 |
+
$fields[$name]['required'] = isset($custom_field['required']) && $custom_field['required'] ? true : false;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
return $fields;
|
185 |
+
}
|
186 |
+
|
187 |
+
public function prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
|
188 |
+
if(is_array($fieldset) && !empty($fieldset)) {
|
189 |
+
$locale = WC()->countries->get_country_locale();
|
190 |
+
|
191 |
+
if(isset($locale[ $country ]) && is_array($locale[ $country ])) {
|
192 |
+
foreach($locale[ $country ] as $key => $value){
|
193 |
+
$fname = $sname.'_'.$key;
|
194 |
+
|
195 |
+
if(is_array($value) && isset($fieldset[$fname])){
|
196 |
+
if(isset($value['required'])){
|
197 |
+
$fieldset[$fname]['required'] = $value['required'];
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
$fieldset = $this->prepare_checkout_fields($fieldset, $original_fieldset);
|
204 |
+
return $fieldset;
|
205 |
+
}else {
|
206 |
+
return $original_fieldset;
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
public function prepare_checkout_fields($fields, $original_fields) {
|
211 |
+
if(is_array($fields) && !empty($fields)) {
|
212 |
+
foreach($fields as $name => $field) {
|
213 |
+
if(THWCFD_Utils::is_enabled($field)) {
|
214 |
+
$new_field = false;
|
215 |
+
$allow_override = apply_filters('thwcfd_allow_default_field_override_'.$name, false);
|
216 |
+
|
217 |
+
if($original_fields && isset($original_fields[$name]) && !$allow_override){
|
218 |
+
$new_field = $original_fields[$name];
|
219 |
+
|
220 |
+
$new_field['label'] = isset($field['label']) ? $field['label'] : '';
|
221 |
+
$new_field['default'] = isset($field['default']) ? $field['default'] : '';
|
222 |
+
$new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
|
223 |
+
$new_field['class'] = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
|
224 |
+
$new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
|
225 |
+
$new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
|
226 |
+
|
227 |
+
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
228 |
+
$new_field['priority'] = isset($field['priority']) ? $field['priority'] : '';
|
229 |
+
|
230 |
+
} else {
|
231 |
+
$new_field = $field;
|
232 |
+
}
|
233 |
+
|
234 |
+
$type = isset($new_field['type']) ? $new_field['type'] : 'text';
|
235 |
+
|
236 |
+
if($type === 'select' || $type === 'radio'){
|
237 |
+
if(isset($new_field['options'])){
|
238 |
+
$options_arr = THWCFD_Utils::prepare_field_options($new_field['options']);
|
239 |
+
$options = array();
|
240 |
+
foreach($options_arr as $key => $value) {
|
241 |
+
$options[$key] = __($value, 'woo-checkout-field-editor-pro');
|
242 |
+
}
|
243 |
+
$new_field['options'] = $options;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
if($type === 'select' && apply_filters('thwcfd_enable_select2_for_select_fields', true)){
|
248 |
+
$new_field['input_class'][] = 'thwcfd-enhanced-select';
|
249 |
+
}
|
250 |
+
|
251 |
+
if(isset($new_field['label'])){
|
252 |
+
$new_field['label'] = THWCFD_Utils::t($new_field['label']);
|
253 |
+
}
|
254 |
+
|
255 |
+
if(isset($new_field['placeholder'])){
|
256 |
+
$new_field['placeholder'] = THWCFD_Utils::t($new_field['placeholder']);
|
257 |
+
}
|
258 |
+
|
259 |
+
$fields[$name] = $new_field;
|
260 |
+
}else{
|
261 |
+
unset($fields[$name]);
|
262 |
+
}
|
263 |
+
}
|
264 |
+
return $fields;
|
265 |
+
}else {
|
266 |
+
return $original_fields;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
/*************************************
|
271 |
+
----- Validate & Update - START ------
|
272 |
+
*************************************/
|
273 |
+
public function checkout_fields_validation($posted, $errors){
|
274 |
+
$checkout_fields = WC()->checkout->checkout_fields;
|
275 |
+
|
276 |
+
foreach($checkout_fields as $fieldset_key => $fieldset){
|
277 |
+
if($this->maybe_skip_fieldset($fieldset_key, $posted)){
|
278 |
+
continue;
|
279 |
+
}
|
280 |
+
|
281 |
+
foreach($fieldset as $key => $field) {
|
282 |
+
if(isset($posted[$key]) && !THWCFD_Utils::is_blank($posted[$key])){
|
283 |
+
$this->validate_custom_field($field, $posted, $errors);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
public function validate_custom_field($field, $posted, $errors=false, $return=false){
|
290 |
+
$err_msgs = array();
|
291 |
+
$key = isset($field['name']) ? $field['name'] : false;
|
292 |
+
|
293 |
+
if($key){
|
294 |
+
$value = isset($posted[$key]) ? $posted[$key] : '';
|
295 |
+
$validators = isset($field['validate']) ? $field['validate'] : '';
|
296 |
+
|
297 |
+
if($value && is_array($validators) && !empty($validators)){
|
298 |
+
foreach($validators as $vname){
|
299 |
+
$err_msg = '';
|
300 |
+
$flabel = isset($field['label']) ? THWCFD_Utils::t($field['label']) : $key;
|
301 |
+
|
302 |
+
if($vname === 'number'){
|
303 |
+
if(!is_numeric($value)){
|
304 |
+
$err_msg = '<strong>'. $flabel .'</strong> '. THWCFD_Utils::t('is not a valid number.');
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
if($err_msg){
|
309 |
+
if($errors || !$return){
|
310 |
+
$this->add_validation_error($err_msg, $errors);
|
311 |
+
}
|
312 |
+
$err_msgs[] = $err_msg;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
return !empty($err_msgs) ? $err_msgs : false;
|
318 |
+
}
|
319 |
+
|
320 |
+
public function add_validation_error($msg, $errors=false){
|
321 |
+
if($errors){
|
322 |
+
$errors->add('validation', $msg);
|
323 |
+
}else if(THWCFD_Utils::woo_version_check('2.3.0')){
|
324 |
+
wc_add_notice($msg, 'error');
|
325 |
+
} else {
|
326 |
+
WC()->add_error($msg);
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
public function checkout_update_order_meta($order_id, $posted){
|
331 |
+
$types = array('billing', 'shipping', 'additional');
|
332 |
+
|
333 |
+
foreach($types as $type){
|
334 |
+
if($this->maybe_skip_fieldset($type, $posted)){
|
335 |
+
continue;
|
336 |
+
}
|
337 |
+
|
338 |
+
$fields = THWCFD_Utils::get_fields($type);
|
339 |
+
|
340 |
+
foreach($fields as $name => $field){
|
341 |
+
if(THWCFD_Utils::is_active_custom_field($field) && isset($posted[$name])){
|
342 |
+
$value = wc_clean($posted[$name]);
|
343 |
+
if($value){
|
344 |
+
update_post_meta($order_id, $name, $value);
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
private function maybe_skip_fieldset( $fieldset_key, $data ) {
|
352 |
+
$ship_to_different_address = isset($data['ship_to_different_address']) ? $data['ship_to_different_address'] : false;
|
353 |
+
|
354 |
+
if ( 'shipping' === $fieldset_key && ( ! $ship_to_different_address || ! WC()->cart->needs_shipping_address() ) ) {
|
355 |
+
return true;
|
356 |
+
}
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
/****************************************
|
361 |
+
----- Display Field Values - START ------
|
362 |
+
*****************************************/
|
363 |
+
/**
|
364 |
+
* Display custom fields in emails
|
365 |
+
*/
|
366 |
+
public function display_custom_fields_in_emails($ofields, $sent_to_admin, $order){
|
367 |
+
$custom_fields = array();
|
368 |
+
$fields = THWCFD_Utils::get_checkout_fields();
|
369 |
+
|
370 |
+
// Loop through all custom fields to see if it should be added
|
371 |
+
foreach( $fields as $key => $field ) {
|
372 |
+
if(isset($field['show_in_email']) && $field['show_in_email']){
|
373 |
+
$order_id = THWCFD_Utils::get_order_id($order);
|
374 |
+
$value = get_post_meta( $order_id, $key, true );
|
375 |
+
|
376 |
+
if($value){
|
377 |
+
$label = isset($field['label']) && $field['label'] ? $field['label'] : $key;
|
378 |
+
$label = esc_attr($label);
|
379 |
+
|
380 |
+
$custom_field = array();
|
381 |
+
$custom_field['label'] = THWCFD_Utils::t($label);
|
382 |
+
$custom_field['value'] = $value;
|
383 |
+
|
384 |
+
$custom_fields[$key] = $custom_field;
|
385 |
+
}
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
return array_merge($ofields, $custom_fields);
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Display custom checkout fields on view order pages
|
394 |
+
*/
|
395 |
+
public function order_details_after_customer_details($order){
|
396 |
+
$order_id = THWCFD_Utils::get_order_id($order);
|
397 |
+
$fields = THWCFD_Utils::get_checkout_fields($order);
|
398 |
+
|
399 |
+
if(is_array($fields) && !empty($fields)){
|
400 |
+
$fields_html = '';
|
401 |
+
// Loop through all custom fields to see if it should be added
|
402 |
+
foreach($fields as $key => $field){
|
403 |
+
if(THWCFD_Utils::is_active_custom_field($field) && isset($field['show_in_order']) && $field['show_in_order']){
|
404 |
+
$value = get_post_meta( $order_id, $key, true );
|
405 |
+
|
406 |
+
if($value){
|
407 |
+
$label = isset($field['label']) && $field['label'] ? THWCFD_Utils::t($field['label']) : $key;
|
408 |
+
|
409 |
+
$label = esc_attr($label);
|
410 |
+
$value = wptexturize($value);
|
411 |
+
|
412 |
+
if(is_account_page()){
|
413 |
+
if(apply_filters( 'thwcfd_view_order_customer_details_table_view', true )){
|
414 |
+
$fields_html .= '<tr><th>'. $label .':</th><td>'. $value .'</td></tr>';
|
415 |
+
}else{
|
416 |
+
$fields_html .= '<br/><dt>'. $label .':</dt><dd>'. $value .'</dd>';
|
417 |
+
}
|
418 |
+
}else{
|
419 |
+
if(apply_filters( 'thwcfd_thankyou_customer_details_table_view', true )){
|
420 |
+
$fields_html .= '<tr><th>'. $label .':</th><td>'. $value .'</td></tr>';
|
421 |
+
}else{
|
422 |
+
$fields_html .= '<br/><dt>'. $label .':</dt><dd>'. $value .'</dd>';
|
423 |
+
}
|
424 |
+
}
|
425 |
+
}
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
if($fields_html){
|
430 |
+
do_action( 'thwcfd_order_details_before_custom_fields_table', $order );
|
431 |
+
?>
|
432 |
+
<table class="woocommerce-table woocommerce-table--custom-fields shop_table custom-fields">
|
433 |
+
<?php
|
434 |
+
echo $fields_html;
|
435 |
+
?>
|
436 |
+
</table>
|
437 |
+
<?php
|
438 |
+
do_action( 'thwcfd_order_details_after_custom_fields_table', $order );
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
442 |
+
/*****************************************
|
443 |
+
----- Display Field Values - END --------
|
444 |
+
*****************************************/
|
445 |
+
}
|
446 |
+
|
447 |
+
endif;
|
448 |
+
|
classes/class-thwcfd-settings-general.php
ADDED
@@ -0,0 +1,689 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Woo Checkout Field Editor Settings General
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.3.6
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
|
14 |
+
if(!class_exists('THWCFD_Settings_General')):
|
15 |
+
|
16 |
+
class THWCFD_Settings_General {
|
17 |
+
protected static $_instance = null;
|
18 |
+
|
19 |
+
protected $tabs = '';
|
20 |
+
protected $sections = '';
|
21 |
+
|
22 |
+
public function __construct() {
|
23 |
+
$this->tabs = array( 'fields' => 'Checkout Fields');
|
24 |
+
$this->sections = array('billing' => 'Billing Fields', 'shipping' => 'Shipping Fields', 'additional' => 'Additional Fields');
|
25 |
+
}
|
26 |
+
|
27 |
+
public static function instance() {
|
28 |
+
if(is_null(self::$_instance)){
|
29 |
+
self::$_instance = new self();
|
30 |
+
}
|
31 |
+
return self::$_instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function define_admin_hooks(){
|
35 |
+
// Show in order details page
|
36 |
+
add_action('woocommerce_admin_order_data_after_order_details', array($this, 'order_data_after_order_details'), 20, 1);
|
37 |
+
add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'order_data_after_billing_address'), 20, 1);
|
38 |
+
add_action('woocommerce_admin_order_data_after_shipping_address', array($this, 'order_data_after_shipping_address'), 20, 1);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function reset_to_default() {
|
42 |
+
delete_option('wc_fields_billing');
|
43 |
+
delete_option('wc_fields_shipping');
|
44 |
+
delete_option('wc_fields_additional');
|
45 |
+
echo '<div class="updated"><p>'. __('SUCCESS: Checkout fields successfully reset', 'woo-checkout-field-editor-pro') .'</p></div>';
|
46 |
+
}
|
47 |
+
|
48 |
+
public function render_page(){
|
49 |
+
if(isset($_POST['reset_fields']))
|
50 |
+
echo $this->reset_to_default();
|
51 |
+
|
52 |
+
$this->output_tabs();
|
53 |
+
$this->output_sections();
|
54 |
+
$this->output_content();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function render_checkout_fields_heading_row(){
|
58 |
+
?>
|
59 |
+
<th class="sort"></th>
|
60 |
+
<th class="check-column"><input type="checkbox" style="margin:0px 4px -1px -1px;" onclick="thwcfdSelectAllCheckoutFields(this)"/></th>
|
61 |
+
<th class="name"><?php _e('Name', 'woo-checkout-field-editor-pro'); ?></th>
|
62 |
+
<th class="id"><?php _e('Type', 'woo-checkout-field-editor-pro'); ?></th>
|
63 |
+
<th><?php _e('Label', 'woo-checkout-field-editor-pro'); ?></th>
|
64 |
+
<th><?php _e('Placeholder', 'woo-checkout-field-editor-pro'); ?></th>
|
65 |
+
<th><?php _e('Validations', 'woo-checkout-field-editor-pro'); ?></th>
|
66 |
+
<th class="status"><?php _e('Required', 'woo-checkout-field-editor-pro'); ?></th>
|
67 |
+
<th class="status"><?php _e('Enabled', 'woo-checkout-field-editor-pro'); ?></th>
|
68 |
+
<th class="action"><?php _e('Edit', 'woo-checkout-field-editor-pro'); ?></th>
|
69 |
+
<?php
|
70 |
+
}
|
71 |
+
|
72 |
+
public function render_actions_row($section){
|
73 |
+
?>
|
74 |
+
<th colspan="6">
|
75 |
+
<button type="button" class="button button-primary" onclick="thwcfdOpenNewFieldForm('<?php echo $section; ?>')">+ <?php _e( 'Add field', 'woo-checkout-field-editor-pro' ); ?></button>
|
76 |
+
<button type="button" class="button" onclick="thwcfdRemoveSelectedFields()"><?php _e('Remove', 'woo-checkout-field-editor-pro'); ?></button>
|
77 |
+
<button type="button" class="button" onclick="thwcfdEnableSelectedFields()"><?php _e('Enable', 'woo-checkout-field-editor-pro'); ?></button>
|
78 |
+
<button type="button" class="button" onclick="thwcfdDisableSelectedFields()"><?php _e('Disable', 'woo-checkout-field-editor-pro'); ?></button>
|
79 |
+
</th>
|
80 |
+
<th colspan="4">
|
81 |
+
<input type="submit" name="save_fields" class="button-primary" value="<?php _e( 'Save changes', 'woo-checkout-field-editor-pro' ) ?>" style="float:right" />
|
82 |
+
<input type="submit" name="reset_fields" class="button" value="<?php _e( 'Reset to default fields', 'woo-checkout-field-editor-pro' ) ?>" style="float:right; margin-right: 5px;"
|
83 |
+
onclick="return confirm('Are you sure you want to reset to default fields? all your changes will be deleted.');"/>
|
84 |
+
</th>
|
85 |
+
<?php
|
86 |
+
}
|
87 |
+
|
88 |
+
public function output_content() {
|
89 |
+
$section = $this->get_current_section();
|
90 |
+
$action = isset($_POST['f_action']) ? $_POST['f_action'] : false;
|
91 |
+
|
92 |
+
if($action === 'new')
|
93 |
+
echo $this->save_or_update_field($section, $action);
|
94 |
+
|
95 |
+
if($action === 'edit')
|
96 |
+
echo $this->save_or_update_field($section, $action);
|
97 |
+
|
98 |
+
if(isset($_POST['save_fields']))
|
99 |
+
echo $this->save_fields($section);
|
100 |
+
|
101 |
+
$fields = THWCFD_Utils::get_fields($section);
|
102 |
+
|
103 |
+
?>
|
104 |
+
<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>
|
105 |
+
<form method="post" id="wcfd_checkout_fields_form" action="">
|
106 |
+
<table id="thwcfd_checkout_fields" class="thpladmin_fields_table" cellspacing="0">
|
107 |
+
<thead>
|
108 |
+
<tr><?php $this->render_actions_row($section); ?></tr>
|
109 |
+
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
110 |
+
</thead>
|
111 |
+
<tfoot>
|
112 |
+
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
113 |
+
<tr><?php $this->render_actions_row($section); ?></tr>
|
114 |
+
</tfoot>
|
115 |
+
<tbody class="ui-sortable">
|
116 |
+
<?php
|
117 |
+
$i=0;
|
118 |
+
foreach( $fields as $name => $field ) :
|
119 |
+
$type = isset($field['type']) ? $field['type'] : '';
|
120 |
+
$label = isset($field['label']) ? $field['label'] : '';
|
121 |
+
$placeholder = isset($field['placeholder']) ? $field['placeholder'] : '';
|
122 |
+
$validate = isset($field['validate']) ? $field['validate'] : '';
|
123 |
+
$required = isset($field['required']) && $field['required'] ? 1 : 0;
|
124 |
+
$enabled = isset($field['enabled']) && $field['enabled'] ? 1 : 0;
|
125 |
+
$custom = isset($field['custom']) && $field['custom'] ? 1 : 0;
|
126 |
+
|
127 |
+
$validate = is_array($validate) ? implode(",", $validate) : '';
|
128 |
+
|
129 |
+
$required_status = $required ? '<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>' : '-';
|
130 |
+
$enabled_status = $enabled ? '<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>' : '-';
|
131 |
+
|
132 |
+
$props_json = htmlspecialchars($this->get_property_set_json($name, $field));
|
133 |
+
//$options_json = isset($field['options_json']) && $field['options_json'] ? htmlspecialchars($field['options_json']) : '';
|
134 |
+
|
135 |
+
$options_json = '';
|
136 |
+
if($type === 'select' || $type === 'radio'){
|
137 |
+
$options = isset($field['options']) ? $field['options'] : '';
|
138 |
+
$options_json = THWCFD_Utils::prepare_options_json($options);
|
139 |
+
}
|
140 |
+
?>
|
141 |
+
<tr class="row_<?php echo $i; echo $enabled ? '' : ' thpladmin-disabled' ?>">
|
142 |
+
<td width="1%" class="sort ui-sortable-handle">
|
143 |
+
<input type="hidden" name="f_name[<?php echo $i; ?>]" class="f_name" value="<?php echo esc_attr($name); ?>" />
|
144 |
+
<input type="hidden" name="f_name_new[<?php echo $i; ?>]" class="f_name_new" value="" />
|
145 |
+
<input type="hidden" name="f_order[<?php echo $i; ?>]" class="f_order" value="<?php echo $i; ?>" />
|
146 |
+
<input type="hidden" name="f_deleted[<?php echo $i; ?>]" class="f_deleted" value="0" />
|
147 |
+
<input type="hidden" name="f_enabled[<?php echo $i; ?>]" class="f_enabled" value="<?php echo $enabled; ?>" />
|
148 |
+
<input type="hidden" name="f_props[<?php echo $i; ?>]" class="f_props" value='<?php echo $props_json; ?>' />
|
149 |
+
<input type="hidden" name="f_options[<?php echo $i; ?>]" class="f_options" value='<?php echo $options_json; ?>' />
|
150 |
+
</td>
|
151 |
+
<td class="td_select"><input type="checkbox" name="select_field"/></td>
|
152 |
+
<td class="td_name"><?php echo esc_attr( $name ); ?></td>
|
153 |
+
<td class="td_type"><?php echo $type; ?></td>
|
154 |
+
<td class="td_label"><?php THWCFD_Utils::et($label); ?></td>
|
155 |
+
<td class="td_placeholder"><?php THWCFD_Utils::et($placeholder); ?></td>
|
156 |
+
<td class="td_validate"><?php echo $validate; ?></td>
|
157 |
+
<td class="td_required status"><?php echo $required_status; ?></td>
|
158 |
+
<td class="td_enabled status"><?php echo $enabled_status; ?></td>
|
159 |
+
<td class="td_edit action">
|
160 |
+
<button type="button" class="button action-btn f_edit_btn" <?php echo($enabled ? '' : 'disabled') ?>
|
161 |
+
onclick="thwcfdOpenEditFieldForm(this, <?php echo $i; ?>)"><?php _e('Edit', 'woo-checkout-field-editor-pro'); ?></button>
|
162 |
+
</td>
|
163 |
+
</tr>
|
164 |
+
<?php
|
165 |
+
$i++;
|
166 |
+
endforeach;
|
167 |
+
?>
|
168 |
+
</tbody>
|
169 |
+
</table>
|
170 |
+
</form>
|
171 |
+
<?php
|
172 |
+
$this->output_add_field_form_pp();
|
173 |
+
$this->output_edit_field_form_pp();
|
174 |
+
//$this->output_popup_form_field_fragments();
|
175 |
+
}
|
176 |
+
|
177 |
+
public function get_property_set_json($name, $field){
|
178 |
+
$json = '';
|
179 |
+
if(is_array($field)){
|
180 |
+
foreach($field as $pname => $pvalue){
|
181 |
+
$pvalue = is_array($pvalue) ? implode(',', $pvalue) : $pvalue;
|
182 |
+
$pvalue = is_string($pvalue) ? esc_attr($pvalue) : $pvalue;
|
183 |
+
|
184 |
+
$field[$pname] = $pvalue;
|
185 |
+
}
|
186 |
+
|
187 |
+
$field['name'] = $name;
|
188 |
+
$json = json_encode($field);
|
189 |
+
}
|
190 |
+
return $json;
|
191 |
+
}
|
192 |
+
|
193 |
+
private function save_or_update_field($section, $action) {
|
194 |
+
try {
|
195 |
+
$result = false;
|
196 |
+
$fields = THWCFD_Utils::get_fields($section);
|
197 |
+
$field = $this->prepare_field_from_posted_data($_POST);
|
198 |
+
$name = isset($field['name']) ? $field['name'] : false;
|
199 |
+
|
200 |
+
if($name){
|
201 |
+
if($action === 'new'){
|
202 |
+
$priority = THWCFD_Utils::prepare_field_priority($fields, false, true);
|
203 |
+
$field['custom'] = 1;
|
204 |
+
$field['priority'] = $priority;
|
205 |
+
}else{
|
206 |
+
$oname = isset($_POST['i_oname']) ? trim(stripslashes($_POST['i_oname'])) : false;
|
207 |
+
if($name && $oname && $name !== $oname ){
|
208 |
+
unset($fields[$oname]);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
$fields[$name] = $field;
|
213 |
+
}
|
214 |
+
|
215 |
+
$result = THWCFD_Utils::update_fields($section, $fields);
|
216 |
+
|
217 |
+
if($result == true) {
|
218 |
+
echo '<div class="updated"><p>'. __('Your changes were saved.', 'woo-checkout-field-editor-pro') .'</p></div>';
|
219 |
+
}else {
|
220 |
+
echo '<div class="error"><p>'. __('Your changes were not saved due to an error (or you made none!).', 'woo-checkout-field-editor-pro') .'</p></div>';
|
221 |
+
}
|
222 |
+
} catch (Exception $e) {
|
223 |
+
echo '<div class="error"><p>'. __('Your changes were not saved due to an error.', 'woo-checkout-field-editor-pro') .'</p></div>';
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
private function save_fields($section) {
|
228 |
+
try {
|
229 |
+
$f_names = !empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
|
230 |
+
if(empty($f_names)){
|
231 |
+
echo '<div class="error"><p> '. __('Your changes were not saved due to no fields found.', 'woo-checkout-field-editor-pro') .'</p></div>';
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
$f_order = !empty( $_POST['f_order'] ) ? $_POST['f_order'] : array();
|
236 |
+
$f_deleted = !empty( $_POST['f_deleted'] ) ? $_POST['f_deleted'] : array();
|
237 |
+
$f_enabled = !empty( $_POST['f_enabled'] ) ? $_POST['f_enabled'] : array();
|
238 |
+
|
239 |
+
$fields = THWCFD_Utils::get_fields($section);
|
240 |
+
|
241 |
+
$max = max( array_map( 'absint', array_keys( $f_names ) ) );
|
242 |
+
for($i = 0; $i <= $max; $i++) {
|
243 |
+
$name = $f_names[$i];
|
244 |
+
|
245 |
+
if(isset($fields[$name])){
|
246 |
+
$is_deleted = isset($f_deleted[$i]) && $f_deleted[$i] ? true : false;
|
247 |
+
|
248 |
+
if($is_deleted){
|
249 |
+
unset($fields[$name]);
|
250 |
+
continue;
|
251 |
+
}
|
252 |
+
|
253 |
+
$order = isset($f_order[$i]) ? trim(stripslashes($f_order[$i])) : 0;
|
254 |
+
$enabled = isset($f_enabled[$i]) ? trim(stripslashes($f_enabled[$i])) : 0;
|
255 |
+
$priority = THWCFD_Utils::prepare_field_priority($fields, $order, false);
|
256 |
+
|
257 |
+
$field = $fields[$name];
|
258 |
+
$field['priority'] = $priority;
|
259 |
+
$field['enabled'] = $enabled;
|
260 |
+
|
261 |
+
$fields[$name] = $field;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
$fields = THWCFD_Utils::sort_fields($fields);
|
265 |
+
$result = THWCFD_Utils::update_fields($section, $fields);
|
266 |
+
|
267 |
+
if($result == true) {
|
268 |
+
echo '<div class="updated"><p>'. __('Your changes were saved.', 'woo-checkout-field-editor-pro') .'</p></div>';
|
269 |
+
}else {
|
270 |
+
echo '<div class="error"><p>'. __('Your changes were not saved due to an error (or you made none!).', 'woo-checkout-field-editor-pro') .'</p></div>';
|
271 |
+
}
|
272 |
+
} catch (Exception $e) {
|
273 |
+
echo '<div class="error"><p>'. __('Your changes were not saved due to an error.', 'woo-checkout-field-editor-pro') .'</p></div>';
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
private function prepare_field_from_posted_data($posted){
|
278 |
+
$field_props = $this->get_field_form_props();
|
279 |
+
$field = array();
|
280 |
+
|
281 |
+
foreach ($field_props as $pname => $prop) {
|
282 |
+
$iname = 'i_'.$pname;
|
283 |
+
|
284 |
+
$pvalue = '';
|
285 |
+
if($prop['type'] === 'checkbox'){
|
286 |
+
$pvalue = isset($posted[$iname]) && $posted[$iname] ? 1 : 0;
|
287 |
+
}else if(isset($posted[$iname])){
|
288 |
+
//$pvalue = is_array($posted[$iname]) ? implode(',', $posted[$iname]) : trim(stripslashes($posted[$iname]));
|
289 |
+
$pvalue = is_array($posted[$iname]) ? $posted[$iname] : trim(stripslashes($posted[$iname]));
|
290 |
+
}
|
291 |
+
|
292 |
+
if($pname === 'class'){
|
293 |
+
//$pvalue = is_string($pvalue) ? array_map('trim', explode(',', $pvalue)) : $pvalue;
|
294 |
+
$pvalue = is_string($pvalue) ? preg_split('/(\s*,*\s*)*,+(\s*,*\s*)*/', $pvalue) : $pvalue;
|
295 |
+
$pvalue = is_array($pvalue) ? $pvalue : array();
|
296 |
+
}
|
297 |
+
|
298 |
+
$field[$pname] = $pvalue;
|
299 |
+
}
|
300 |
+
|
301 |
+
$type = isset($field['type']) ? $field['type'] : '';
|
302 |
+
if(!$type){
|
303 |
+
$type = isset($posted['i_otype']) ? trim(stripslashes($posted['i_otype'])) : '';
|
304 |
+
$field['type'] = $type;
|
305 |
+
}
|
306 |
+
|
307 |
+
$name = isset($field['name']) ? $field['name'] : '';
|
308 |
+
if(!$name){
|
309 |
+
$field['name'] = isset($posted['i_oname']) ? trim(stripslashes($posted['i_oname'])) : '';
|
310 |
+
}
|
311 |
+
|
312 |
+
if($type === 'select'){
|
313 |
+
$field['validate'] = '';
|
314 |
+
|
315 |
+
}else if($type === 'radio'){
|
316 |
+
$field['validate'] = '';
|
317 |
+
$field['placeholder'] = '';
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
if($type === 'select' || $type === 'radio'){
|
322 |
+
$options_json = isset($posted['i_options_json']) ? trim(stripslashes($posted['i_options_json'])) : '';
|
323 |
+
$options_arr = THWCFD_Utils::prepare_options_array($options_json);
|
324 |
+
|
325 |
+
//$field['options_json'] = $options_json;
|
326 |
+
$field['options'] = $options_arr;
|
327 |
+
}else{
|
328 |
+
$field['options'] = '';
|
329 |
+
}
|
330 |
+
|
331 |
+
$field['autocomplete'] = isset($posted['i_autocomplete']) ? $posted['i_autocomplete'] : '';
|
332 |
+
$field['priority'] = isset($posted['i_priority']) ? $posted['i_priority'] : '';
|
333 |
+
//$field['custom'] = isset($posted['i_custom']) ? $posted['i_custom'] : '';
|
334 |
+
$field['custom'] = isset($posted['i_custom']) && $posted['i_custom'] ? 1 : 0;
|
335 |
+
|
336 |
+
return $field;
|
337 |
+
}
|
338 |
+
|
339 |
+
/******* ADD,EDIT Forms *******/
|
340 |
+
/*******************************/
|
341 |
+
public function get_field_types(){
|
342 |
+
return array(
|
343 |
+
'text' => __('Text', 'woo-checkout-field-editor-pro'),
|
344 |
+
'password' => __('Password', 'woo-checkout-field-editor-pro'),
|
345 |
+
'email' => __('Email', 'woo-checkout-field-editor-pro'),
|
346 |
+
'tel' => __('Phone', 'woo-checkout-field-editor-pro'),
|
347 |
+
'select' => __('Select', 'woo-checkout-field-editor-pro'),
|
348 |
+
'textarea' => __('Textarea', 'woo-checkout-field-editor-pro'),
|
349 |
+
'radio' => __('Radio', 'woo-checkout-field-editor-pro'),
|
350 |
+
);
|
351 |
+
}
|
352 |
+
|
353 |
+
public function get_field_form_props(){
|
354 |
+
$field_types = $this->get_field_types();
|
355 |
+
|
356 |
+
$validations = array(
|
357 |
+
'email' => 'Email',
|
358 |
+
'phone' => 'Phone',
|
359 |
+
'postcode' => 'Postcode',
|
360 |
+
'state' => 'State',
|
361 |
+
'number' => 'Number',
|
362 |
+
);
|
363 |
+
|
364 |
+
$display_style = array(
|
365 |
+
'full' => 'Full width',
|
366 |
+
'half_left' => 'Half width left',
|
367 |
+
'ha;lf_right' => 'Half width right',
|
368 |
+
);
|
369 |
+
|
370 |
+
return array(
|
371 |
+
'type' => array('type'=>'select', 'name'=>'type', 'label'=>'Type', 'required'=>1, 'options'=>$field_types,
|
372 |
+
'onchange'=>'thwcfdFieldTypeChangeListner(this)'),
|
373 |
+
'name' => array('type'=>'text', 'name'=>'name', 'label'=>'Name', 'required'=>1),
|
374 |
+
'label' => array('type'=>'text', 'name'=>'label', 'label'=>'Label'),
|
375 |
+
'default' => array('type'=>'text', 'name'=>'default', 'label'=>'Default Value'),
|
376 |
+
'placeholder' => array('type'=>'text', 'name'=>'placeholder', 'label'=>'Placeholder'),
|
377 |
+
//'options' => array('type'=>'text', 'name'=>'options', 'label'=>'Options', 'placeholder'=>'Seperate options with pipe(|)'),
|
378 |
+
'class' => array('type'=>'text', 'name'=>'class', 'label'=>'Class', 'placeholder'=>'Seperate classes with comma'),
|
379 |
+
'validate' => array('type'=>'select', 'name'=>'validate', 'label'=>'Validation', 'options'=>$validations, 'multiple'=>1),
|
380 |
+
'disp_style' => array('type'=>'select', 'name'=>'disp_style', 'label'=>'Field Display', 'options'=>$display_style),
|
381 |
+
|
382 |
+
'required' => array('type'=>'checkbox', 'name'=>'required', 'label'=>'Required', 'value'=>'1', 'checked'=>1),
|
383 |
+
//'clear' => array('type'=>'checkbox', 'name'=>'clear', 'label'=>'Clear Row', 'value'=>'1', 'checked'=>1),
|
384 |
+
'enabled' => array('type'=>'checkbox', 'name'=>'enabled', 'label'=>'Enabled', 'value'=>'1', 'checked'=>1),
|
385 |
+
|
386 |
+
'show_in_email' => array('type'=>'checkbox', 'name'=>'show_in_email', 'label'=>'Display in Emails', 'value'=>'1', 'checked'=>1),
|
387 |
+
'show_in_order' => array('type'=>'checkbox', 'name'=>'show_in_order', 'label'=>'Display in Order Detail Pages', 'value'=>'1', 'checked'=>1),
|
388 |
+
);
|
389 |
+
}
|
390 |
+
|
391 |
+
private function output_add_field_form_pp(){
|
392 |
+
?>
|
393 |
+
<div id="thwcfd_new_field_form_pp" title="New Checkout Field" class="thpladmin-popup-wrapper">
|
394 |
+
<?php $this->output_popup_form_fields('new'); ?>
|
395 |
+
</div>
|
396 |
+
<?php
|
397 |
+
}
|
398 |
+
|
399 |
+
private function output_edit_field_form_pp(){
|
400 |
+
?>
|
401 |
+
<div id="thwcfd_edit_field_form_pp" title="Edit Checkout Field" class="thpladmin-popup-wrapper">
|
402 |
+
<?php $this->output_popup_form_fields('edit'); ?>
|
403 |
+
</div>
|
404 |
+
<?php
|
405 |
+
}
|
406 |
+
|
407 |
+
private function output_popup_form_fields($form_type){
|
408 |
+
$field_props = $this->get_field_form_props();
|
409 |
+
|
410 |
+
?>
|
411 |
+
<form method="post" id="thwcfd_<?php echo $form_type ?>_field_form" action="">
|
412 |
+
<input type="hidden" name="f_action" value="<?php echo $form_type ?>" />
|
413 |
+
<input type="hidden" name="i_autocomplete" value="" />
|
414 |
+
<input type="hidden" name="i_priority" value="" />
|
415 |
+
<input type="hidden" name="i_custom" value="" />
|
416 |
+
<input type="hidden" name="i_oname" value="" />
|
417 |
+
<input type="hidden" name="i_otype" value="" />
|
418 |
+
<input type="hidden" name="i_options_json" value="" />
|
419 |
+
|
420 |
+
<table width="100%">
|
421 |
+
<tr>
|
422 |
+
<td colspan="2" class="err_msgs"></td>
|
423 |
+
</tr>
|
424 |
+
<?php
|
425 |
+
$this->render_form_field_element($field_props['type']);
|
426 |
+
$this->render_form_field_element($field_props['name']);
|
427 |
+
$this->render_form_field_element($field_props['label']);
|
428 |
+
$this->render_form_field_element($field_props['placeholder']);
|
429 |
+
$this->render_form_field_element($field_props['default']);
|
430 |
+
$this->render_form_field_element($field_props['class']);
|
431 |
+
//$this->render_form_field_element($field_props['disp_style']);
|
432 |
+
$this->render_form_field_element($field_props['validate']);
|
433 |
+
//$this->render_form_field_element($field_props['options']);
|
434 |
+
$this->render_form_element_h_spacing();
|
435 |
+
$this->render_field_form_fragment_options();
|
436 |
+
$this->render_form_element_h_spacing();
|
437 |
+
|
438 |
+
?>
|
439 |
+
<tr class="row-required">
|
440 |
+
<td> </td>
|
441 |
+
<td>
|
442 |
+
<?php
|
443 |
+
$this->render_form_field_element($field_props['required']);
|
444 |
+
//$this->render_form_field_element($field_props['clear']);
|
445 |
+
$this->render_form_field_element($field_props['enabled']);
|
446 |
+
$this->render_form_field_element($field_props['show_in_email']);
|
447 |
+
$this->render_form_field_element($field_props['show_in_order']);
|
448 |
+
?>
|
449 |
+
</td>
|
450 |
+
</tr>
|
451 |
+
</table>
|
452 |
+
</form>
|
453 |
+
<?php
|
454 |
+
}
|
455 |
+
|
456 |
+
public function render_form_field_element($props){
|
457 |
+
if(is_array($props)){
|
458 |
+
$type = isset($props['type']) ? $props['type'] : 'text';
|
459 |
+
|
460 |
+
if($type === 'select'){
|
461 |
+
$this->render_form_field_element_select($props);
|
462 |
+
}else if($type === 'radio'){
|
463 |
+
$this->render_form_field_element_radio($props);
|
464 |
+
}else if($type === 'checkbox'){
|
465 |
+
$this->render_form_field_element_checkbox($props);
|
466 |
+
}else{
|
467 |
+
$this->render_form_field_element_inputtext($props);
|
468 |
+
}
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
private function render_form_field_element_inputtext($props){
|
473 |
+
$name = isset($props['name']) ? $props['name'] : '';
|
474 |
+
$fname = 'i_'.$name;
|
475 |
+
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
476 |
+
|
477 |
+
$field_attr = 'name="'.$fname.'" value=""';
|
478 |
+
if(isset($props['placeholder']) && $props['placeholder']){
|
479 |
+
$field_attr .= ' placeholder="'.__($props['placeholder'], 'woo-checkout-field-editor-pro').'"';
|
480 |
+
}
|
481 |
+
$field_attr .= ' style="width:250px;"';
|
482 |
+
|
483 |
+
?>
|
484 |
+
<tr class="<?php echo 'row-'.$name; ?>">
|
485 |
+
<td width="30%"><?php echo $label; ?></td>
|
486 |
+
<td><input type="text" <?php echo $field_attr; ?> /></td>
|
487 |
+
</tr>
|
488 |
+
<?php
|
489 |
+
}
|
490 |
+
|
491 |
+
private function render_form_field_element_select($props){
|
492 |
+
$name = isset($props['name']) ? $props['name'] : '';
|
493 |
+
$fname = isset($props['multiple']) && $props['multiple'] ? 'i_'.$name.'[]' : 'i_'.$name;
|
494 |
+
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
495 |
+
$options = isset($props['options']) ? $props['options'] : array();
|
496 |
+
$options = is_array($options) ? $options : $array();
|
497 |
+
|
498 |
+
$field_attr = 'name="'.$fname.'"';
|
499 |
+
if(isset($props['onchange']) && $props['onchange']){
|
500 |
+
$field_attr .= ' onchange="'.$props['onchange'].'"';
|
501 |
+
}
|
502 |
+
|
503 |
+
if(isset($props['placeholder']) && $props['placeholder']){
|
504 |
+
$field_attr .= ' data-placeholder="'.__($props['placeholder'], 'woo-checkout-field-editor-pro').'"';
|
505 |
+
}
|
506 |
+
|
507 |
+
if(isset($props['multiple']) && $props['multiple']){
|
508 |
+
$field_attr .= ' multiple="multiple"';
|
509 |
+
$field_attr .= ' class="thwcfd-enhanced-multi-select"';
|
510 |
+
$field_attr .= ' style="width:250px; height:30px;"';
|
511 |
+
}else{
|
512 |
+
$field_attr .= ' style="width:250px;"';
|
513 |
+
}
|
514 |
+
|
515 |
+
?>
|
516 |
+
<tr class="<?php echo 'row-'.$name; ?>">
|
517 |
+
<td width="30%"><?php echo $label; ?></td>
|
518 |
+
<td>
|
519 |
+
<select <?php echo $field_attr; ?> >
|
520 |
+
<?php foreach($options as $key => $value){ ?>
|
521 |
+
<option value="<?php echo trim($key); ?>"><?php echo $value; ?></option>
|
522 |
+
<?php } ?>
|
523 |
+
</select>
|
524 |
+
</td>
|
525 |
+
</tr>
|
526 |
+
<?php
|
527 |
+
}
|
528 |
+
|
529 |
+
private function render_form_field_element_radio($props){
|
530 |
+
$name = isset($props['name']) ? $props['name'] : '';
|
531 |
+
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
532 |
+
$options = isset($props['options']) ? $props['options'] : array();
|
533 |
+
$options = is_array($options) ? $options : $array();
|
534 |
+
|
535 |
+
?>
|
536 |
+
<tr class="<?php echo 'row-'.$name; ?>">
|
537 |
+
<td width="30%"><?php echo $label; ?></td>
|
538 |
+
<td>
|
539 |
+
|
540 |
+
<?php foreach($options as $key => $value){ ?>
|
541 |
+
<input type="radio" name="<?php echo $name; ?>" value="<?php echo trim($key); ?>"> <?php echo $value; ?>
|
542 |
+
<?php } ?>
|
543 |
+
</td>
|
544 |
+
</tr>
|
545 |
+
<?php
|
546 |
+
}
|
547 |
+
|
548 |
+
private function render_form_field_element_checkbox($props){
|
549 |
+
$name = isset($props['name']) ? $props['name'] : '';
|
550 |
+
$fname = 'i_'.$name;
|
551 |
+
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
552 |
+
|
553 |
+
$field_attr = 'id="'.$fname.'" name="'.$fname.'" value="1"';
|
554 |
+
if(isset($props['checked']) && $props['checked']){
|
555 |
+
$field_attr .= ' checked="checked"';
|
556 |
+
}
|
557 |
+
|
558 |
+
?>
|
559 |
+
<input type="checkbox" <?php echo $field_attr; ?> />
|
560 |
+
<label for="<?php echo $fname; ?>"><?php echo $label; ?></label><br/>
|
561 |
+
<?php
|
562 |
+
}
|
563 |
+
|
564 |
+
private function render_field_form_fragment_options(){
|
565 |
+
?>
|
566 |
+
<tr class="row-options">
|
567 |
+
<td width="30%" valign="top"><?php _e('Options', 'woo-checkout-field-editor-pro'); ?></td>
|
568 |
+
<td>
|
569 |
+
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="thwcfd-option-list thpladmin-dynamic-row-table"><tbody>
|
570 |
+
<tr>
|
571 |
+
<td style="width:150px;"><input type="text" name="i_options_key[]" placeholder="Option Value" style="width:140px;"/></td>
|
572 |
+
<td style="width:190px;"><input type="text" name="i_options_text[]" placeholder="Option Text" style="width:180px;"/></td>
|
573 |
+
<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>
|
574 |
+
<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>
|
575 |
+
<td class="action-cell sort ui-sortable-handle"></td>
|
576 |
+
</tr>
|
577 |
+
</tbody></table>
|
578 |
+
</td>
|
579 |
+
</tr>
|
580 |
+
<?php
|
581 |
+
}
|
582 |
+
|
583 |
+
public function render_form_element_h_spacing($padding = 5, $colspan = 2){
|
584 |
+
?>
|
585 |
+
<tr><td colspan="<?php echo $colspan; ?>" style="padding-top:<?php echo $padding ?>px;"></td></tr>
|
586 |
+
<?php
|
587 |
+
}
|
588 |
+
|
589 |
+
/******* Display & Update Field Values *******/
|
590 |
+
/*********************************************/
|
591 |
+
public function order_data_after_order_details($order){
|
592 |
+
$fields = THWCFD_Utils::get_fields('additional');
|
593 |
+
$this->display_fields_in_admin_order($order, $fields, '<p> </p>');
|
594 |
+
}
|
595 |
+
|
596 |
+
public function order_data_after_billing_address($order){
|
597 |
+
$fields = THWCFD_Utils::get_fields('billing');
|
598 |
+
$this->display_fields_in_admin_order($order, $fields, '');
|
599 |
+
}
|
600 |
+
|
601 |
+
public function order_data_after_shipping_address($order){
|
602 |
+
$fields = THWCFD_Utils::get_fields('shipping');
|
603 |
+
$this->display_fields_in_admin_order($order, $fields, '');
|
604 |
+
}
|
605 |
+
|
606 |
+
public function display_fields_in_admin_order($order, $fields, $prefix_html = ''){
|
607 |
+
if(is_array($fields)){
|
608 |
+
$html = '';
|
609 |
+
$order_id = THWCFD_Utils::get_order_id($order);
|
610 |
+
|
611 |
+
foreach($fields as $name => $field){
|
612 |
+
if(THWCFD_Utils::is_active_custom_field($field) && isset($field['show_in_order']) && $field['show_in_order']){
|
613 |
+
$value = get_post_meta( $order_id, $name, true );
|
614 |
+
if(!empty($value)){
|
615 |
+
$label = isset($field['label']) && $field['label'] ? THWCFD_Utils::t($field['label']) : $name;
|
616 |
+
$html .= '<p><strong>'. $label .':</strong><br/> '. wptexturize($value) .'</p>';
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
if($html){
|
622 |
+
echo $prefix_html.$html;
|
623 |
+
}
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
/******* TABS & SECTIONS *******/
|
628 |
+
/*******************************/
|
629 |
+
public function get_current_tab(){
|
630 |
+
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
631 |
+
}
|
632 |
+
|
633 |
+
public function get_current_section(){
|
634 |
+
$tab = $this->get_current_tab();
|
635 |
+
$section = '';
|
636 |
+
if($tab === 'fields'){
|
637 |
+
$section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
|
638 |
+
}
|
639 |
+
return $section;
|
640 |
+
}
|
641 |
+
|
642 |
+
public function output_tabs(){
|
643 |
+
$current_tab = $this->get_current_tab();
|
644 |
+
|
645 |
+
if(empty($this->tabs)){
|
646 |
+
return;
|
647 |
+
}
|
648 |
+
|
649 |
+
echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
|
650 |
+
foreach( $this->tabs as $id => $label ){
|
651 |
+
$active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
|
652 |
+
$label = __($label, 'woo-checkout-field-editor-pro');
|
653 |
+
echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
|
654 |
+
}
|
655 |
+
echo '</h2>';
|
656 |
+
}
|
657 |
+
|
658 |
+
public function output_sections() {
|
659 |
+
$current_tab = $this->get_current_tab();
|
660 |
+
$current_section = $this->get_current_section();
|
661 |
+
|
662 |
+
if(empty($this->sections)){
|
663 |
+
return;
|
664 |
+
}
|
665 |
+
|
666 |
+
$array_keys = array_keys( $this->sections );
|
667 |
+
|
668 |
+
echo '<ul class="thpladmin-sections">';
|
669 |
+
foreach( $this->sections as $id => $label ){
|
670 |
+
$label = __($label, 'woo-checkout-field-editor-pro');
|
671 |
+
$url = $this->get_admin_url($current_tab, sanitize_title($id));
|
672 |
+
echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
|
673 |
+
}
|
674 |
+
echo '</ul>';
|
675 |
+
}
|
676 |
+
|
677 |
+
public function get_admin_url($tab = false, $section = false){
|
678 |
+
$url = 'admin.php?page=checkout_form_designer';
|
679 |
+
if($tab && !empty($tab)){
|
680 |
+
$url .= '&tab='. $tab;
|
681 |
+
}
|
682 |
+
if($section && !empty($section)){
|
683 |
+
$url .= '§ion='. $section;
|
684 |
+
}
|
685 |
+
return admin_url($url);
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
endif;
|
classes/class-thwcfd-settings.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Woo Checkout Field Editor Settings
|
4 |
+
*
|
5 |
+
* @author ThemeHigh
|
6 |
+
* @category Admin
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined( 'ABSPATH' ) || exit;
|
10 |
+
|
11 |
+
if(!class_exists('THWCFD_Settings')) :
|
12 |
+
|
13 |
+
class THWCFD_Settings {
|
14 |
+
public function __construct() {
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
public function enqueue_styles_and_scripts($hook) {
|
19 |
+
if(strpos($hook, 'woocommerce_page_checkout_form_designer') === false) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
+
$deps = array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-tiptip', 'woocommerce_admin', 'select2', 'wp-color-picker');
|
24 |
+
|
25 |
+
wp_enqueue_style('woocommerce_admin_styles');
|
26 |
+
wp_enqueue_style('thwcfd-admin-style', THWCFD_ASSETS_URL . 'css/thwcfd-admin.css', THWCFD_VERSION);
|
27 |
+
wp_enqueue_script('thwcfd-admin-script', THWCFD_ASSETS_URL . 'js/thwcfd-admin.js', $deps, THWCFD_VERSION, true);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function admin_menu() {
|
31 |
+
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Form Designer', 'woo-checkout-field-editor-pro'), __('Checkout Form', 'woo-checkout-field-editor-pro'), 'manage_woocommerce', 'checkout_form_designer', array($this, 'output_settings'));
|
32 |
+
|
33 |
+
//add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
34 |
+
}
|
35 |
+
|
36 |
+
public function add_screen_id($ids){
|
37 |
+
$ids[] = 'woocommerce_page_checkout_form_designer';
|
38 |
+
$ids[] = strtolower(__('WooCommerce', 'woo-checkout-field-editor-pro')) .'_page_checkout_form_designer';
|
39 |
+
|
40 |
+
return $ids;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function plugin_action_links($links) {
|
44 |
+
$settings_link = '<a href="'.admin_url('admin.php?page=checkout_form_designer').'">'. __('Settings', 'woo-checkout-field-editor-pro') .'</a>';
|
45 |
+
array_unshift($links, $settings_link);
|
46 |
+
return $links;
|
47 |
+
}
|
48 |
+
|
49 |
+
/*public function plugin_row_meta( $links, $file ) {
|
50 |
+
if(THWCFE_BASE_NAME == $file) {
|
51 |
+
$doc_link = esc_url('https://www.themehigh.com/help-guides/woocommerce-checkout-field-editor/');
|
52 |
+
$support_link = esc_url('https://www.themehigh.com/help-guides/');
|
53 |
+
|
54 |
+
$row_meta = array(
|
55 |
+
'docs' => '<a href="'.$doc_link.'" target="_blank" aria-label="'.__('View plugin documentation', 'woo-checkout-field-editor-pro').'">'.__('Docs', 'woo-checkout-field-editor-pro').'</a>',
|
56 |
+
'support' => '<a href="'.$support_link.'" target="_blank" aria-label="'. __('Visit premium customer support', 'woo-checkout-field-editor-pro') .'">'. __('Premium support', 'woo-checkout-field-editor-pro') .'</a>',
|
57 |
+
);
|
58 |
+
|
59 |
+
return array_merge( $links, $row_meta );
|
60 |
+
}
|
61 |
+
return (array) $links;
|
62 |
+
}*/
|
63 |
+
|
64 |
+
private function output_premium_version_notice(){
|
65 |
+
?>
|
66 |
+
<div id="message" class="wc-connect updated thpladmin-notice">
|
67 |
+
<div class="squeezer">
|
68 |
+
<table>
|
69 |
+
<tr>
|
70 |
+
<td width="70%">
|
71 |
+
<p><strong><i>WooCommerce Checkout Field Editor Pro</i></strong> premium version provides more features to design your checkout page.</p>
|
72 |
+
<ul>
|
73 |
+
<li>17 field types available, (<i>Text, Hidden, Password, Telephone, Email, Number, Textarea, Radio, Checkbox, Checkbox Group, Select, Multi-select, Date Picker, Time Picker, File Upload, Heading, Label</i>).</li>
|
74 |
+
<li>Conditionally display fields based on cart items and other field(s) values.</li>
|
75 |
+
<li>Add an extra cost to the cart total based on field selection.</li>
|
76 |
+
<li>Custom validation rules using RegEx.</li>
|
77 |
+
<li>Option to add more sections in addition to the core sections (billing, shipping and additional) in checkout page.</li>
|
78 |
+
</ul>
|
79 |
+
</td>
|
80 |
+
<td>
|
81 |
+
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/">
|
82 |
+
<img src="<?php echo THWCFD_ASSETS_URL ?>/css/upgrade-btn.png" />
|
83 |
+
</a>
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
</table>
|
87 |
+
</div>
|
88 |
+
</div>
|
89 |
+
<?php
|
90 |
+
}
|
91 |
+
|
92 |
+
private function output_review_request_link(){
|
93 |
+
?>
|
94 |
+
<p>If you like our <strong>Checkout Field Editor</strong> plugin please leave us a <a href="https://wordpress.org/support/plugin/woo-checkout-field-editor-pro/reviews?rate=5#new-post" target="_blank" aria-label="five star" data-rated="Thanks :)">★★★★★</a> rating. A huge thanks in advance!</p>
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
|
98 |
+
public function output_settings(){
|
99 |
+
$this->output_premium_version_notice();
|
100 |
+
$this->output_review_request_link();
|
101 |
+
|
102 |
+
$tab = $this->get_current_tab();
|
103 |
+
if($tab === 'fields'){
|
104 |
+
$general_settings = THWCFD_Settings_General::instance();
|
105 |
+
$general_settings->render_page();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
public function get_current_tab(){
|
110 |
+
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
endif;
|
115 |
+
|
classes/class-thwcfd-utils.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Utils functions for woo checkout field editor.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.3.6
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
|
14 |
+
if(!class_exists('THWCFD_Utils')):
|
15 |
+
|
16 |
+
class THWCFD_Utils {
|
17 |
+
public function __construct() {
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function is_address_field($name){
|
22 |
+
$address_fields = array(
|
23 |
+
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
24 |
+
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
25 |
+
);
|
26 |
+
|
27 |
+
if($name && in_array($name, $address_fields)){
|
28 |
+
return true;
|
29 |
+
}
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
public static function is_default_field($name){
|
34 |
+
$default_fields = array(
|
35 |
+
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
36 |
+
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
37 |
+
'order_comments'
|
38 |
+
);
|
39 |
+
|
40 |
+
if($name && in_array($name, $default_fields)){
|
41 |
+
return true;
|
42 |
+
}
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
public static function is_default_field_name($field_name){
|
47 |
+
$default_fields = array(
|
48 |
+
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2',
|
49 |
+
'billing_city', 'billing_state', 'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
50 |
+
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2',
|
51 |
+
'shipping_city', 'shipping_state', 'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
52 |
+
);
|
53 |
+
|
54 |
+
if($name && in_array($name, $default_fields)){
|
55 |
+
return true;
|
56 |
+
}
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
public static function is_reserved_field_name( $field_name ){
|
61 |
+
$reserved_names = array(
|
62 |
+
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2',
|
63 |
+
'billing_city', 'billing_state', 'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
64 |
+
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2',
|
65 |
+
'shipping_city', 'shipping_state', 'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
66 |
+
);
|
67 |
+
|
68 |
+
if($name && in_array($name, $reserved_names)){
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
public static function is_valid_field($field){
|
75 |
+
$return = false;
|
76 |
+
if(is_array($field)){
|
77 |
+
$return = true;
|
78 |
+
}
|
79 |
+
return $return;
|
80 |
+
}
|
81 |
+
|
82 |
+
public static function is_enabled($field){
|
83 |
+
$enabled = false;
|
84 |
+
if(is_array($field)){
|
85 |
+
$enabled = isset($field['enabled']) && $field['enabled'] == false ? false : true;
|
86 |
+
}
|
87 |
+
return $enabled;
|
88 |
+
}
|
89 |
+
|
90 |
+
public static function is_custom_field($field){
|
91 |
+
$return = false;
|
92 |
+
if(isset($field['custom']) && $field['custom']){
|
93 |
+
$return = true;
|
94 |
+
}
|
95 |
+
return $return;
|
96 |
+
}
|
97 |
+
|
98 |
+
public static function is_active_custom_field($field){
|
99 |
+
$return = false;
|
100 |
+
if(self::is_valid_field($field) && self::is_enabled($field) && self::is_custom_field($field)){
|
101 |
+
$return = true;
|
102 |
+
}
|
103 |
+
return $return;
|
104 |
+
}
|
105 |
+
|
106 |
+
public static function update_fields($key, $fields){
|
107 |
+
$result = update_option('wc_fields_' . $key, $fields);
|
108 |
+
return $result;
|
109 |
+
}
|
110 |
+
|
111 |
+
public static function get_fields($key){
|
112 |
+
$fields = get_option('wc_fields_'. $key, array());
|
113 |
+
$fields = is_array($fields) ? array_filter($fields) : array();
|
114 |
+
|
115 |
+
if(empty($fields) || sizeof($fields) == 0){
|
116 |
+
if($key === 'billing' || $key === 'shipping'){
|
117 |
+
$fields = WC()->countries->get_address_fields(WC()->countries->get_base_country(), $key . '_');
|
118 |
+
|
119 |
+
} else if($key === 'additional'){
|
120 |
+
$fields = array(
|
121 |
+
'order_comments' => array(
|
122 |
+
'type' => 'textarea',
|
123 |
+
'class' => array('notes'),
|
124 |
+
'label' => __('Order Notes', 'woocommerce'),
|
125 |
+
'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
|
126 |
+
)
|
127 |
+
);
|
128 |
+
}
|
129 |
+
$fields = self::prepare_default_fields($fields);
|
130 |
+
}
|
131 |
+
return $fields;
|
132 |
+
}
|
133 |
+
|
134 |
+
private static function prepare_default_fields($fields){
|
135 |
+
foreach ($fields as $key => $value) {
|
136 |
+
$fields[$key]['custom'] = 0;
|
137 |
+
$fields[$key]['enabled'] = 1;
|
138 |
+
$fields[$key]['show_in_email'] = 1;
|
139 |
+
$fields[$key]['show_in_order'] = 1;
|
140 |
+
}
|
141 |
+
return $fields;
|
142 |
+
}
|
143 |
+
|
144 |
+
public static function get_checkout_fields($order=false){
|
145 |
+
$fields = array();
|
146 |
+
$needs_shipping = true;
|
147 |
+
|
148 |
+
if($order){
|
149 |
+
$needs_shipping = !wc_ship_to_billing_address_only() && $order->needs_shipping_address() ? true : false;
|
150 |
+
}
|
151 |
+
|
152 |
+
if($needs_shipping){
|
153 |
+
$fields = array_merge(self::get_fields('billing'), self::get_fields('shipping'), self::get_fields('additional'));
|
154 |
+
}else{
|
155 |
+
$fields = array_merge(self::get_fields('billing'), self::get_fields('additional'));
|
156 |
+
}
|
157 |
+
|
158 |
+
return $fields;
|
159 |
+
}
|
160 |
+
|
161 |
+
public static function prepare_field_options($options){
|
162 |
+
if(is_string($options)){
|
163 |
+
$options = array_map('trim', explode('|', $options));
|
164 |
+
}
|
165 |
+
return is_array($options) ? $options : array();
|
166 |
+
}
|
167 |
+
|
168 |
+
public static function prepare_options_array($options_json){
|
169 |
+
$options_json = rawurldecode($options_json);
|
170 |
+
$options_arr = json_decode($options_json, true);
|
171 |
+
$options = array();
|
172 |
+
|
173 |
+
if($options_arr){
|
174 |
+
foreach($options_arr as $option){
|
175 |
+
$okey = isset($option['key']) ? $option['key'] : '';
|
176 |
+
$otext = isset($option['text']) ? $option['text'] : '';
|
177 |
+
$okey = $okey ? $okey : $otext;
|
178 |
+
|
179 |
+
if($okey && $otext){
|
180 |
+
$options[$okey] = $otext;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
return $options;
|
185 |
+
}
|
186 |
+
|
187 |
+
public static function prepare_options_json($options){
|
188 |
+
$options_json = '';
|
189 |
+
if(is_array($options) && !empty($options)){
|
190 |
+
$options_arr = array();
|
191 |
+
|
192 |
+
foreach($options as $okey => $otext){
|
193 |
+
$okey = $okey ? $okey : $otext;
|
194 |
+
|
195 |
+
if($okey && $otext){
|
196 |
+
array_push($options_arr, array("key" => $okey, "text" => $otext));
|
197 |
+
//array_push($options_arr, array("key" => esc_attr($okey), "text" => esc_attr($otext)));
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
$options_json = json_encode($options_arr);
|
202 |
+
$options_json = rawurlencode($options_json);
|
203 |
+
}
|
204 |
+
return $options_json;
|
205 |
+
}
|
206 |
+
|
207 |
+
public static function prepare_field_priority($fields, $order, $new=false){
|
208 |
+
$priority = '';
|
209 |
+
if(!$new){
|
210 |
+
$priority = is_numeric($order) ? ($order+1)*10 : false;
|
211 |
+
}
|
212 |
+
|
213 |
+
if(!$priority){
|
214 |
+
$max_priority = self::get_max_priority($fields);
|
215 |
+
$priority = is_numeric($max_priority) ? $max_priority+10 : false;
|
216 |
+
}
|
217 |
+
return $priority;
|
218 |
+
}
|
219 |
+
|
220 |
+
private static function get_max_priority($fields){
|
221 |
+
$max_priority = 0;
|
222 |
+
if(is_array($fields)){
|
223 |
+
foreach ($fields as $key => $value) {
|
224 |
+
$priority = isset($value['priority']) ? $value['priority'] : false;
|
225 |
+
$max_priority = is_numeric($priority) && $priority > $max_priority ? $priority : $max_priority;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
return $max_priority;
|
229 |
+
}
|
230 |
+
|
231 |
+
public static function sort_fields($fields){
|
232 |
+
uasort($fields, 'wc_checkout_fields_uasort_comparison');
|
233 |
+
return $fields;
|
234 |
+
}
|
235 |
+
|
236 |
+
public static function sort_fields_by_order($a, $b){
|
237 |
+
if(!isset($a['order']) || $a['order'] == $b['order']){
|
238 |
+
return 0;
|
239 |
+
}
|
240 |
+
return ($a['order'] < $b['order']) ? -1 : 1;
|
241 |
+
}
|
242 |
+
|
243 |
+
public static function get_order_id($order){
|
244 |
+
$order_id = false;
|
245 |
+
if(self::woo_version_check()){
|
246 |
+
$order_id = $order->get_id();
|
247 |
+
}else{
|
248 |
+
$order_id = $order->id;
|
249 |
+
}
|
250 |
+
return $order_id;
|
251 |
+
}
|
252 |
+
|
253 |
+
public static function woo_version_check( $version = '3.0' ) {
|
254 |
+
if(function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
|
255 |
+
global $woocommerce;
|
256 |
+
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
257 |
+
return true;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
return false;
|
261 |
+
}
|
262 |
+
|
263 |
+
public static function wcfd_version_check( $version = '1.3.6' ) {
|
264 |
+
if(THWCFD_VERSION && version_compare( THWCFD_VERSION, $version, ">=" ) ) {
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
|
270 |
+
public function is_blank($value) {
|
271 |
+
return empty($value) && !is_numeric($value);
|
272 |
+
}
|
273 |
+
|
274 |
+
/***********************************
|
275 |
+
----- i18n functions - START ------
|
276 |
+
***********************************/
|
277 |
+
public static function t($text){
|
278 |
+
if(!empty($text)){
|
279 |
+
$otext = $text;
|
280 |
+
$text = __($text, 'woo-checkout-field-editor-pro');
|
281 |
+
if($text === $otext){
|
282 |
+
$text = __($text, 'woocommerce');
|
283 |
+
}
|
284 |
+
}
|
285 |
+
return $text;
|
286 |
+
}
|
287 |
+
|
288 |
+
public static function et($text){
|
289 |
+
if(!empty($text)){
|
290 |
+
$otext = $text;
|
291 |
+
$text = __($text, 'woo-checkout-field-editor-pro');
|
292 |
+
if($text === $otext){
|
293 |
+
$text = __($text, 'woocommerce');
|
294 |
+
}
|
295 |
+
}
|
296 |
+
echo $text;
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
endif;
|
classes/class-thwcfd.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The file that defines the core plugin class.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.3.6
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
|
14 |
+
if(!class_exists('THWCFD')):
|
15 |
+
|
16 |
+
class THWCFD {
|
17 |
+
const TEXT_DOMAIN = 'woo-checkout-field-editor-pro';
|
18 |
+
|
19 |
+
public function __construct() {
|
20 |
+
$this->load_dependencies();
|
21 |
+
$this->set_locale();
|
22 |
+
$this->define_admin_hooks();
|
23 |
+
$this->define_public_hooks();
|
24 |
+
}
|
25 |
+
|
26 |
+
private function load_dependencies() {
|
27 |
+
if(!function_exists('is_plugin_active')){
|
28 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
29 |
+
}
|
30 |
+
require_once THWCFD_PATH . 'classes/class-thwcfd-utils.php';
|
31 |
+
require_once THWCFD_PATH . 'classes/class-thwcfd-settings.php';
|
32 |
+
require_once THWCFD_PATH . 'classes/class-thwcfd-settings-general.php';
|
33 |
+
require_once THWCFD_PATH . 'classes/class-thwcfd-checkout.php';
|
34 |
+
}
|
35 |
+
|
36 |
+
private function set_locale() {
|
37 |
+
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
38 |
+
}
|
39 |
+
|
40 |
+
public function load_plugin_textdomain(){
|
41 |
+
$locale = apply_filters('plugin_locale', get_locale(), self::TEXT_DOMAIN);
|
42 |
+
|
43 |
+
load_textdomain(self::TEXT_DOMAIN, WP_LANG_DIR.'/woo-checkout-field-editor-pro/'.self::TEXT_DOMAIN.'-'.$locale.'.mo');
|
44 |
+
load_plugin_textdomain(self::TEXT_DOMAIN, false, dirname(THWCFD_BASE_NAME) . '/languages/');
|
45 |
+
}
|
46 |
+
|
47 |
+
private function define_admin_hooks() {
|
48 |
+
$plugin_admin = new THWCFD_Settings();
|
49 |
+
|
50 |
+
add_action('admin_enqueue_scripts', array($plugin_admin, 'enqueue_styles_and_scripts'));
|
51 |
+
add_action('admin_menu', array($plugin_admin, 'admin_menu'));
|
52 |
+
add_filter('woocommerce_screen_ids', array($plugin_admin, 'add_screen_id'));
|
53 |
+
add_filter('plugin_action_links_'.THWCFD_BASE_NAME, array($plugin_admin, 'plugin_action_links'));
|
54 |
+
//add_filter('plugin_row_meta', array($plugin_admin, 'plugin_row_meta'), 10, 2);
|
55 |
+
|
56 |
+
$general_settings = new THWCFD_Settings_General();
|
57 |
+
add_action('after_setup_theme', array($general_settings, 'define_admin_hooks'));
|
58 |
+
}
|
59 |
+
|
60 |
+
private function define_public_hooks() {
|
61 |
+
if(!is_admin() || (defined( 'DOING_AJAX' ) && DOING_AJAX)){
|
62 |
+
$plugin_checkout = new THWCFD_Checkout();
|
63 |
+
add_action('wp_enqueue_scripts', array($plugin_checkout, 'enqueue_styles_and_scripts'));
|
64 |
+
add_action('after_setup_theme', array($plugin_checkout, 'define_public_hooks'));
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
endif;
|
classes/class-wc-checkout-field-editor.php
DELETED
@@ -1,795 +0,0 @@
|
|
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 |
-
public 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_filter('plugin_action_links_'.TH_WCFD_BASE_NAME, array($this, 'add_settings_link'));
|
23 |
-
|
24 |
-
// Show in order details page
|
25 |
-
add_action('woocommerce_admin_order_data_after_order_details', array($this, 'order_data_after_order_details'), 20, 1);
|
26 |
-
add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'order_data_after_billing_address'), 20, 1);
|
27 |
-
add_action('woocommerce_admin_order_data_after_shipping_address', array($this, 'order_data_after_shipping_address'), 20, 1);
|
28 |
-
|
29 |
-
add_action('woocommerce_checkout_update_order_meta', array($this, 'save_data'), 10, 2);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* menu function.
|
34 |
-
*/
|
35 |
-
public function admin_menu() {
|
36 |
-
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Form Designer', 'woo-checkout-field-editor-pro'), __('Checkout Form', 'woo-checkout-field-editor-pro'),
|
37 |
-
'manage_woocommerce', 'checkout_form_designer', array($this, 'the_designer'));
|
38 |
-
|
39 |
-
add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* add_screen_id function.
|
44 |
-
*/
|
45 |
-
public function add_screen_id($ids){
|
46 |
-
$ids[] = 'woocommerce_page_checkout_form_designer';
|
47 |
-
$ids[] = strtolower(__('WooCommerce', 'woo-checkout-field-editor-pro')) .'_page_checkout_form_designer';
|
48 |
-
|
49 |
-
return $ids;
|
50 |
-
}
|
51 |
-
|
52 |
-
public function add_settings_link($links) {
|
53 |
-
$settings_link = '<a href="'.admin_url('admin.php?page=checkout_form_designer').'">'. __('Settings', 'woo-checkout-field-editor-pro') .'</a>';
|
54 |
-
array_unshift($links, $settings_link);
|
55 |
-
return $links;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* scripts function.
|
60 |
-
*/
|
61 |
-
public function enqueue_admin_scripts() {
|
62 |
-
wp_enqueue_style ('thwcfd-style', plugins_url('/assets/css/thwcfd-style.css', dirname(__FILE__)));
|
63 |
-
wp_enqueue_script('thwcfd-admin-script', plugins_url('/assets/js/thwcfd-admin.js', dirname(__FILE__)), array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable',
|
64 |
-
'woocommerce_admin', 'select2', 'jquery-tiptip'), TH_WCFD_VERSION, true);
|
65 |
-
}
|
66 |
-
|
67 |
-
public function output_premium_version_notice(){
|
68 |
-
?>
|
69 |
-
<div id="message" class="wc-connect updated thwcfd-notice">
|
70 |
-
<div class="squeezer">
|
71 |
-
<table>
|
72 |
-
<tr>
|
73 |
-
<td width="70%">
|
74 |
-
<p><strong><i>WooCommerce Checkout Field Editor Pro</i></strong> premium version provides more features to design your checkout page.</p>
|
75 |
-
<ul>
|
76 |
-
<li>17 field types available, (<i>Text, Hidden, Password, Telephone, Email, Number, Textarea, Radio, Checkbox, Checkbox Group, Select, Multi-select, Date Picker, Time Picker, File Upload, Heading, Label</i>).</li>
|
77 |
-
<li>Conditionally display fields based on cart items and other field(s) values.</li>
|
78 |
-
<li>Add an extra cost to the cart total based on field selection.</li>
|
79 |
-
<li>Custom validation rules using RegEx.</li>
|
80 |
-
<li>Option to add more sections in addition to the core sections (billing, shipping and additional) in checkout page.</li>
|
81 |
-
</ul>
|
82 |
-
</td>
|
83 |
-
<td>
|
84 |
-
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/" class="">
|
85 |
-
<img src="<?php echo plugins_url( '../assets/css/upgrade-btn.png', __FILE__ ); ?>" />
|
86 |
-
</a>
|
87 |
-
</td>
|
88 |
-
</tr>
|
89 |
-
</table>
|
90 |
-
</div>
|
91 |
-
</div>
|
92 |
-
<?php
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Reset checkout fields.
|
97 |
-
*/
|
98 |
-
public function reset_checkout_fields() {
|
99 |
-
delete_option('wc_fields_billing');
|
100 |
-
delete_option('wc_fields_shipping');
|
101 |
-
delete_option('wc_fields_additional');
|
102 |
-
echo '<div class="updated"><p>'. __('SUCCESS: Checkout fields successfully reset', 'woo-checkout-field-editor-pro') .'</p></div>';
|
103 |
-
}
|
104 |
-
|
105 |
-
public function is_reserved_field_name( $field_name ){
|
106 |
-
if($field_name && in_array($field_name, array(
|
107 |
-
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
108 |
-
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
109 |
-
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state',
|
110 |
-
'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
111 |
-
))){
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
return false;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function is_default_field_name($field_name){
|
118 |
-
if($field_name && in_array($field_name, array(
|
119 |
-
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
120 |
-
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
121 |
-
'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state',
|
122 |
-
'shipping_country', 'shipping_postcode', 'customer_note', 'order_comments'
|
123 |
-
))){
|
124 |
-
return true;
|
125 |
-
}
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
public function is_valid_field($field){
|
130 |
-
$return = false;
|
131 |
-
if(is_array($field)){
|
132 |
-
$return = true;
|
133 |
-
}
|
134 |
-
return $return;
|
135 |
-
}
|
136 |
-
|
137 |
-
public function is_enabled($field){
|
138 |
-
$return = false;
|
139 |
-
if(isset($field['enabled']) && $field['enabled']){
|
140 |
-
$return = true;
|
141 |
-
}
|
142 |
-
return $return;
|
143 |
-
}
|
144 |
-
|
145 |
-
public function is_custom_field($field){
|
146 |
-
$return = false;
|
147 |
-
if(isset($field['custom']) && $field['custom']){
|
148 |
-
$return = true;
|
149 |
-
}
|
150 |
-
return $return;
|
151 |
-
}
|
152 |
-
|
153 |
-
public function display_fields_in_admin_order($order, $fields, $prefix_html = ''){
|
154 |
-
if(is_array($fields)){
|
155 |
-
$html = '';
|
156 |
-
|
157 |
-
$order_id = false;
|
158 |
-
if(thwcfd_woocommerce_version_check()){
|
159 |
-
$order_id = $order->get_id();
|
160 |
-
}else{
|
161 |
-
$order_id = $order->id;
|
162 |
-
}
|
163 |
-
|
164 |
-
foreach($fields as $name => $field){
|
165 |
-
if($this->is_valid_field($field) && $this->is_custom_field($field) && $this->is_enabled($field) && $field['show_in_order']){
|
166 |
-
$value = get_post_meta( $order_id, $name, true );
|
167 |
-
if(!empty($value)){
|
168 |
-
$label = !empty($field['label']) ? __( $field['label'], 'woo-checkout-field-editor-pro' ) : $name;
|
169 |
-
$html .= '<p><strong>'. $label .':</strong><br/> '. wptexturize($value) .'</p>';
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
if($html){
|
175 |
-
echo $prefix_html.$html;
|
176 |
-
}
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
public function order_data_after_order_details($order){
|
181 |
-
$fields = $this->get_fields('additional');
|
182 |
-
$this->display_fields_in_admin_order($order, $fields, '<p> </p>');
|
183 |
-
}
|
184 |
-
|
185 |
-
public function order_data_after_billing_address($order){
|
186 |
-
$fields = $this->get_fields('billing');
|
187 |
-
$this->display_fields_in_admin_order($order, $fields, '');
|
188 |
-
}
|
189 |
-
|
190 |
-
public function order_data_after_shipping_address($order){
|
191 |
-
$fields = $this->get_fields('shipping');
|
192 |
-
$this->display_fields_in_admin_order($order, $fields, '');
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Save Data function.
|
197 |
-
*/
|
198 |
-
public function save_data($order_id, $posted){
|
199 |
-
$types = array('billing', 'shipping', 'additional');
|
200 |
-
|
201 |
-
foreach($types as $type){
|
202 |
-
$fields = $this->get_fields($type);
|
203 |
-
|
204 |
-
foreach($fields as $name => $field){
|
205 |
-
if(isset($field['custom']) && $field['custom'] && isset($posted[$name])){
|
206 |
-
$value = wc_clean($posted[$name]);
|
207 |
-
if($value){
|
208 |
-
update_post_meta($order_id, $name, $value);
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
public static function get_fields($key){
|
216 |
-
$fields = get_option('wc_fields_'. $key, array());
|
217 |
-
$fields = is_array($fields) ? array_filter($fields) : array();
|
218 |
-
|
219 |
-
if(empty($fields) || sizeof($fields) == 0){
|
220 |
-
if($key === 'billing' || $key === 'shipping'){
|
221 |
-
$fields = WC()->countries->get_address_fields(WC()->countries->get_base_country(), $key . '_');
|
222 |
-
|
223 |
-
} else if($key === 'additional'){
|
224 |
-
$fields = array(
|
225 |
-
'order_comments' => array(
|
226 |
-
'type' => 'textarea',
|
227 |
-
'class' => array('notes'),
|
228 |
-
'label' => __('Order Notes', 'woocommerce'),
|
229 |
-
'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
|
230 |
-
)
|
231 |
-
);
|
232 |
-
}
|
233 |
-
}
|
234 |
-
return $fields;
|
235 |
-
}
|
236 |
-
|
237 |
-
public function sort_fields_by_order($a, $b){
|
238 |
-
if(!isset($a['order']) || $a['order'] == $b['order']){
|
239 |
-
return 0;
|
240 |
-
}
|
241 |
-
return ($a['order'] < $b['order']) ? -1 : 1;
|
242 |
-
}
|
243 |
-
|
244 |
-
public function get_field_types(){
|
245 |
-
return array(
|
246 |
-
'text' => __('Text', 'woo-checkout-field-editor-pro'),
|
247 |
-
'select' => __('Select', 'woo-checkout-field-editor-pro'),
|
248 |
-
);
|
249 |
-
}
|
250 |
-
|
251 |
-
/*
|
252 |
-
* New field form popup
|
253 |
-
*/
|
254 |
-
public function wcfd_new_field_form_pp(){
|
255 |
-
$field_types = $this->get_field_types();
|
256 |
-
?>
|
257 |
-
<div id="wcfd_new_field_form_pp" title="New Checkout Field" class="wcfd_popup_wrapper">
|
258 |
-
<form>
|
259 |
-
<table>
|
260 |
-
<tr>
|
261 |
-
<td colspan="2" class="err_msgs"></td>
|
262 |
-
</tr>
|
263 |
-
<tr>
|
264 |
-
<td width="40%"><?php _e('Type', 'woo-checkout-field-editor-pro'); ?></td>
|
265 |
-
<td>
|
266 |
-
<select name="ftype" style="width:150px;" onchange="fieldTypeChangeListner(this)">
|
267 |
-
<?php foreach($field_types as $value=>$label){ ?>
|
268 |
-
<option value="<?php echo trim($value); ?>"><?php echo $label; ?></option>
|
269 |
-
<?php } ?>
|
270 |
-
</select>
|
271 |
-
</td>
|
272 |
-
</tr>
|
273 |
-
<tr>
|
274 |
-
<td><?php _e('Name', 'woo-checkout-field-editor-pro'); ?></td>
|
275 |
-
<td><input type="text" name="fname" style="width:250px;"/></td>
|
276 |
-
</tr>
|
277 |
-
<tr>
|
278 |
-
<td><?php _e('Label', 'woo-checkout-field-editor-pro'); ?></td>
|
279 |
-
<td><input type="text" name="flabel" style="width:250px;"/></td>
|
280 |
-
</tr>
|
281 |
-
<tr class="rowPlaceholder">
|
282 |
-
<td><?php _e('Placeholder', 'woo-checkout-field-editor-pro'); ?></td>
|
283 |
-
<td><input type="text" name="fplaceholder" style="width:250px;"/></td>
|
284 |
-
</tr>
|
285 |
-
<tr class="rowOptions">
|
286 |
-
<td><?php _e('Options', 'woo-checkout-field-editor-pro'); ?></td>
|
287 |
-
<td><input type="text" name="foptions" placeholder="<?php _e('Seperate options with pipe', 'woo-checkout-field-editor-pro'); ?>(|)" style="width:250px;"/></td>
|
288 |
-
</tr>
|
289 |
-
<tr class="rowClass">
|
290 |
-
<td><?php _e('Class', 'woo-checkout-field-editor-pro'); ?></td>
|
291 |
-
<td><input type="text" name="fclass" placeholder="<?php _e('Seperate classes with comma', 'woo-checkout-field-editor-pro'); ?>" style="width:250px;"/></td>
|
292 |
-
</tr>
|
293 |
-
<!--<tr class="rowLabelClass">
|
294 |
-
<td>Label Class</td>
|
295 |
-
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
296 |
-
</tr>-->
|
297 |
-
<tr class="rowValidate">
|
298 |
-
<td><?php _e('Validation', 'woo-checkout-field-editor-pro'); ?></td>
|
299 |
-
<td>
|
300 |
-
<select multiple="multiple" name="fvalidate" placeholder="<?php _e('Select validations', 'woo-checkout-field-editor-pro'); ?>" class="thwcfd-enhanced-multi-select"
|
301 |
-
style="width: 250px; height:30px;">
|
302 |
-
<option value="email"><?php _e('Email', 'woo-checkout-field-editor-pro'); ?></option>
|
303 |
-
<option value="phone"><?php _e('Phone', 'woo-checkout-field-editor-pro'); ?></option>
|
304 |
-
<option value="postcode"><?php _e('Postcode', 'woo-checkout-field-editor-pro'); ?></option>
|
305 |
-
<option value="state"><?php _e('State', 'woo-checkout-field-editor-pro'); ?></option>
|
306 |
-
</select>
|
307 |
-
</td>
|
308 |
-
</tr>
|
309 |
-
<tr class="rowRequired">
|
310 |
-
<td> </td>
|
311 |
-
<td>
|
312 |
-
<input type="checkbox" name="frequired" value="yes" checked/>
|
313 |
-
<label><?php _e('Required', 'woo-checkout-field-editor-pro'); ?></label><br/>
|
314 |
-
|
315 |
-
<input type="checkbox" name="fclearRow" value="yes" checked/>
|
316 |
-
<label><?php _e('Clear Row', 'woo-checkout-field-editor-pro'); ?></label><br/>
|
317 |
-
|
318 |
-
<input type="checkbox" name="fenabled" value="yes" checked/>
|
319 |
-
<label><?php _e('Enabled', 'woo-checkout-field-editor-pro'); ?></label>
|
320 |
-
</td>
|
321 |
-
</tr>
|
322 |
-
<tr class="rowShowInEmail">
|
323 |
-
<td> </td>
|
324 |
-
<td>
|
325 |
-
<input type="checkbox" name="fshowinemail" value="email" checked/>
|
326 |
-
<label><?php _e('Display in Emails', 'woo-checkout-field-editor-pro'); ?></label>
|
327 |
-
</td>
|
328 |
-
</tr>
|
329 |
-
<tr class="rowShowInOrder">
|
330 |
-
<td> </td>
|
331 |
-
<td>
|
332 |
-
<input type="checkbox" name="fshowinorder" value="order-review" checked/>
|
333 |
-
<label><?php _e('Display in Order Detail Pages', 'woo-checkout-field-editor-pro'); ?></label>
|
334 |
-
</td>
|
335 |
-
</tr>
|
336 |
-
</table>
|
337 |
-
</form>
|
338 |
-
</div>
|
339 |
-
<?php
|
340 |
-
}
|
341 |
-
|
342 |
-
/*
|
343 |
-
* New field form popup
|
344 |
-
*/
|
345 |
-
public function wcfd_edit_field_form_pp(){
|
346 |
-
$field_types = $this->get_field_types();
|
347 |
-
?>
|
348 |
-
<div id="wcfd_edit_field_form_pp" title="Edit Checkout Field" class="wcfd_popup_wrapper">
|
349 |
-
<form>
|
350 |
-
<table>
|
351 |
-
<tr>
|
352 |
-
<td colspan="2" class="err_msgs"></td>
|
353 |
-
</tr>
|
354 |
-
<tr>
|
355 |
-
<td width="40%"><?php _e('Name', 'woo-checkout-field-editor-pro'); ?></td>
|
356 |
-
<td>
|
357 |
-
<input type="hidden" name="rowId"/>
|
358 |
-
<input type="hidden" name="fname"/>
|
359 |
-
<input type="text" name="fnameNew" style="width:250px;"/>
|
360 |
-
</td>
|
361 |
-
</tr>
|
362 |
-
<tr>
|
363 |
-
<td><?php _e('Type', 'woo-checkout-field-editor-pro'); ?></td>
|
364 |
-
<td>
|
365 |
-
<select name="ftype" style="width:150px;" onchange="fieldTypeChangeListner(this)">
|
366 |
-
<?php foreach($field_types as $value=>$label){ ?>
|
367 |
-
<option value="<?php echo trim($value); ?>"><?php echo $label; ?></option>
|
368 |
-
<?php } ?>
|
369 |
-
</select>
|
370 |
-
</td>
|
371 |
-
</tr>
|
372 |
-
<tr>
|
373 |
-
<td><?php _e('Label', 'woo-checkout-field-editor-pro'); ?></td>
|
374 |
-
<td><input type="text" name="flabel" style="width:250px;"/></td>
|
375 |
-
</tr>
|
376 |
-
<tr class="rowPlaceholder">
|
377 |
-
<td><?php _e('Placeholder', 'woo-checkout-field-editor-pro'); ?></td>
|
378 |
-
<td><input type="text" name="fplaceholder" style="width:250px;"/></td>
|
379 |
-
</tr>
|
380 |
-
<tr class="rowOptions">
|
381 |
-
<td><?php _e('Options', 'woo-checkout-field-editor-pro'); ?></td>
|
382 |
-
<td><input type="text" name="foptions" placeholder="<?php _e('Seperate options with pipe', 'woo-checkout-field-editor-pro'); ?>(|)" style="width:250px;"/></td>
|
383 |
-
</tr>
|
384 |
-
<tr class="rowClass">
|
385 |
-
<td><?php _e('Class', 'woo-checkout-field-editor-pro'); ?></td>
|
386 |
-
<td><input type="text" name="fclass" placeholder="<?php _e('Seperate classes with comma', 'woo-checkout-field-editor-pro'); ?>" style="width:250px;"/></td>
|
387 |
-
</tr>
|
388 |
-
<!--<tr class="rowLabelClass">
|
389 |
-
<td>Label Class</td>
|
390 |
-
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
391 |
-
</tr>-->
|
392 |
-
<tr class="rowValidate">
|
393 |
-
<td>Validation</td>
|
394 |
-
<td>
|
395 |
-
<select multiple="multiple" name="fvalidate" placeholder="<?php _e('Select validations', 'woo-checkout-field-editor-pro'); ?>" class="thwcfd-enhanced-multi-select"
|
396 |
-
style="width: 250px; height:30px;">
|
397 |
-
<option value="email"><?php _e('Email', 'woo-checkout-field-editor-pro'); ?></option>
|
398 |
-
<option value="phone"><?php _e('Phone', 'woo-checkout-field-editor-pro'); ?></option>
|
399 |
-
<option value="postcode"><?php _e('Postcode', 'woo-checkout-field-editor-pro'); ?></option>
|
400 |
-
<option value="state"><?php _e('State', 'woo-checkout-field-editor-pro'); ?></option>
|
401 |
-
</select>
|
402 |
-
</td>
|
403 |
-
</tr>
|
404 |
-
<tr class="rowRequired">
|
405 |
-
<td> </td>
|
406 |
-
<td>
|
407 |
-
<input type="checkbox" name="frequired" value="yes" checked/>
|
408 |
-
<label><?php _e('Required', 'woo-checkout-field-editor-pro'); ?></label><br/>
|
409 |
-
|
410 |
-
<input type="checkbox" name="fclearRow" value="yes" checked/>
|
411 |
-
<label><?php _e('Clear Row', 'woo-checkout-field-editor-pro'); ?></label><br/>
|
412 |
-
|
413 |
-
<input type="checkbox" name="fenabled" value="yes" checked/>
|
414 |
-
<label><?php _e('Enabled', 'woo-checkout-field-editor-pro'); ?></label>
|
415 |
-
</td>
|
416 |
-
</tr>
|
417 |
-
<tr class="rowShowInEmail">
|
418 |
-
<td> </td>
|
419 |
-
<td>
|
420 |
-
<input type="checkbox" name="fshowinemail" value="email" checked/>
|
421 |
-
<label><?php _e('Display in Emails', 'woo-checkout-field-editor-pro'); ?></label>
|
422 |
-
</td>
|
423 |
-
</tr>
|
424 |
-
<tr class="rowShowInOrder">
|
425 |
-
<td> </td>
|
426 |
-
<td>
|
427 |
-
<input type="checkbox" name="fshowinorder" value="order-review" checked/>
|
428 |
-
<label><?php _e('Display in Order Detail Pages', 'woo-checkout-field-editor-pro'); ?></label>
|
429 |
-
</td>
|
430 |
-
</tr>
|
431 |
-
</table>
|
432 |
-
</form>
|
433 |
-
</div>
|
434 |
-
<?php
|
435 |
-
}
|
436 |
-
|
437 |
-
public function render_tabs_and_sections(){
|
438 |
-
$tabs = array( 'fields' => __('Checkout Fields', 'woo-checkout-field-editor-pro') );
|
439 |
-
$tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
440 |
-
|
441 |
-
$sections = ''; $section = '';
|
442 |
-
if($tab === 'fields'){
|
443 |
-
$sections = array( 'billing', 'shipping', 'additional' );
|
444 |
-
$section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
|
445 |
-
}
|
446 |
-
|
447 |
-
echo '<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">';
|
448 |
-
foreach( $tabs as $key => $value ) {
|
449 |
-
$active = ( $key == $tab ) ? 'nav-tab-active' : '';
|
450 |
-
echo '<a class="nav-tab '.$active.'" href="'.admin_url('admin.php?page=checkout_form_designer&tab='.$key).'">'.$value.'</a>';
|
451 |
-
}
|
452 |
-
echo '</h2>';
|
453 |
-
|
454 |
-
if(!empty($sections)){
|
455 |
-
echo '<ul class="thwcfd-sections">';
|
456 |
-
$size = sizeof($sections); $i = 0;
|
457 |
-
foreach( $sections as $key ) {
|
458 |
-
$i++;
|
459 |
-
$active = ( $key == $section ) ? 'current' : '';
|
460 |
-
$url = 'admin.php?page=checkout_form_designer&tab=fields§ion='.$key;
|
461 |
-
echo '<li>';
|
462 |
-
echo '<a href="'.admin_url($url).'" class="'.$active.'" >'.ucwords($key).' '.__('Fields', 'woo-checkout-field-editor-pro').'</a>';
|
463 |
-
echo ($size > $i) ? ' | ' : '';
|
464 |
-
echo '</li>';
|
465 |
-
}
|
466 |
-
echo '</ul>';
|
467 |
-
}
|
468 |
-
|
469 |
-
$this->output_premium_version_notice();
|
470 |
-
}
|
471 |
-
|
472 |
-
public function get_current_tab(){
|
473 |
-
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
474 |
-
}
|
475 |
-
|
476 |
-
public function get_current_section(){
|
477 |
-
$tab = $this->get_current_tab();
|
478 |
-
$section = '';
|
479 |
-
if($tab === 'fields'){
|
480 |
-
$section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
|
481 |
-
}
|
482 |
-
return $section;
|
483 |
-
}
|
484 |
-
|
485 |
-
public function render_checkout_fields_heading_row(){
|
486 |
-
?>
|
487 |
-
<th class="sort"></th>
|
488 |
-
<th class="check-column"><input type="checkbox" style="margin:0px 4px -1px -1px;" onclick="thwcfdSelectAllCheckoutFields(this)"/></th>
|
489 |
-
<th class="name"><?php _e('Name', 'woo-checkout-field-editor-pro'); ?></th>
|
490 |
-
<th class="id"><?php _e('Type', 'woo-checkout-field-editor-pro'); ?></th>
|
491 |
-
<th><?php _e('Label', 'woo-checkout-field-editor-pro'); ?></th>
|
492 |
-
<th><?php _e('Placeholder', 'woo-checkout-field-editor-pro'); ?></th>
|
493 |
-
<th><?php _e('Validation Rules', 'woo-checkout-field-editor-pro'); ?></th>
|
494 |
-
<th class="status"><?php _e('Required', 'woo-checkout-field-editor-pro'); ?></th>
|
495 |
-
<th class="status"><?php _e('Enabled', 'woo-checkout-field-editor-pro'); ?></th>
|
496 |
-
<th class="status"><?php _e('Edit', 'woo-checkout-field-editor-pro'); ?></th>
|
497 |
-
<?php
|
498 |
-
}
|
499 |
-
|
500 |
-
public function render_actions_row($section){
|
501 |
-
?>
|
502 |
-
<th colspan="6">
|
503 |
-
<button type="button" class="button button-primary" onclick="openNewFieldForm('<?php echo $section; ?>')">+ <?php _e( 'Add field', 'woo-checkout-field-editor-pro' ); ?></button>
|
504 |
-
<button type="button" class="button" onclick="removeSelectedFields()"><?php _e( 'Remove', 'woo-checkout-field-editor-pro' ); ?></button>
|
505 |
-
<button type="button" class="button" onclick="enableSelectedFields()"><?php _e( 'Enable', 'woo-checkout-field-editor-pro' ); ?></button>
|
506 |
-
<button type="button" class="button" onclick="disableSelectedFields()"><?php _e( 'Disable', 'woo-checkout-field-editor-pro' ); ?></button>
|
507 |
-
</th>
|
508 |
-
<th colspan="4">
|
509 |
-
<input type="submit" name="save_fields" class="button-primary" value="<?php _e( 'Save changes', 'woo-checkout-field-editor-pro' ) ?>" style="float:right" />
|
510 |
-
<input type="submit" name="reset_fields" class="button" value="<?php _e( 'Reset to default fields', 'woo-checkout-field-editor-pro' ) ?>" style="float:right; margin-right: 5px;"
|
511 |
-
onclick="return confirm('Are you sure you want to reset to default fields? all your changes will be deleted.');"/>
|
512 |
-
</th>
|
513 |
-
<?php
|
514 |
-
}
|
515 |
-
|
516 |
-
public function the_designer() {
|
517 |
-
$tab = $this->get_current_tab();
|
518 |
-
if($tab === 'fields'){
|
519 |
-
$this->checkout_form_field_editor();
|
520 |
-
}
|
521 |
-
}
|
522 |
-
|
523 |
-
public function checkout_form_field_editor() {
|
524 |
-
$section = $this->get_current_section();
|
525 |
-
|
526 |
-
echo '<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>';
|
527 |
-
$this->render_tabs_and_sections();
|
528 |
-
|
529 |
-
if ( isset( $_POST['save_fields'] ) )
|
530 |
-
echo $this->save_options( $section );
|
531 |
-
|
532 |
-
if ( isset( $_POST['reset_fields'] ) )
|
533 |
-
echo $this->reset_checkout_fields();
|
534 |
-
|
535 |
-
global $supress_field_modification;
|
536 |
-
$supress_field_modification = false;
|
537 |
-
?>
|
538 |
-
|
539 |
-
<form method="post" id="wcfd_checkout_fields_form" action="">
|
540 |
-
<table id="wcfd_checkout_fields" class="wc_gateways widefat thpladmin_fields_table" cellspacing="0">
|
541 |
-
<thead>
|
542 |
-
<tr><?php $this->render_actions_row($section); ?></tr>
|
543 |
-
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
544 |
-
</thead>
|
545 |
-
<tfoot>
|
546 |
-
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
547 |
-
<tr><?php $this->render_actions_row($section); ?></tr>
|
548 |
-
</tfoot>
|
549 |
-
<tbody class="ui-sortable">
|
550 |
-
<?php
|
551 |
-
$i=0;
|
552 |
-
foreach( $this->get_fields( $section ) as $name => $options ) :
|
553 |
-
if ( isset( $options['custom'] ) && $options['custom'] == 1 ) {
|
554 |
-
$options['custom'] = '1';
|
555 |
-
} else {
|
556 |
-
$options['custom'] = '0';
|
557 |
-
}
|
558 |
-
|
559 |
-
if ( !isset( $options['label'] ) ) {
|
560 |
-
$options['label'] = '';
|
561 |
-
}
|
562 |
-
|
563 |
-
if ( !isset( $options['placeholder'] ) ) {
|
564 |
-
$options['placeholder'] = '';
|
565 |
-
}
|
566 |
-
|
567 |
-
if( isset( $options['options'] ) && is_array($options['options']) ) {
|
568 |
-
$options['options'] = implode("|", $options['options']);
|
569 |
-
}else{
|
570 |
-
$options['options'] = '';
|
571 |
-
}
|
572 |
-
|
573 |
-
if( isset( $options['class'] ) && is_array($options['class']) ) {
|
574 |
-
$options['class'] = implode(",", $options['class']);
|
575 |
-
}else{
|
576 |
-
$options['class'] = '';
|
577 |
-
}
|
578 |
-
|
579 |
-
if( isset( $options['label_class'] ) && is_array($options['label_class']) ) {
|
580 |
-
$options['label_class'] = implode(",", $options['label_class']);
|
581 |
-
}else{
|
582 |
-
$options['label_class'] = '';
|
583 |
-
}
|
584 |
-
|
585 |
-
if( isset( $options['validate'] ) && is_array($options['validate']) ) {
|
586 |
-
$options['validate'] = implode(",", $options['validate']);
|
587 |
-
}else{
|
588 |
-
$options['validate'] = '';
|
589 |
-
}
|
590 |
-
|
591 |
-
if ( isset( $options['required'] ) && $options['required'] == 1 ) {
|
592 |
-
$options['required'] = '1';
|
593 |
-
} else {
|
594 |
-
$options['required'] = '0';
|
595 |
-
}
|
596 |
-
|
597 |
-
if ( isset( $options['clear'] ) && $options['clear'] == 1 ) {
|
598 |
-
$options['clear'] = '1';
|
599 |
-
} else {
|
600 |
-
$options['clear'] = '0';
|
601 |
-
}
|
602 |
-
|
603 |
-
if ( !isset( $options['enabled'] ) || $options['enabled'] == 1 ) {
|
604 |
-
$options['enabled'] = '1';
|
605 |
-
} else {
|
606 |
-
$options['enabled'] = '0';
|
607 |
-
}
|
608 |
-
|
609 |
-
if ( !isset( $options['type'] ) ) {
|
610 |
-
$options['type'] = 'text';
|
611 |
-
}
|
612 |
-
|
613 |
-
if ( isset( $options['show_in_email'] ) && $options['show_in_email'] == 1 ) {
|
614 |
-
$options['show_in_email'] = '1';
|
615 |
-
} else {
|
616 |
-
$options['show_in_email'] = '0';
|
617 |
-
}
|
618 |
-
|
619 |
-
if ( isset( $options['show_in_order'] ) && $options['show_in_order'] == 1 ) {
|
620 |
-
$options['show_in_order'] = '1';
|
621 |
-
} else {
|
622 |
-
$options['show_in_order'] = '0';
|
623 |
-
}
|
624 |
-
?>
|
625 |
-
<tr class="row_<?php echo $i; echo($options['enabled'] == 1 ? '' : ' thwcfd-disabled') ?>">
|
626 |
-
<td width="1%" class="sort ui-sortable-handle">
|
627 |
-
<input type="hidden" name="f_custom[<?php echo $i; ?>]" class="f_custom" value="<?php echo $options['custom']; ?>" />
|
628 |
-
<input type="hidden" name="f_order[<?php echo $i; ?>]" class="f_order" value="<?php echo $i; ?>" />
|
629 |
-
|
630 |
-
<input type="hidden" name="f_name[<?php echo $i; ?>]" class="f_name" value="<?php echo esc_attr( $name ); ?>" />
|
631 |
-
<input type="hidden" name="f_name_new[<?php echo $i; ?>]" class="f_name_new" value="" />
|
632 |
-
<input type="hidden" name="f_type[<?php echo $i; ?>]" class="f_type" value="<?php echo $options['type']; ?>" />
|
633 |
-
<input type="hidden" name="f_label[<?php echo $i; ?>]" class="f_label" value="<?php echo $options['label']; ?>" />
|
634 |
-
<input type="hidden" name="f_placeholder[<?php echo $i; ?>]" class="f_placeholder" value="<?php echo $options['placeholder']; ?>" />
|
635 |
-
<input type="hidden" name="f_options[<?php echo $i; ?>]" class="f_options" value="<?php echo($options['options']) ?>" />
|
636 |
-
|
637 |
-
<input type="hidden" name="f_class[<?php echo $i; ?>]" class="f_class" value="<?php echo $options['class']; ?>" />
|
638 |
-
<input type="hidden" name="f_label_class[<?php echo $i; ?>]" class="f_label_class" value="<?php echo $options['label_class']; ?>" />
|
639 |
-
|
640 |
-
<input type="hidden" name="f_required[<?php echo $i; ?>]" class="f_required" value="<?php echo($options['required']) ?>" />
|
641 |
-
<input type="hidden" name="f_clear[<?php echo $i; ?>]" class="f_clear" value="<?php echo($options['clear']) ?>" />
|
642 |
-
|
643 |
-
<input type="hidden" name="f_enabled[<?php echo $i; ?>]" class="f_enabled" value="<?php echo($options['enabled']) ?>" />
|
644 |
-
<input type="hidden" name="f_validation[<?php echo $i; ?>]" class="f_validation" value="<?php echo($options['validate']) ?>" />
|
645 |
-
<input type="hidden" name="f_show_in_email[<?php echo $i; ?>]" class="f_show_in_email" value="<?php echo($options['show_in_email']) ?>" />
|
646 |
-
<input type="hidden" name="f_show_in_order[<?php echo $i; ?>]" class="f_show_in_order" value="<?php echo($options['show_in_order']) ?>" />
|
647 |
-
<input type="hidden" name="f_deleted[<?php echo $i; ?>]" class="f_deleted" value="0" />
|
648 |
-
|
649 |
-
<!--$properties = array('type', 'label', 'placeholder', 'class', 'required', 'clear', 'label_class', 'options');-->
|
650 |
-
</td>
|
651 |
-
<td class="td_select"><input type="checkbox" name="select_field"/></td>
|
652 |
-
<td class="td_name"><?php echo esc_attr( $name ); ?></td>
|
653 |
-
<td class="td_type"><?php echo $options['type']; ?></td>
|
654 |
-
<td class="td_label"><?php thwcfd_et($options['label']); ?></td>
|
655 |
-
<td class="td_placeholder"><?php thwcfd_et( $options['placeholder']); ?></td>
|
656 |
-
<td class="td_validate"><?php echo $options['validate']; ?></td>
|
657 |
-
<td class="td_required status"><?php echo($options['required'] == 1 ? '<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>' : '-' ) ?></td>
|
658 |
-
<td class="td_enabled status"><?php echo($options['enabled'] == 1 ? '<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>' : '-' ) ?></td>
|
659 |
-
<td class="td_edit">
|
660 |
-
<button type="button" class="f_edit_btn" <?php echo($options['enabled'] == 1 ? '' : 'disabled') ?>
|
661 |
-
onclick="openEditFieldForm(this,<?php echo $i; ?>)"><?php _e( 'Edit', 'woo-checkout-field-editor-pro' ); ?></button>
|
662 |
-
</td>
|
663 |
-
</tr>
|
664 |
-
<?php $i++; endforeach; ?>
|
665 |
-
</tbody>
|
666 |
-
</table>
|
667 |
-
</form>
|
668 |
-
<?php
|
669 |
-
$this->wcfd_new_field_form_pp();
|
670 |
-
$this->wcfd_edit_field_form_pp();
|
671 |
-
?>
|
672 |
-
</div>
|
673 |
-
<?php
|
674 |
-
}
|
675 |
-
|
676 |
-
public function save_options( $section ) {
|
677 |
-
$o_fields = $this->get_fields( $section );
|
678 |
-
$fields = $o_fields;
|
679 |
-
//$core_fields = array_keys( WC()->countries->get_address_fields( WC()->countries->get_base_country(), $section . '_' ) );
|
680 |
-
//$core_fields[] = 'order_comments';
|
681 |
-
|
682 |
-
$f_order = ! empty( $_POST['f_order'] ) ? $_POST['f_order'] : array();
|
683 |
-
|
684 |
-
$f_names = ! empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
|
685 |
-
$f_names_new = ! empty( $_POST['f_name_new'] ) ? $_POST['f_name_new'] : array();
|
686 |
-
$f_types = ! empty( $_POST['f_type'] ) ? $_POST['f_type'] : array();
|
687 |
-
$f_labels = ! empty( $_POST['f_label'] ) ? $_POST['f_label'] : array();
|
688 |
-
$f_placeholder = ! empty( $_POST['f_placeholder'] ) ? $_POST['f_placeholder'] : array();
|
689 |
-
$f_options = ! empty( $_POST['f_options'] ) ? $_POST['f_options'] : array();
|
690 |
-
|
691 |
-
$f_class = ! empty( $_POST['f_class'] ) ? $_POST['f_class'] : array();
|
692 |
-
$f_label_class = ! empty( $_POST['f_label_class'] ) ? $_POST['f_label_class'] : array();
|
693 |
-
|
694 |
-
$f_required = ! empty( $_POST['f_required'] ) ? $_POST['f_required'] : array();
|
695 |
-
$f_clear = ! empty( $_POST['f_clear'] ) ? $_POST['f_clear'] : array();
|
696 |
-
$f_enabled = ! empty( $_POST['f_enabled'] ) ? $_POST['f_enabled'] : array();
|
697 |
-
|
698 |
-
$f_show_in_email = ! empty( $_POST['f_show_in_email'] ) ? $_POST['f_show_in_email'] : array();
|
699 |
-
$f_show_in_order = ! empty( $_POST['f_show_in_order'] ) ? $_POST['f_show_in_order'] : array();
|
700 |
-
|
701 |
-
$f_validation = ! empty( $_POST['f_validation'] ) ? $_POST['f_validation'] : array();
|
702 |
-
$f_deleted = ! empty( $_POST['f_deleted'] ) ? $_POST['f_deleted'] : array();
|
703 |
-
|
704 |
-
$f_position = ! empty( $_POST['f_position'] ) ? $_POST['f_position'] : array();
|
705 |
-
$f_display_options = ! empty( $_POST['f_display_options'] ) ? $_POST['f_display_options'] : array();
|
706 |
-
$max = max( array_map( 'absint', array_keys( $f_names ) ) );
|
707 |
-
|
708 |
-
for ( $i = 0; $i <= $max; $i ++ ) {
|
709 |
-
$name = empty( $f_names[$i] ) ? '' : urldecode( sanitize_title( wc_clean( stripslashes( $f_names[$i] ) ) ) );
|
710 |
-
$new_name = empty( $f_names_new[$i] ) ? '' : urldecode( sanitize_title( wc_clean( stripslashes( $f_names_new[$i] ) ) ) );
|
711 |
-
$allow_override = apply_filters('thwcfd_allow_default_field_override_'.$new_name, false);
|
712 |
-
|
713 |
-
if(!empty($f_deleted[$i]) && $f_deleted[$i] == 1){
|
714 |
-
unset( $fields[$name] );
|
715 |
-
continue;
|
716 |
-
}
|
717 |
-
|
718 |
-
// Check reserved names
|
719 |
-
if($this->is_reserved_field_name( $new_name ) && !$allow_override){
|
720 |
-
continue;
|
721 |
-
}
|
722 |
-
|
723 |
-
//if update field
|
724 |
-
if( $name && $new_name && $new_name !== $name ){
|
725 |
-
if ( isset( $fields[$name] ) ) {
|
726 |
-
$fields[$new_name] = $fields[$name];
|
727 |
-
} else {
|
728 |
-
$fields[$new_name] = array();
|
729 |
-
}
|
730 |
-
|
731 |
-
unset( $fields[$name] );
|
732 |
-
$name = $new_name;
|
733 |
-
} else {
|
734 |
-
$name = $name ? $name : $new_name;
|
735 |
-
}
|
736 |
-
|
737 |
-
if(!$name){
|
738 |
-
continue;
|
739 |
-
}
|
740 |
-
|
741 |
-
//if new field
|
742 |
-
if ( !isset( $fields[$name] ) ) {
|
743 |
-
$fields[$name] = array();
|
744 |
-
}
|
745 |
-
|
746 |
-
$o_type = isset( $o_fields[$name]['type'] ) ? $o_fields[$name]['type'] : 'text';
|
747 |
-
|
748 |
-
//$o_class = isset( $o_fields[$name]['class'] ) ? $o_fields[$name]['class'] : array();
|
749 |
-
//$classes = array_diff( $o_class, array( 'form-row-first', 'form-row-last', 'form-row-wide' ) );
|
750 |
-
|
751 |
-
$fields[$name]['type'] = empty( $f_types[$i] ) ? $o_type : wc_clean( $f_types[$i] );
|
752 |
-
$fields[$name]['label'] = empty( $f_labels[$i] ) ? '' : wp_kses_post( trim( stripslashes( $f_labels[$i] ) ) );
|
753 |
-
$fields[$name]['placeholder'] = empty( $f_placeholder[$i] ) ? '' : wc_clean( stripslashes( $f_placeholder[$i] ) );
|
754 |
-
$fields[$name]['options'] = empty( $f_options[$i] ) ? array() : array_map( 'wc_clean', explode( '|', trim(stripslashes($f_options[$i])) ) );
|
755 |
-
|
756 |
-
$fields[$name]['class'] = empty( $f_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_class[$i] ) );
|
757 |
-
$fields[$name]['label_class'] = empty( $f_label_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_label_class[$i] ) );
|
758 |
-
|
759 |
-
$fields[$name]['required'] = empty( $f_required[$i] ) ? false : true;
|
760 |
-
$fields[$name]['clear'] = empty( $f_clear[$i] ) ? false : true;
|
761 |
-
|
762 |
-
$fields[$name]['enabled'] = empty( $f_enabled[$i] ) ? false : true;
|
763 |
-
$fields[$name]['order'] = isset($f_order[$i]) && is_numeric($f_order[$i]) ? wc_clean( $f_order[$i] ) : '';
|
764 |
-
|
765 |
-
if (!empty( $fields[$name]['options'] )) {
|
766 |
-
$fields[$name]['options'] = array_combine( $fields[$name]['options'], $fields[$name]['options'] );
|
767 |
-
}
|
768 |
-
|
769 |
-
if (!in_array( $name, $this->locale_fields ) || apply_filters('thwcfd_allow_address_field_validation_override', false, $name)){
|
770 |
-
$fields[$name]['validate'] = empty( $f_validation[$i] ) ? array() : explode( ',', $f_validation[$i] );
|
771 |
-
}
|
772 |
-
|
773 |
-
if (!$this->is_default_field_name( $name )){
|
774 |
-
$fields[$name]['custom'] = true;
|
775 |
-
$fields[$name]['show_in_email'] = empty( $f_show_in_email[$i] ) ? false : true;
|
776 |
-
$fields[$name]['show_in_order'] = empty( $f_show_in_order[$i] ) ? false : true;
|
777 |
-
} else {
|
778 |
-
$fields[$name]['custom'] = false;
|
779 |
-
}
|
780 |
-
|
781 |
-
//$fields[$name]['label'] = __($fields[$name]['label'], 'woocommerce');
|
782 |
-
//$fields[$name]['placeholder'] = __($fields[$name]['placeholder'], 'woocommerce');
|
783 |
-
}
|
784 |
-
|
785 |
-
uasort( $fields, array( $this, 'sort_fields_by_order' ) );
|
786 |
-
$result = update_option( 'wc_fields_' . $section, $fields );
|
787 |
-
|
788 |
-
if ( $result == true ) {
|
789 |
-
echo '<div class="updated"><p>' . __( 'Your changes were saved.', 'woo-checkout-field-editor-pro' ) . '</p></div>';
|
790 |
-
} else {
|
791 |
-
echo '<div class="error"><p> ' . __( 'Your changes were not saved due to an error (or you made none!).', 'woo-checkout-field-editor-pro' ) . '</p></div>';
|
792 |
-
}
|
793 |
-
}
|
794 |
-
|
795 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
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: 4.
|
6 |
Tested up to: 5.2.2
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,28 +12,35 @@ Checkout Field Editor (Checkout Manager) for WooCommerce - The best WooCommerce
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
=
|
16 |
If you are wondering how to add custom field in WooCommerce checkout page, you are at the right place. Checkout Field Editor for WooCommerce 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 |
-
=
|
19 |
-
*
|
20 |
-
*
|
21 |
-
* Available field types are
|
22 |
-
*
|
23 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
*
|
26 |
-
*
|
27 |
|
28 |
-
=
|
29 |
Check out the premium version of Checkout Field Editor for WooCommerce - 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 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
|
|
37 |
<ul>
|
38 |
<li><strong>17 field types are available:</strong> In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
|
39 |
<p>Available field types:</p>
|
@@ -82,13 +89,12 @@ Check out the premium version of Checkout Field Editor for WooCommerce - The bes
|
|
82 |
<li><strong>Edit section(s) properties:</strong> Edit custom added section(s) label and display position.</li>
|
83 |
<li><strong>Delete section(s):</strong> Delete custom added section(s).</li>
|
84 |
</ul>
|
85 |
-
</blockquote>
|
86 |
|
87 |
== Installation ==
|
88 |
= Minimum Requirements =
|
89 |
* WooCommerce 3.0 or greater
|
90 |
-
* WordPress 4.
|
91 |
-
* PHP version 5.
|
92 |
* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
|
93 |
|
94 |
= Automatic installation =
|
@@ -143,6 +149,9 @@ Yes. There is a button 'reset to default fields' to go back to the WooCommerce d
|
|
143 |
8. Newly added field
|
144 |
|
145 |
== Changelog ==
|
|
|
|
|
|
|
146 |
= 1.3.5 =
|
147 |
* WooCommerce compatible version updated.
|
148 |
|
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: 4.9
|
6 |
Tested up to: 5.2.2
|
7 |
+
Stable tag: 1.3.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
= Checkout Field Editor for WooCommerce =
|
16 |
If you are wondering how to add custom field in WooCommerce checkout page, you are at the right place. Checkout Field Editor for WooCommerce 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 Version Features =
|
19 |
+
* **Add new custom field(s).** 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 |
+
* **Edit field(s).** 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
|
22 |
+
* Input Text
|
23 |
+
* Password
|
24 |
+
* Email
|
25 |
+
* Phone
|
26 |
+
* Select
|
27 |
+
* Textarea
|
28 |
+
* Radio
|
29 |
+
* **Display in Order Details page and Email.** 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 available in both the ‘New Field’ and ‘Edit Field’ forms.
|
30 |
+
* **Remove field(s).** 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.
|
31 |
* <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.
|
32 |
+
* **Change checkout fields order.** You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
|
33 |
+
* **Reset to default field set.** You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
|
34 |
|
35 |
+
= Premium Version Demos =
|
36 |
Check out the premium version of Checkout Field Editor for WooCommerce - 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.
|
|
|
37 |
|
38 |
+
[Live Demo - Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
39 |
+
[Live Demo - Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
40 |
|
41 |
+
[Buy Now!](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
42 |
+
|
43 |
+
= Premium Version Features =
|
44 |
<ul>
|
45 |
<li><strong>17 field types are available:</strong> In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
|
46 |
<p>Available field types:</p>
|
89 |
<li><strong>Edit section(s) properties:</strong> Edit custom added section(s) label and display position.</li>
|
90 |
<li><strong>Delete section(s):</strong> Delete custom added section(s).</li>
|
91 |
</ul>
|
|
|
92 |
|
93 |
== Installation ==
|
94 |
= Minimum Requirements =
|
95 |
* WooCommerce 3.0 or greater
|
96 |
+
* WordPress 4.9 or greater
|
97 |
+
* PHP version 5.6 or greater (PHP 7.2 or greater is recommended)
|
98 |
* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
|
99 |
|
100 |
= Automatic installation =
|
149 |
8. Newly added field
|
150 |
|
151 |
== Changelog ==
|
152 |
+
= 1.3.6 =
|
153 |
+
* New field types added (Textarea, Radio, Email, Phone, Password).
|
154 |
+
|
155 |
= 1.3.5 =
|
156 |
* WooCommerce compatible version updated.
|
157 |
|