Version Description
- Fix: php error
Download this release
Release Info
Developer | quadlayers |
Plugin | WooCommerce Checkout Manager |
Version | 5.1.2 |
Comparing to | |
See all releases |
Code changes from version 5.1.1 to 5.1.2
- assets/less/wooccm-admin.less +313 -0
- assets/less/wooccm.less +157 -0
- includes/class-wooccm-compatibility.php +7 -3
- includes/controller/class-wooccm-checkout.php +6 -0
- includes/controller/class-wooccm-field-billing.php +15 -75
- includes/controller/class-wooccm-field-shipping.php +2 -35
- includes/controller/class-wooccm-field.php +58 -52
- includes/model/class-wooccm-field.php +15 -6
- includes/model/class-wooccm-model.php +14 -23
- includes/view/backend/pages/parts/loop.php +1 -1
- includes/view/frontend/class-wooccm-fields-handler.php +9 -6
- includes/view/frontend/class-wooccm-fields-register.php +31 -0
- pending +1 -0
- readme.txt +4 -1
- templates/order/order-custom-fields.php +9 -9
- woocommerce-checkout-manager.php +2 -2
assets/less/wooccm-admin.less
ADDED
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.select2-container {
|
2 |
+
z-index: 9999999;
|
3 |
+
|
4 |
+
.select2-selection--single,
|
5 |
+
.select2-selection--single .select2-selection__rendered,
|
6 |
+
.select2-selection--single .select2-selection__arrow {
|
7 |
+
height: 30px!important;
|
8 |
+
line-height: 30px!important;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
.wooccm-premium {
|
13 |
+
opacity: 0.5;
|
14 |
+
pointer-events: none;
|
15 |
+
|
16 |
+
/* .description {
|
17 |
+
&.premium {
|
18 |
+
//display: none;
|
19 |
+
}
|
20 |
+
|
21 |
+
&.hidden {
|
22 |
+
//display: none;
|
23 |
+
}
|
24 |
+
}*/
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
.button {
|
29 |
+
&.fileinput-button {
|
30 |
+
position: relative;
|
31 |
+
overflow: hidden!important;
|
32 |
+
|
33 |
+
input {
|
34 |
+
position: absolute;
|
35 |
+
top: 0;
|
36 |
+
right: 0;
|
37 |
+
margin: 0;
|
38 |
+
opacity: 0;
|
39 |
+
-ms-filter:'alpha(opacity=0)';
|
40 |
+
font-size: 200px;
|
41 |
+
direction: ltr;
|
42 |
+
cursor: pointer;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
table {
|
48 |
+
|
49 |
+
&.wc_gateways {
|
50 |
+
|
51 |
+
> tbody {
|
52 |
+
|
53 |
+
> tr {
|
54 |
+
> td {
|
55 |
+
|
56 |
+
select {
|
57 |
+
line-height: 1!important;
|
58 |
+
}
|
59 |
+
|
60 |
+
&.label {
|
61 |
+
font-weight: 600;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
&.wooccm-enhanced-options {
|
70 |
+
border: none;
|
71 |
+
box-shadow: none;
|
72 |
+
|
73 |
+
> thead {
|
74 |
+
> th {
|
75 |
+
.woocommerce-help-tip {
|
76 |
+
margin: -1px 0 0 0.25em;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
> tbody {
|
82 |
+
> tr {
|
83 |
+
> td {
|
84 |
+
input.label {
|
85 |
+
width: 100%;
|
86 |
+
}
|
87 |
+
select.add-price-type {
|
88 |
+
margin: 0 0 0 10px;
|
89 |
+
}
|
90 |
+
input.check {
|
91 |
+
margin: 0 9px;
|
92 |
+
}
|
93 |
+
|
94 |
+
&.sort .wc-item-reorder-nav {
|
95 |
+
width: auto;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
#wooccm_modal {
|
104 |
+
|
105 |
+
&.processing {
|
106 |
+
pointer-events: none;
|
107 |
+
&:before {
|
108 |
+
content: '';
|
109 |
+
position: absolute;
|
110 |
+
top:0; bottom: 0; left: 0; right: 0;
|
111 |
+
background-color: #ffffff;
|
112 |
+
z-index: 99999999;
|
113 |
+
opacity: 0.8;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
select {
|
118 |
+
min-height: 30px;
|
119 |
+
}
|
120 |
+
|
121 |
+
.form-field {
|
122 |
+
.wrap {
|
123 |
+
padding: 0;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
.attachment-info {
|
128 |
+
.details,
|
129 |
+
.settings {
|
130 |
+
width: 100%;
|
131 |
+
}
|
132 |
+
|
133 |
+
.woocommerce_options_panel label,
|
134 |
+
.woocommerce_options_panel legend {
|
135 |
+
width: 75px;
|
136 |
+
margin: 0 0 0 -90px;
|
137 |
+
font-weight: 600;
|
138 |
+
}
|
139 |
+
|
140 |
+
.woocommerce_options_panel fieldset.form-field,
|
141 |
+
.woocommerce_options_panel p.form-field {
|
142 |
+
padding: 0 20px 0 92px!important;
|
143 |
+
}
|
144 |
+
|
145 |
+
.woocommerce_options_panel input[type=email],
|
146 |
+
.woocommerce_options_panel input[type=number],
|
147 |
+
.woocommerce_options_panel input[type=password],
|
148 |
+
.woocommerce_options_panel input[type=text],
|
149 |
+
.woocommerce_options_panel select,
|
150 |
+
.woocommerce_options_panel .select2-container {
|
151 |
+
width: 100%!important;
|
152 |
+
}
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
#woocommerce-product-data {
|
157 |
+
|
158 |
+
.woocommerce_options_panel {
|
159 |
+
width: 100%;
|
160 |
+
|
161 |
+
.premium {
|
162 |
+
display: block;
|
163 |
+
clear: both;
|
164 |
+
}
|
165 |
+
|
166 |
+
/* input,
|
167 |
+
select,
|
168 |
+
textarea {
|
169 |
+
margin: 0;
|
170 |
+
}*/
|
171 |
+
|
172 |
+
.woocommerce-help-tip {
|
173 |
+
margin: 0 0 0 0.5em;
|
174 |
+
}
|
175 |
+
|
176 |
+
.select2-container {
|
177 |
+
width: 50%!important;
|
178 |
+
line-height: 16px;
|
179 |
+
|
180 |
+
.select2-selection {
|
181 |
+
box-shadow: none;
|
182 |
+
border-radius: 3px;
|
183 |
+
padding: 0 24px 0 8px;
|
184 |
+
}
|
185 |
+
|
186 |
+
.select2-selection--multiple {
|
187 |
+
line-height: 16px;
|
188 |
+
min-height: 30px;
|
189 |
+
}
|
190 |
+
|
191 |
+
@media only screen and (max-width: 1280px) {
|
192 |
+
width: 80%!important;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
.select2-container--default {
|
197 |
+
|
198 |
+
.select2-selection--multiple .select2-selection__rendered li {
|
199 |
+
margin: 3px 3px 0 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
&.select2-container--focus .select2-selection--multiple {
|
203 |
+
border-color: #5b9dd9!important;
|
204 |
+
box-shadow: 0 0 2px rgba(30, 140, 190, 0.8)!important;
|
205 |
+
outline: 2px solid transparent!important;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
#wooccm-order-files {
|
215 |
+
|
216 |
+
.inside {
|
217 |
+
margin: 0;
|
218 |
+
padding: 0;
|
219 |
+
background: #fefefe;
|
220 |
+
display: block!important;
|
221 |
+
}
|
222 |
+
|
223 |
+
.handlediv,
|
224 |
+
.hndle {
|
225 |
+
display: none;
|
226 |
+
}
|
227 |
+
|
228 |
+
.wooccm_upload_results {
|
229 |
+
display: inline-block;
|
230 |
+
margin: 0 10px;
|
231 |
+
}
|
232 |
+
|
233 |
+
.wooccm_order_attachments_wrapper {
|
234 |
+
margin: 0;
|
235 |
+
overflow-x: auto;
|
236 |
+
|
237 |
+
table {
|
238 |
+
&.wooccm_order_attachments {
|
239 |
+
width: 100%;
|
240 |
+
background: #fff;
|
241 |
+
|
242 |
+
thead th:first-child {
|
243 |
+
padding-left: 2em;
|
244 |
+
}
|
245 |
+
|
246 |
+
thead th.sortable {
|
247 |
+
cursor: pointer;
|
248 |
+
}
|
249 |
+
|
250 |
+
.item {
|
251 |
+
min-width: 200px;
|
252 |
+
}
|
253 |
+
|
254 |
+
thead th {
|
255 |
+
text-align: left;
|
256 |
+
padding: 1em;
|
257 |
+
font-weight: 400;
|
258 |
+
color: #999;
|
259 |
+
background: #f8f8f8;
|
260 |
+
user-select: none;
|
261 |
+
}
|
262 |
+
|
263 |
+
tbody#order_line_items tr:first-child td {
|
264 |
+
border-top: none;
|
265 |
+
}
|
266 |
+
|
267 |
+
tbody tr:last-child td {
|
268 |
+
border-bottom: 1px solid #dfdfdf;
|
269 |
+
}
|
270 |
+
|
271 |
+
td.thumb {
|
272 |
+
text-align: left;
|
273 |
+
width: 38px;
|
274 |
+
padding-bottom: 1.5em;
|
275 |
+
|
276 |
+
.wc-order-item-thumbnail {
|
277 |
+
width: 38px;
|
278 |
+
height: 38px;
|
279 |
+
border: 2px solid #e8e8e8;
|
280 |
+
background: #f8f8f8;
|
281 |
+
color: #ccc;
|
282 |
+
position: relative;
|
283 |
+
font-size: 21px;
|
284 |
+
display: block;
|
285 |
+
text-align: center;
|
286 |
+
}
|
287 |
+
|
288 |
+
}
|
289 |
+
tbody th:first-child,
|
290 |
+
td:first-child {
|
291 |
+
padding-left: 2em;
|
292 |
+
}
|
293 |
+
tbody th,
|
294 |
+
td {
|
295 |
+
padding: 1.5em 1em 1em;
|
296 |
+
text-align: left;
|
297 |
+
line-height: 1.5em;
|
298 |
+
vertical-align: top;
|
299 |
+
border-bottom: 1px solid #f8f8f8;
|
300 |
+
}
|
301 |
+
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
.wc-order-data-row {
|
307 |
+
border-bottom: 1px solid #dfdfdf;
|
308 |
+
padding: 1.5em 2em;
|
309 |
+
background: #f8f8f8;
|
310 |
+
line-height: 2em;
|
311 |
+
text-align: left;
|
312 |
+
}
|
313 |
+
}
|
assets/less/wooccm.less
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.woocommerce {
|
2 |
+
form {
|
3 |
+
.wooccm-clearfix {
|
4 |
+
&:before,
|
5 |
+
&:after{
|
6 |
+
content:'';
|
7 |
+
display:table;
|
8 |
+
}
|
9 |
+
&:after{
|
10 |
+
clear: both;
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
.wooccm-conditional-child {
|
15 |
+
display: none;
|
16 |
+
}
|
17 |
+
|
18 |
+
.wooccm-type-radio {
|
19 |
+
|
20 |
+
.woocommerce-radio-wrapper {
|
21 |
+
|
22 |
+
label {
|
23 |
+
display: inline-block;
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
.wooccm-colorpicker-iris {
|
30 |
+
.iris-picker {
|
31 |
+
display: none;
|
32 |
+
}
|
33 |
+
|
34 |
+
&.active {
|
35 |
+
.iris-picker {
|
36 |
+
display: block;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/* @media (min-width: 768px) {
|
42 |
+
.wooccm-field {
|
43 |
+
&.form-row-first {
|
44 |
+
width: 47.0588235294%;
|
45 |
+
float: left;
|
46 |
+
margin-right: 5.8823529412%;
|
47 |
+
clear: both;
|
48 |
+
}
|
49 |
+
&.form-row-last {
|
50 |
+
width: 45.4545454545%;
|
51 |
+
float: right;
|
52 |
+
margin-right: 0;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}*/
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
.button {
|
60 |
+
&.fileinput-button {
|
61 |
+
position: relative;
|
62 |
+
overflow: hidden!important;
|
63 |
+
|
64 |
+
input {
|
65 |
+
position: absolute;
|
66 |
+
top: 0;
|
67 |
+
right: 0;
|
68 |
+
margin: 0;
|
69 |
+
opacity: 0;
|
70 |
+
-ms-filter:'alpha(opacity=0)';
|
71 |
+
font-size: 200px;
|
72 |
+
direction: ltr;
|
73 |
+
cursor: pointer;
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
.wooccm-file-list {
|
80 |
+
margin: 0 -5px;
|
81 |
+
padding: 0;
|
82 |
+
display: flex;
|
83 |
+
flex-wrap: wrap;
|
84 |
+
align-items: center;
|
85 |
+
justify-content: start;
|
86 |
+
|
87 |
+
.wooccm-file-file {
|
88 |
+
display: flex;
|
89 |
+
justify-content: center;
|
90 |
+
align-items: stretch;
|
91 |
+
box-sizing: border-box;
|
92 |
+
padding: 10px 5px 0 5px;
|
93 |
+
width: 25%;
|
94 |
+
//max-height: 90px;
|
95 |
+
position: relative;
|
96 |
+
|
97 |
+
|
98 |
+
.wooccm-file-list-delete {
|
99 |
+
z-index: 1;
|
100 |
+
position: absolute;
|
101 |
+
top: 2px;
|
102 |
+
right: -3px;
|
103 |
+
width: 16px;
|
104 |
+
height: 16px;
|
105 |
+
background-color: #222;
|
106 |
+
display: block;
|
107 |
+
line-height: 16px;
|
108 |
+
text-align: center;
|
109 |
+
color: #fefefe;
|
110 |
+
font-weight: 900;
|
111 |
+
border-radius: 50%;
|
112 |
+
font-size: 12px;
|
113 |
+
cursor: pointer;
|
114 |
+
font-family: code;
|
115 |
+
text-decoration: none!important;
|
116 |
+
}
|
117 |
+
|
118 |
+
.wooccm-file-list-container {
|
119 |
+
width: 100%;
|
120 |
+
overflow: hidden;
|
121 |
+
}
|
122 |
+
|
123 |
+
.wooccm-file-list-image-container {
|
124 |
+
display: flex;
|
125 |
+
justify-content: center;
|
126 |
+
align-items: center;
|
127 |
+
overflow: hidden;
|
128 |
+
width: 100%;
|
129 |
+
padding-top: 100%;
|
130 |
+
position: relative;
|
131 |
+
background: #eee;
|
132 |
+
|
133 |
+
> img {
|
134 |
+
overflow: hidden;
|
135 |
+
object-fit: cover;
|
136 |
+
position: absolute;
|
137 |
+
top: 30%;
|
138 |
+
bottom: auto;
|
139 |
+
height: 40%;
|
140 |
+
opacity: 0.8;
|
141 |
+
|
142 |
+
&.image {
|
143 |
+
top: 0;
|
144 |
+
bottom: 0;
|
145 |
+
left: 0;
|
146 |
+
right: 0;
|
147 |
+
max-height: 100%;
|
148 |
+
max-height: 100%;
|
149 |
+
height: 100%;
|
150 |
+
width: 100%;
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
includes/class-wooccm-compatibility.php
CHANGED
@@ -296,6 +296,8 @@ class WOOCCM_Field_Compatibility
|
|
296 |
}
|
297 |
}
|
298 |
}
|
|
|
|
|
299 |
}
|
300 |
|
301 |
if (!empty($field['conditional_parent_key']) && isset($field['conditional_parent_value'])) {
|
@@ -366,14 +368,16 @@ class WOOCCM_Field_Compatibility
|
|
366 |
|
367 |
if ($fields = $this->get_option_old($name, $prefix)) {
|
368 |
|
369 |
-
|
|
|
|
|
370 |
|
371 |
foreach ($fields as $field_id => $field) {
|
372 |
|
373 |
$field = $this->new_panel_compatibility($field_id, $field, $fields, $prefix);
|
374 |
|
375 |
// if (count($defaults) && $default_id = @max(array_keys(array_column($defaults, 'key'), $field['key']))) {
|
376 |
-
if (count($defaults) && $default_id = WOOCCM()->$prefix->get_field_id($defaults, 'key', $field['key'])) {
|
377 |
|
378 |
if (isset($defaults[$default_id])) {
|
379 |
|
@@ -383,7 +387,7 @@ class WOOCCM_Field_Compatibility
|
|
383 |
|
384 |
$field = wp_parse_args($field, $defaults[$default_id]);
|
385 |
}
|
386 |
-
}
|
387 |
|
388 |
$fields[$field_id] = $field;
|
389 |
}
|
296 |
}
|
297 |
}
|
298 |
}
|
299 |
+
} else {
|
300 |
+
$field['options'] = array();
|
301 |
}
|
302 |
|
303 |
if (!empty($field['conditional_parent_key']) && isset($field['conditional_parent_value'])) {
|
368 |
|
369 |
if ($fields = $this->get_option_old($name, $prefix)) {
|
370 |
|
371 |
+
//$defaults = WOOCCM()->$prefix->get_default_fields();
|
372 |
+
|
373 |
+
//$defaults_keys = array_column($defaults, 'key');
|
374 |
|
375 |
foreach ($fields as $field_id => $field) {
|
376 |
|
377 |
$field = $this->new_panel_compatibility($field_id, $field, $fields, $prefix);
|
378 |
|
379 |
// if (count($defaults) && $default_id = @max(array_keys(array_column($defaults, 'key'), $field['key']))) {
|
380 |
+
/*if (count($defaults) && $default_id = WOOCCM()->$prefix->get_field_id($defaults, 'key', $field['key'])) {
|
381 |
|
382 |
if (isset($defaults[$default_id])) {
|
383 |
|
387 |
|
388 |
$field = wp_parse_args($field, $defaults[$default_id]);
|
389 |
}
|
390 |
+
}*/
|
391 |
|
392 |
$fields[$field_id] = $field;
|
393 |
}
|
includes/controller/class-wooccm-checkout.php
CHANGED
@@ -147,6 +147,9 @@ class WOOCCM_Checkout_Controller
|
|
147 |
|
148 |
wc_get_template('notices/notice.php', array(
|
149 |
'messages' => array_filter((array) $text),
|
|
|
|
|
|
|
150 |
));
|
151 |
}
|
152 |
}
|
@@ -158,6 +161,9 @@ class WOOCCM_Checkout_Controller
|
|
158 |
|
159 |
wc_get_template('notices/notice.php', array(
|
160 |
'messages' => array_filter((array) $text),
|
|
|
|
|
|
|
161 |
));
|
162 |
}
|
163 |
}
|
147 |
|
148 |
wc_get_template('notices/notice.php', array(
|
149 |
'messages' => array_filter((array) $text),
|
150 |
+
'notices' => array(0 => array(
|
151 |
+
'notice' => $text
|
152 |
+
))
|
153 |
));
|
154 |
}
|
155 |
}
|
161 |
|
162 |
wc_get_template('notices/notice.php', array(
|
163 |
'messages' => array_filter((array) $text),
|
164 |
+
'notices' => array(0 => array(
|
165 |
+
'notice' => $text
|
166 |
+
))
|
167 |
));
|
168 |
}
|
169 |
}
|
includes/controller/class-wooccm-field-billing.php
CHANGED
@@ -1,22 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller
|
|
|
4 |
|
5 |
protected static $_instance;
|
6 |
public $billing;
|
7 |
|
8 |
-
public function __construct()
|
|
|
9 |
|
10 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/model/class-wooccm-field-billing.php');
|
11 |
|
12 |
add_action('wooccm_sections_header', array($this, 'add_header'));
|
13 |
add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section'), 99);
|
14 |
-
add_filter('woocommerce_admin_billing_fields', array($this, 'add_admin_billing_fields'));
|
15 |
//add_filter('woocommerce_admin_shipping_fields', array($this, 'add_admin_shipping_fields'));
|
16 |
// add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'add_order_data'));
|
17 |
}
|
18 |
|
19 |
-
public static function instance()
|
|
|
20 |
if (is_null(self::$_instance)) {
|
21 |
self::$_instance = new self();
|
22 |
}
|
@@ -26,7 +29,8 @@ class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller {
|
|
26 |
// Admin
|
27 |
// ---------------------------------------------------------------------------
|
28 |
|
29 |
-
public function add_section()
|
|
|
30 |
|
31 |
global $current_section, $wp_roles, $wp_locale;
|
32 |
|
@@ -46,17 +50,19 @@ class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller {
|
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
public function add_header()
|
|
|
50 |
global $current_section;
|
51 |
-
|
52 |
<li><a href="<?php echo admin_url('admin.php?page=wc-settings&tab=wooccm§ion=billing'); ?>" class="<?php echo ($current_section == 'billing' ? 'current' : ''); ?>"><?php esc_html_e('Billing', 'woocommerce-checkout-manager'); ?></a> | </li>
|
53 |
-
|
54 |
}
|
55 |
|
56 |
// Admin Order
|
57 |
// ---------------------------------------------------------------------------
|
58 |
|
59 |
-
function add_admin_billing_fields($billing_fields)
|
|
|
60 |
|
61 |
if (!$fields = WOOCCM()->billing->get_fields()) {
|
62 |
return $billing_fields;
|
@@ -95,72 +101,6 @@ class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller {
|
|
95 |
|
96 |
return $billing_fields;
|
97 |
}
|
98 |
-
|
99 |
-
/* function add_admin_shipping_fields($shipping_fields)
|
100 |
-
{
|
101 |
-
|
102 |
-
if (!$fields = WOOCCM()->shipping->get_fields()) {
|
103 |
-
return $shipping_fields;
|
104 |
-
}
|
105 |
-
|
106 |
-
$defaults = WOOCCM()->shipping->get_defaults();
|
107 |
-
$template = WOOCCM()->shipping->get_template_types();
|
108 |
-
|
109 |
-
foreach ($fields as $field_id => $field) {
|
110 |
-
|
111 |
-
if (in_array($field['name'], $defaults)) {
|
112 |
-
continue;
|
113 |
-
}
|
114 |
-
|
115 |
-
if (in_array($field['name'], $template)) {
|
116 |
-
continue;
|
117 |
-
}
|
118 |
-
|
119 |
-
if (!isset($field['type']) || $field['type'] != 'textarea') {
|
120 |
-
$field['type'] = 'text';
|
121 |
-
}
|
122 |
-
|
123 |
-
$shipping_fields[$field['name']] = $field;
|
124 |
-
$shipping_fields[$field['name']]['id'] = sprintf('_%s', (string) $field['key']);
|
125 |
-
$shipping_fields[$field['name']]['label'] = $field['label'];
|
126 |
-
$shipping_fields[$field['name']]['name'] = $field['key'];
|
127 |
-
$shipping_fields[$field['name']]['value'] = null;
|
128 |
-
$shipping_fields[$field['name']]['class'] = join(' ', $field['class']);
|
129 |
-
//$shipping_fields[$field['name']]['wrapper_class'] = 'wooccm-premium';
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
return $shipping_fields;
|
134 |
-
} */
|
135 |
-
|
136 |
-
/* function add_order_data($order)
|
137 |
-
{
|
138 |
-
|
139 |
-
if ($fields = WOOCCM()->billing->get_fields()) {
|
140 |
-
|
141 |
-
$defaults = WOOCCM()->billing->get_defaults();
|
142 |
-
|
143 |
-
foreach ($fields as $field_id => $field) {
|
144 |
-
|
145 |
-
if (!in_array($field['name'], $defaults)) {
|
146 |
-
|
147 |
-
$key = sprintf('_%s', $field['key']);
|
148 |
-
|
149 |
-
if ($value = get_post_meta($order->get_id(), $key, true)) {
|
150 |
-
?>
|
151 |
-
<p id="<?php echo esc_attr($field['key']); ?>" class="form-field form-field-wide form-field-type-<?php echo esc_attr($field['type']); ?>">
|
152 |
-
<strong title="<?php echo esc_attr(sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $key, __('Generic', 'woocommerce-checkout-manager'))); ?>">
|
153 |
-
<?php echo esc_attr(trim($field['label'])); ?>:
|
154 |
-
</strong>
|
155 |
-
<br />
|
156 |
-
<?php echo esc_html($value); ?>
|
157 |
-
</p>
|
158 |
-
<?php
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
}
|
163 |
-
} */
|
164 |
}
|
165 |
|
166 |
WOOCCM_Field_Controller_Billing::instance();
|
1 |
<?php
|
2 |
|
3 |
+
class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller
|
4 |
+
{
|
5 |
|
6 |
protected static $_instance;
|
7 |
public $billing;
|
8 |
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
|
12 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/model/class-wooccm-field-billing.php');
|
13 |
|
14 |
add_action('wooccm_sections_header', array($this, 'add_header'));
|
15 |
add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section'), 99);
|
16 |
+
add_filter('woocommerce_admin_billing_fields', array($this, 'add_admin_billing_fields'), 999);
|
17 |
//add_filter('woocommerce_admin_shipping_fields', array($this, 'add_admin_shipping_fields'));
|
18 |
// add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'add_order_data'));
|
19 |
}
|
20 |
|
21 |
+
public static function instance()
|
22 |
+
{
|
23 |
if (is_null(self::$_instance)) {
|
24 |
self::$_instance = new self();
|
25 |
}
|
29 |
// Admin
|
30 |
// ---------------------------------------------------------------------------
|
31 |
|
32 |
+
public function add_section()
|
33 |
+
{
|
34 |
|
35 |
global $current_section, $wp_roles, $wp_locale;
|
36 |
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
public function add_header()
|
54 |
+
{
|
55 |
global $current_section;
|
56 |
+
?>
|
57 |
<li><a href="<?php echo admin_url('admin.php?page=wc-settings&tab=wooccm§ion=billing'); ?>" class="<?php echo ($current_section == 'billing' ? 'current' : ''); ?>"><?php esc_html_e('Billing', 'woocommerce-checkout-manager'); ?></a> | </li>
|
58 |
+
<?php
|
59 |
}
|
60 |
|
61 |
// Admin Order
|
62 |
// ---------------------------------------------------------------------------
|
63 |
|
64 |
+
function add_admin_billing_fields($billing_fields)
|
65 |
+
{
|
66 |
|
67 |
if (!$fields = WOOCCM()->billing->get_fields()) {
|
68 |
return $billing_fields;
|
101 |
|
102 |
return $billing_fields;
|
103 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
WOOCCM_Field_Controller_Billing::instance();
|
includes/controller/class-wooccm-field-shipping.php
CHANGED
@@ -12,9 +12,8 @@ class WOOCCM_Field_Controller_Shipping extends WOOCCM_Field_Controller
|
|
12 |
|
13 |
add_action('wooccm_sections_header', array($this, 'add_header'));
|
14 |
add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section'), 99);
|
15 |
-
add_filter('woocommerce_admin_shipping_fields', array($this, 'add_admin_shipping_fields'));
|
16 |
|
17 |
-
//add_action('woocommerce_admin_order_data_after_shipping_address', array($this, 'add_order_data'));
|
18 |
}
|
19 |
|
20 |
public static function instance()
|
@@ -64,7 +63,6 @@ class WOOCCM_Field_Controller_Shipping extends WOOCCM_Field_Controller
|
|
64 |
return $shipping_fields;
|
65 |
}
|
66 |
|
67 |
-
//$defaults = WOOCCM()->shipping->get_defaults();
|
68 |
$template = WOOCCM()->shipping->get_template_types();
|
69 |
|
70 |
foreach ($fields as $field_id => $field) {
|
@@ -97,38 +95,7 @@ class WOOCCM_Field_Controller_Shipping extends WOOCCM_Field_Controller
|
|
97 |
|
98 |
return $shipping_fields;
|
99 |
}
|
100 |
-
|
101 |
-
// Admin Order
|
102 |
-
// ---------------------------------------------------------------------------
|
103 |
-
|
104 |
-
/*function add_order_data($order)
|
105 |
-
{
|
106 |
-
|
107 |
-
if ($fields = WOOCCM()->shipping->get_fields()) {
|
108 |
-
|
109 |
-
$defaults = WOOCCM()->shipping->get_defaults();
|
110 |
-
|
111 |
-
foreach ($fields as $field_id => $field) {
|
112 |
-
|
113 |
-
if (!in_array($field['name'], $defaults)) {
|
114 |
-
|
115 |
-
$key = sprintf('_%s', $field['key']);
|
116 |
-
|
117 |
-
if ($value = get_post_meta($order->get_id(), $key, true)) {
|
118 |
-
?>
|
119 |
-
<p id="<?php echo esc_attr($field['key']); ?>" class="form-field form-field-wide form-field-type-<?php echo esc_attr($field['type']); ?>">
|
120 |
-
<strong title="<?php echo esc_attr(sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $key, __('Generic', 'woocommerce-checkout-manager'))); ?>">
|
121 |
-
<?php echo esc_attr(trim($field['label'])); ?>:
|
122 |
-
</strong>
|
123 |
-
<br />
|
124 |
-
<?php echo esc_html($value); ?>
|
125 |
-
</p>
|
126 |
-
<?php
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}*/
|
132 |
}
|
133 |
|
134 |
WOOCCM_Field_Controller_Shipping::instance();
|
12 |
|
13 |
add_action('wooccm_sections_header', array($this, 'add_header'));
|
14 |
add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section'), 99);
|
15 |
+
add_filter('woocommerce_admin_shipping_fields', array($this, 'add_admin_shipping_fields'), 999);
|
16 |
|
|
|
17 |
}
|
18 |
|
19 |
public static function instance()
|
63 |
return $shipping_fields;
|
64 |
}
|
65 |
|
|
|
66 |
$template = WOOCCM()->shipping->get_template_types();
|
67 |
|
68 |
foreach ($fields as $field_id => $field) {
|
95 |
|
96 |
return $shipping_fields;
|
97 |
}
|
98 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
|
101 |
WOOCCM_Field_Controller_Shipping::instance();
|
includes/controller/class-wooccm-field.php
CHANGED
@@ -87,14 +87,30 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
87 |
public function ajax_toggle_field_attribute()
|
88 |
{
|
89 |
|
90 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
$
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
|
97 |
-
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
parent::error_reload_page();
|
@@ -103,24 +119,29 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
103 |
public function ajax_change_field_attribute()
|
104 |
{
|
105 |
|
106 |
-
if (
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
110 |
|
111 |
-
|
112 |
|
113 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
114 |
$attr = wc_clean(wp_unslash($_REQUEST['field_attr']));
|
115 |
-
$value = wc_clean(wp_unslash($_REQUEST['field_value']));
|
116 |
|
117 |
-
$
|
118 |
|
119 |
-
|
120 |
|
121 |
-
$field = WOOCCM()->$section->update_field($
|
122 |
|
123 |
-
parent::success_ajax($
|
124 |
}
|
125 |
}
|
126 |
}
|
@@ -148,7 +169,11 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
148 |
public function ajax_delete_field()
|
149 |
{
|
150 |
|
151 |
-
if (
|
|
|
|
|
|
|
|
|
152 |
|
153 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
154 |
|
@@ -164,18 +189,19 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
164 |
public function ajax_reset_fields()
|
165 |
{
|
166 |
|
167 |
-
if (
|
|
|
|
|
|
|
|
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
$section = wc_clean(wp_unslash($_REQUEST['section']));
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
176 |
|
177 |
-
|
178 |
-
}
|
179 |
}
|
180 |
}
|
181 |
|
@@ -185,7 +211,11 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
185 |
public function ajax_load_field()
|
186 |
{
|
187 |
|
188 |
-
if (
|
|
|
|
|
|
|
|
|
189 |
|
190 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
191 |
|
@@ -273,27 +303,6 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
273 |
// Save
|
274 |
// ---------------------------------------------------------------------------
|
275 |
|
276 |
-
public function toggle_field_attribute($field_id, $attr)
|
277 |
-
{
|
278 |
-
|
279 |
-
if (array_key_exists('section', $_REQUEST)) {
|
280 |
-
|
281 |
-
$section = wc_clean(wp_unslash($_REQUEST['section']));
|
282 |
-
|
283 |
-
if (isset(WOOCCM()->$section)) {
|
284 |
-
|
285 |
-
if ($field = WOOCCM()->$section->get_field($field_id)) {
|
286 |
-
|
287 |
-
$field[$attr] = !(bool) @$field[$attr];
|
288 |
-
|
289 |
-
WOOCCM()->$section->update_field($field);
|
290 |
-
|
291 |
-
return $field[$attr];
|
292 |
-
}
|
293 |
-
}
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
public function save_modal_field($field_data)
|
298 |
{
|
299 |
|
@@ -303,16 +312,13 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
303 |
|
304 |
if (isset(WOOCCM()->$section)) {
|
305 |
|
306 |
-
// fix unchecked checkboxes
|
307 |
-
|
308 |
-
$field_id = wc_clean(wp_unslash($field_data['id']));
|
309 |
$field_data = wp_parse_args($field_data, WOOCCM()->$section->get_args());
|
310 |
|
311 |
// don't override
|
312 |
-
unset($field_data['order']);
|
313 |
-
unset($field_data['required']);
|
314 |
-
unset($field_data['position']);
|
315 |
-
unset($field_data['disabled']);
|
316 |
|
317 |
return WOOCCM()->$section->update_field($field_data);
|
318 |
}
|
87 |
public function ajax_toggle_field_attribute()
|
88 |
{
|
89 |
|
90 |
+
if (
|
91 |
+
current_user_can('manage_woocommerce') &&
|
92 |
+
check_ajax_referer('wooccm_field', 'nonce') &&
|
93 |
+
isset($_REQUEST['section']) &&
|
94 |
+
isset($_REQUEST['field_id']) &&
|
95 |
+
isset($_REQUEST['field_attr'])
|
96 |
+
) {
|
97 |
|
98 |
+
$section = wc_clean(wp_unslash($_REQUEST['section']));
|
99 |
+
|
100 |
+
if (isset(WOOCCM()->$section)) {
|
101 |
+
|
102 |
+
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
103 |
+
$attr = wc_clean(wp_unslash($_REQUEST['field_attr']));
|
104 |
+
|
105 |
+
if ($field = WOOCCM()->$section->get_field($field_id)) {
|
106 |
|
107 |
+
$value = $field[$attr] = !(bool) @$field[$attr];
|
108 |
|
109 |
+
WOOCCM()->$section->update_field($field);
|
110 |
+
|
111 |
+
parent::success_ajax($value);
|
112 |
+
}
|
113 |
+
}
|
114 |
}
|
115 |
|
116 |
parent::error_reload_page();
|
119 |
public function ajax_change_field_attribute()
|
120 |
{
|
121 |
|
122 |
+
if (
|
123 |
+
current_user_can('manage_woocommerce') &&
|
124 |
+
check_ajax_referer('wooccm_field', 'nonce') &&
|
125 |
+
isset($_REQUEST['section']) &&
|
126 |
+
isset($_REQUEST['field_id']) &&
|
127 |
+
isset($_REQUEST['field_attr']) &&
|
128 |
+
isset($_REQUEST['field_value'])
|
129 |
+
) {
|
130 |
|
131 |
+
$section = wc_clean(wp_unslash($_REQUEST['section']));
|
132 |
|
133 |
+
if (isset(WOOCCM()->$section)) {
|
134 |
|
135 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
136 |
$attr = wc_clean(wp_unslash($_REQUEST['field_attr']));
|
|
|
137 |
|
138 |
+
if ($field = WOOCCM()->$section->get_field($field_id)) {
|
139 |
|
140 |
+
$value = $field[$attr] = wc_clean(wp_unslash($_REQUEST['field_value']));
|
141 |
|
142 |
+
$field = WOOCCM()->$section->update_field($field);
|
143 |
|
144 |
+
parent::success_ajax($value);
|
145 |
}
|
146 |
}
|
147 |
}
|
169 |
public function ajax_delete_field()
|
170 |
{
|
171 |
|
172 |
+
if (
|
173 |
+
current_user_can('manage_woocommerce') &&
|
174 |
+
check_ajax_referer('wooccm_field', 'nonce') &&
|
175 |
+
isset($_REQUEST['field_id'])
|
176 |
+
) {
|
177 |
|
178 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
179 |
|
189 |
public function ajax_reset_fields()
|
190 |
{
|
191 |
|
192 |
+
if (
|
193 |
+
current_user_can('manage_woocommerce') &&
|
194 |
+
check_ajax_referer('wooccm_field', 'nonce') &&
|
195 |
+
isset($_REQUEST['section'])
|
196 |
+
) {
|
197 |
|
198 |
+
$section = wc_clean(wp_unslash($_REQUEST['section']));
|
|
|
|
|
199 |
|
200 |
+
if (isset(WOOCCM()->$section)) {
|
201 |
|
202 |
+
WOOCCM()->$section->delete_fields();
|
203 |
|
204 |
+
parent::success_ajax();
|
|
|
205 |
}
|
206 |
}
|
207 |
|
211 |
public function ajax_load_field()
|
212 |
{
|
213 |
|
214 |
+
if (
|
215 |
+
current_user_can('manage_woocommerce') &&
|
216 |
+
check_ajax_referer('wooccm_field', 'nonce') &&
|
217 |
+
isset($_REQUEST['field_id'])
|
218 |
+
) {
|
219 |
|
220 |
$field_id = wc_clean(wp_unslash($_REQUEST['field_id']));
|
221 |
|
303 |
// Save
|
304 |
// ---------------------------------------------------------------------------
|
305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
public function save_modal_field($field_data)
|
307 |
{
|
308 |
|
312 |
|
313 |
if (isset(WOOCCM()->$section)) {
|
314 |
|
|
|
|
|
|
|
315 |
$field_data = wp_parse_args($field_data, WOOCCM()->$section->get_args());
|
316 |
|
317 |
// don't override
|
318 |
+
//unset($field_data['order']);
|
319 |
+
//unset($field_data['required']);
|
320 |
+
//unset($field_data['position']);
|
321 |
+
//unset($field_data['disabled']);
|
322 |
|
323 |
return WOOCCM()->$section->update_field($field_data);
|
324 |
}
|
includes/model/class-wooccm-field.php
CHANGED
@@ -253,12 +253,15 @@ class WOOCCM_Field extends WOOCCM_Model
|
|
253 |
//remove_filter('woocommerce_' . $prefix . 'fields', array($filters, 'add_' . $prefix . 'fields'));
|
254 |
remove_all_filters('woocommerce_' . $prefix . 'fields');
|
255 |
|
|
|
256 |
foreach (WC()->countries->get_address_fields('', $prefix) as $key => $field) {
|
257 |
|
|
|
258 |
$field['key'] = $key;
|
259 |
$field['name'] = str_replace($prefix, '', $key);
|
260 |
|
261 |
-
$fields[] = $field;
|
|
|
262 |
}
|
263 |
}
|
264 |
|
@@ -268,17 +271,22 @@ class WOOCCM_Field extends WOOCCM_Model
|
|
268 |
public function get_fields()
|
269 |
{
|
270 |
|
271 |
-
|
|
|
|
|
272 |
|
273 |
foreach ($fields as $field_id => $field) {
|
|
|
274 |
$fields[$field_id] = apply_filters('wooccm_checkout_field_filter', $this->sanitize_field($field_id, $field, $fields), $field_id);
|
275 |
}
|
276 |
|
277 |
-
// Resort the fields by order
|
278 |
uasort($fields, array(__CLASS__, 'order_fields'));
|
|
|
|
|
279 |
}
|
|
|
280 |
|
281 |
-
return
|
282 |
}
|
283 |
|
284 |
public function update_fields($fields)
|
@@ -306,6 +314,7 @@ class WOOCCM_Field extends WOOCCM_Model
|
|
306 |
public function delete_fields()
|
307 |
{
|
308 |
$this->delete();
|
|
|
309 |
}
|
310 |
|
311 |
// Field
|
@@ -371,9 +380,9 @@ class WOOCCM_Field extends WOOCCM_Model
|
|
371 |
}
|
372 |
}
|
373 |
|
374 |
-
if (count($field['options']) > 1) {
|
375 |
uasort($field['options'], array(__CLASS__, 'order_fields'));
|
376 |
-
}
|
377 |
|
378 |
return wp_unslash($field);
|
379 |
}
|
253 |
//remove_filter('woocommerce_' . $prefix . 'fields', array($filters, 'add_' . $prefix . 'fields'));
|
254 |
remove_all_filters('woocommerce_' . $prefix . 'fields');
|
255 |
|
256 |
+
$i = 0;
|
257 |
foreach (WC()->countries->get_address_fields('', $prefix) as $key => $field) {
|
258 |
|
259 |
+
$field['id'] = $i;
|
260 |
$field['key'] = $key;
|
261 |
$field['name'] = str_replace($prefix, '', $key);
|
262 |
|
263 |
+
$fields[$i] = $field;
|
264 |
+
$i++;
|
265 |
}
|
266 |
}
|
267 |
|
271 |
public function get_fields()
|
272 |
{
|
273 |
|
274 |
+
// (is_array($fields = $this->get_items())) {
|
275 |
+
|
276 |
+
if (count($fields = $this->get_items())) {
|
277 |
|
278 |
foreach ($fields as $field_id => $field) {
|
279 |
+
|
280 |
$fields[$field_id] = apply_filters('wooccm_checkout_field_filter', $this->sanitize_field($field_id, $field, $fields), $field_id);
|
281 |
}
|
282 |
|
|
|
283 |
uasort($fields, array(__CLASS__, 'order_fields'));
|
284 |
+
|
285 |
+
$fields = apply_filters('wooccm_' . $this->prefix . '_fields', $fields);
|
286 |
}
|
287 |
+
//}
|
288 |
|
289 |
+
return $fields;
|
290 |
}
|
291 |
|
292 |
public function update_fields($fields)
|
314 |
public function delete_fields()
|
315 |
{
|
316 |
$this->delete();
|
317 |
+
$this->save_items($this->get_defaults());
|
318 |
}
|
319 |
|
320 |
// Field
|
380 |
}
|
381 |
}
|
382 |
|
383 |
+
if (is_array($field['options']) && count($field['options']) > 1) {
|
384 |
uasort($field['options'], array(__CLASS__, 'order_fields'));
|
385 |
+
}
|
386 |
|
387 |
return wp_unslash($field);
|
388 |
}
|
includes/model/class-wooccm-model.php
CHANGED
@@ -17,7 +17,7 @@ class WOOCCM_Model
|
|
17 |
|
18 |
$items = $this->get_items();
|
19 |
|
20 |
-
if (
|
21 |
return max(array_keys($items)) + 1;
|
22 |
}
|
23 |
|
@@ -67,26 +67,11 @@ class WOOCCM_Model
|
|
67 |
return $this->save_items($items);
|
68 |
}
|
69 |
|
70 |
-
// protected function save_item($item_data = null)
|
71 |
-
// {
|
72 |
-
|
73 |
-
|
74 |
-
// $items = $this->get_items();
|
75 |
-
|
76 |
-
// // if (!isset($items[$item_data['id']])) {
|
77 |
-
// // return false;
|
78 |
-
// // }
|
79 |
-
|
80 |
-
// $items[$item_data['id']] = array_replace_recursive($this->get_args(), $item_data);
|
81 |
-
|
82 |
-
// return $this->save($items);
|
83 |
-
// }
|
84 |
-
|
85 |
protected function delete_item($id = null)
|
86 |
{
|
87 |
$items = $this->get_items();
|
88 |
if ($items) {
|
89 |
-
if (
|
90 |
unset($items[$id]);
|
91 |
return $this->save($items);
|
92 |
}
|
@@ -98,19 +83,25 @@ class WOOCCM_Model
|
|
98 |
{
|
99 |
|
100 |
$items = $this->get();
|
|
|
101 |
//make sure each item has all values
|
102 |
if (is_array($items)) {
|
103 |
-
|
104 |
-
$items
|
|
|
|
|
|
|
105 |
}
|
106 |
}
|
107 |
-
|
|
|
108 |
}
|
109 |
|
110 |
protected function save_items($items)
|
111 |
{
|
112 |
|
113 |
if (is_array($items)) {
|
|
|
114 |
foreach ($items as $id => $item) {
|
115 |
|
116 |
if (!isset($item['id'])) {
|
@@ -119,9 +110,9 @@ class WOOCCM_Model
|
|
119 |
|
120 |
$items[$id] = array_replace_recursive($this->get_args(), $item);
|
121 |
}
|
122 |
-
}
|
123 |
|
124 |
-
|
|
|
125 |
}
|
126 |
|
127 |
// Core
|
@@ -156,6 +147,6 @@ class WOOCCM_Model
|
|
156 |
protected function delete()
|
157 |
{
|
158 |
delete_option($this->table);
|
159 |
-
//
|
160 |
}
|
161 |
}
|
17 |
|
18 |
$items = $this->get_items();
|
19 |
|
20 |
+
if (count($items)) {
|
21 |
return max(array_keys($items)) + 1;
|
22 |
}
|
23 |
|
67 |
return $this->save_items($items);
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
protected function delete_item($id = null)
|
71 |
{
|
72 |
$items = $this->get_items();
|
73 |
if ($items) {
|
74 |
+
if (count($items) > 0) {
|
75 |
unset($items[$id]);
|
76 |
return $this->save($items);
|
77 |
}
|
83 |
{
|
84 |
|
85 |
$items = $this->get();
|
86 |
+
|
87 |
//make sure each item has all values
|
88 |
if (is_array($items)) {
|
89 |
+
if (count($items)) {
|
90 |
+
foreach ($items as $id => $item) {
|
91 |
+
$items[$id] = array_replace_recursive($this->get_args(), $item);
|
92 |
+
}
|
93 |
+
return $items;
|
94 |
}
|
95 |
}
|
96 |
+
|
97 |
+
return array();
|
98 |
}
|
99 |
|
100 |
protected function save_items($items)
|
101 |
{
|
102 |
|
103 |
if (is_array($items)) {
|
104 |
+
|
105 |
foreach ($items as $id => $item) {
|
106 |
|
107 |
if (!isset($item['id'])) {
|
110 |
|
111 |
$items[$id] = array_replace_recursive($this->get_args(), $item);
|
112 |
}
|
|
|
113 |
|
114 |
+
return $this->save($items);
|
115 |
+
}
|
116 |
}
|
117 |
|
118 |
// Core
|
147 |
protected function delete()
|
148 |
{
|
149 |
delete_option($this->table);
|
150 |
+
//update_option($this->table, $this->get_defaults());
|
151 |
}
|
152 |
}
|
includes/view/backend/pages/parts/loop.php
CHANGED
@@ -115,7 +115,7 @@
|
|
115 |
<a class="<?php printf('wooccm_%s_settings_edit', $current_section); ?> button" aria-label="<?php esc_html_e('Edit checkout field', 'woocommerce-checkout-manager'); ?>" href="javascript:;"><?php esc_html_e('Edit'); ?></a>
|
116 |
</td>
|
117 |
<td class="delete">
|
118 |
-
<?php if (is_array($defaults) && !in_array($field['
|
119 |
<a class="<?php printf('wooccm_%s_settings_delete', $current_section); ?>" aria-label="<?php esc_html_e('Edit checkout field', 'woocommerce-checkout-manager'); ?>" href="javascript:;"><?php esc_html_e('Delete'); ?></a>
|
120 |
<?php endif; ?>
|
121 |
</td>
|
115 |
<a class="<?php printf('wooccm_%s_settings_edit', $current_section); ?> button" aria-label="<?php esc_html_e('Edit checkout field', 'woocommerce-checkout-manager'); ?>" href="javascript:;"><?php esc_html_e('Edit'); ?></a>
|
116 |
</td>
|
117 |
<td class="delete">
|
118 |
+
<?php if (is_array($defaults) && !in_array($field['key'], array_column($defaults, 'key'))): ?>
|
119 |
<a class="<?php printf('wooccm_%s_settings_delete', $current_section); ?>" aria-label="<?php esc_html_e('Edit checkout field', 'woocommerce-checkout-manager'); ?>" href="javascript:;"><?php esc_html_e('Delete'); ?></a>
|
120 |
<?php endif; ?>
|
121 |
</td>
|
includes/view/frontend/class-wooccm-fields-handler.php
CHANGED
@@ -211,12 +211,15 @@ class WOOCCM_Fields_Handler
|
|
211 |
|
212 |
foreach ($fields as $key => $type) {
|
213 |
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
220 |
}
|
221 |
}
|
222 |
}
|
211 |
|
212 |
foreach ($fields as $key => $type) {
|
213 |
|
214 |
+
if (is_array($type)) {
|
215 |
+
if (count($type)) {
|
216 |
+
foreach ($type as $field_id => $field) {
|
217 |
+
// Remove disabled
|
218 |
+
// -------------------------------------------------------------------
|
219 |
+
if (!empty($field['disabled'])) {
|
220 |
+
unset($fields[$key][$field_id]);
|
221 |
+
}
|
222 |
+
}
|
223 |
}
|
224 |
}
|
225 |
}
|
includes/view/frontend/class-wooccm-fields-register.php
CHANGED
@@ -24,6 +24,11 @@ class WOOCCM_Fields_Register
|
|
24 |
// Additional fields
|
25 |
// -----------------------------------------------------------------------
|
26 |
add_filter('woocommerce_checkout_fields', array($this, 'add_additional_fields'));
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
public static function instance()
|
@@ -44,6 +49,32 @@ class WOOCCM_Fields_Register
|
|
44 |
return WOOCCM()->shipping->get_fields();
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
public function add_additional_fields($fields)
|
48 |
{
|
49 |
|
24 |
// Additional fields
|
25 |
// -----------------------------------------------------------------------
|
26 |
add_filter('woocommerce_checkout_fields', array($this, 'add_additional_fields'));
|
27 |
+
|
28 |
+
// My account
|
29 |
+
// woocommerce 4.2 issue, the shipping and billing fields not working on my account when required field is empty
|
30 |
+
// temporary fix excluding required fields in my account
|
31 |
+
add_filter('woocommerce_address_to_edit', array($this, 'add_my_account_fields'), 10, 2);
|
32 |
}
|
33 |
|
34 |
public static function instance()
|
49 |
return WOOCCM()->shipping->get_fields();
|
50 |
}
|
51 |
|
52 |
+
public function add_my_account_fields($defaults, $load_address)
|
53 |
+
{
|
54 |
+
|
55 |
+
if (isset(WOOCCM()->$load_address)) {
|
56 |
+
|
57 |
+
$fields = WOOCCM()->$load_address->get_fields();
|
58 |
+
|
59 |
+
$keys = array_column(WOOCCM()->$load_address->get_fields(), 'key');
|
60 |
+
|
61 |
+
foreach ($fields as $field_id => $field) {
|
62 |
+
if (!isset($field['value'])) {
|
63 |
+
|
64 |
+
// when country field is visible default state is set via javascript
|
65 |
+
if (in_array("{$load_address}_country", $keys)) {
|
66 |
+
unset($fields[$field_id]['country']);
|
67 |
+
}
|
68 |
+
$fields[$field_id]['value'] = get_user_meta(get_current_user_id(), $field['key'], true);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $fields;
|
73 |
+
}
|
74 |
+
|
75 |
+
return $defaults;
|
76 |
+
}
|
77 |
+
|
78 |
public function add_additional_fields($fields)
|
79 |
{
|
80 |
|
pending
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/
|
|
4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 5.4.2
|
7 |
-
Stable tag: 5.1.
|
8 |
WC requires at least: 3.1.0
|
9 |
WC tested up to: 4.2.0
|
10 |
License: GPLv2 or later
|
@@ -107,6 +107,9 @@ Your Order data can be reviewed in each order within the default WooCommerce Ord
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
110 |
= 5.1.1 =
|
111 |
* Fix: php error
|
112 |
|
4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 5.4.2
|
7 |
+
Stable tag: 5.1.2
|
8 |
WC requires at least: 3.1.0
|
9 |
WC tested up to: 4.2.0
|
10 |
License: GPLv2 or later
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 5.1.2 =
|
111 |
+
* Fix: php error
|
112 |
+
|
113 |
= 5.1.1 =
|
114 |
* Fix: php error
|
115 |
|
templates/order/order-custom-fields.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<h2 class="woocommerce-order-details__title"><?php echo ($title = get_option('wooccm_order_custom_fields_title', false)) ? esc_html($title) : esc_html__('
|
2 |
<table class="woocommerce-table shop_table order_details">
|
3 |
<tbody>
|
4 |
<?php
|
5 |
-
if (count($checkout = WC()->checkout->get_checkout_fields())):
|
6 |
foreach ($checkout as $field_type => $fields) :
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
<?php if (!in_array($
|
11 |
-
<?php if ($value = get_post_meta($order_id, sprintf('_%s', $key), true)): ?>
|
12 |
<tr id="tr-<?php echo esc_attr($key); ?>">
|
13 |
<th>
|
14 |
<?php echo esc_html($field['label']); ?>
|
@@ -19,8 +19,8 @@
|
|
19 |
</tr>
|
20 |
<?php endif; ?>
|
21 |
<?php endif; ?>
|
22 |
-
<?php
|
23 |
-
<?php
|
24 |
<?php endforeach; ?>
|
25 |
<?php endif; ?>
|
26 |
</tbody>
|
1 |
+
<h2 class="woocommerce-order-details__title"><?php echo ($title = get_option('wooccm_order_custom_fields_title', false)) ? esc_html($title) : esc_html__('Order extra', 'woocommerce-checkout-manager'); ?></h2>
|
2 |
<table class="woocommerce-table shop_table order_details">
|
3 |
<tbody>
|
4 |
<?php
|
5 |
+
if (count($checkout = WC()->checkout->get_checkout_fields())) :
|
6 |
foreach ($checkout as $field_type => $fields) :
|
7 |
+
if (isset(WOOCCM()->$field_type)) :
|
8 |
+
$defaults = array_column(WOOCCM()->$field_type->get_defaults(), 'key');
|
9 |
+
foreach ($fields as $key => $field) : ?>
|
10 |
+
<?php if (!in_array($key, $defaults) && empty($field['hide_order'])) : ?>
|
11 |
+
<?php if ($value = get_post_meta($order_id, sprintf('_%s', $key), true)) : ?>
|
12 |
<tr id="tr-<?php echo esc_attr($key); ?>">
|
13 |
<th>
|
14 |
<?php echo esc_html($field['label']); ?>
|
19 |
</tr>
|
20 |
<?php endif; ?>
|
21 |
<?php endif; ?>
|
22 |
+
<?php endforeach; ?>
|
23 |
+
<?php endif; ?>
|
24 |
<?php endforeach; ?>
|
25 |
<?php endif; ?>
|
26 |
</tbody>
|
woocommerce-checkout-manager.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Plugin Name: WooCommerce Checkout Manager
|
5 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
6 |
-
* Version: 5.1.
|
7 |
* Author: QuadLayers
|
8 |
* Author URI: https://www.quadlayers.com
|
9 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
@@ -19,7 +19,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
|
|
19 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
20 |
}
|
21 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
22 |
-
define('WOOCCM_PLUGIN_VERSION', '5.1.
|
23 |
}
|
24 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
25 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
3 |
/**
|
4 |
* Plugin Name: WooCommerce Checkout Manager
|
5 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
6 |
+
* Version: 5.1.2
|
7 |
* Author: QuadLayers
|
8 |
* Author URI: https://www.quadlayers.com
|
9 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
19 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
20 |
}
|
21 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
22 |
+
define('WOOCCM_PLUGIN_VERSION', '5.1.2');
|
23 |
}
|
24 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
25 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|