Version Description
Download this release
Release Info
Developer | quadlayers |
Plugin | WooCommerce Checkout Manager |
Version | 6.1.0 |
Comparing to | |
See all releases |
Code changes from version 6.0.9 to 6.1.0
includes/controller/class-wooccm-checkout.php
CHANGED
@@ -1,414 +1,416 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class WOOCCM_Checkout_Controller
|
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 |
-
if (is_checkout() || is_account_page()) {
|
46 |
-
|
47 |
-
WOOCCM()->register_scripts();
|
48 |
-
|
49 |
-
$i18n = substr(get_user_locale(), 0, 2);
|
50 |
-
|
51 |
-
wp_enqueue_style('wooccm');
|
52 |
-
|
53 |
-
// Colorpicker
|
54 |
-
// ---------------------------------------------------------------------
|
55 |
-
wp_enqueue_style('wp-color-picker');
|
56 |
-
wp_enqueue_script('wp-color-picker');
|
57 |
-
|
58 |
-
// Farbtastic
|
59 |
-
// ---------------------------------------------------------------------
|
60 |
-
wp_enqueue_style('farbtastic');
|
61 |
-
wp_enqueue_script('farbtastic');
|
62 |
-
|
63 |
-
// Dashicons
|
64 |
-
// ---------------------------------------------------------------------
|
65 |
-
wp_enqueue_style('dashicons');
|
66 |
-
|
67 |
-
|
68 |
-
// Checkout
|
69 |
-
// ---------------------------------------------------------------------
|
70 |
-
wp_enqueue_script('wooccm-checkout');
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
public function add_inline_scripts()
|
75 |
-
{
|
76 |
-
|
77 |
-
if (get_option('wooccm_checkout_force_shipping_address', 'no') == 'yes') {
|
78 |
-
?>
|
79 |
-
<style>
|
80 |
-
#ship-to-different-address-checkbox {
|
81 |
-
display: none;
|
82 |
}
|
83 |
-
|
84 |
-
|
85 |
-
display: block !important;
|
86 |
-
}
|
87 |
-
</style>
|
88 |
-
<?php
|
89 |
-
}
|
90 |
-
|
91 |
-
if (get_option('wooccm_checkout_force_create_account', 'no') == 'yes') {
|
92 |
-
?>
|
93 |
-
<style>
|
94 |
-
div.create-account {
|
95 |
-
display: block !important;
|
96 |
-
}
|
97 |
-
|
98 |
-
p.create-account {
|
99 |
-
display: none !important;
|
100 |
-
}
|
101 |
-
</style>
|
102 |
-
<script>
|
103 |
-
jQuery(document).ready(function(e) {
|
104 |
-
jQuery("input#createaccount").prop('checked', 'checked');
|
105 |
-
});
|
106 |
-
</script>
|
107 |
-
<?php
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
// Frontend
|
112 |
-
// -------------------------------------------------------------------------
|
113 |
-
public function order_notes($fields)
|
114 |
-
{
|
115 |
-
|
116 |
-
$options = get_option('wccs_settings');
|
117 |
-
|
118 |
-
if ($label = get_option('wooccm_checkout_order_notes_label', false)) {
|
119 |
-
$fields['order']['order_comments']['label'] = $label;
|
120 |
-
}
|
121 |
-
|
122 |
-
if ($placeholder = get_option('wooccm_checkout_order_notes_placeholder', false)) {
|
123 |
-
$fields['order']['order_comments']['placeholder'] = $placeholder;
|
124 |
-
}
|
125 |
-
|
126 |
-
if (get_option('wooccm_checkout_remove_order_notes', 'no') === 'yes') {
|
127 |
-
unset($fields['order']['order_comments']);
|
128 |
-
}
|
129 |
-
|
130 |
-
return $fields;
|
131 |
-
}
|
132 |
-
|
133 |
-
public function remove_order_notes($value)
|
134 |
-
{
|
135 |
-
|
136 |
-
if (get_option('wooccm_checkout_remove_order_notes', 'no') === 'yes') {
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
return $value;
|
141 |
-
}
|
142 |
-
|
143 |
-
function add_checkout_form_before_message($param)
|
144 |
-
{
|
145 |
-
|
146 |
-
if ($text = get_option('wooccm_checkout_checkout_form_before_message', false)) {
|
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 |
-
}
|
156 |
-
|
157 |
-
function add_checkout_form_after_message($param)
|
158 |
-
{
|
159 |
-
|
160 |
-
if ($text = get_option('wooccm_checkout_checkout_form_after_message', false)) {
|
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 |
-
}
|
170 |
-
|
171 |
-
// Admin
|
172 |
-
// ---------------------------------------------------------------------------
|
173 |
-
|
174 |
-
public function get_settings()
|
175 |
-
{
|
176 |
-
|
177 |
-
return array(
|
178 |
-
array(
|
179 |
-
'type' => 'title',
|
180 |
-
'id' => 'section_title'
|
181 |
-
),
|
182 |
-
array(
|
183 |
-
'name' => esc_html__('Force shipping address', 'woocommerce-checkout-manager'),
|
184 |
-
'desc_tip' => esc_html__('Force show shipping checkout fields.', 'woocommerce-checkout-manager'),
|
185 |
-
'id' => 'wooccm_checkout_force_shipping_address',
|
186 |
-
'type' => 'select',
|
187 |
-
'class' => 'chosen_select',
|
188 |
-
'options' => array(
|
189 |
-
'yes' => esc_html__('Yes', 'woocommerce-checkout-manager'),
|
190 |
-
'no' => esc_html__('No', 'woocommerce-checkout-manager'),
|
191 |
-
),
|
192 |
-
'default' => 'no',
|
193 |
-
),
|
194 |
-
array(
|
195 |
-
'name' => esc_html__('Force create an account', 'woocommerce-checkout-manager'),
|
196 |
-
'desc_tip' => esc_html__('Force create an account for guests users.', 'woocommerce-checkout-manager'),
|
197 |
-
'id' => 'wooccm_checkout_force_create_account',
|
198 |
-
'type' => 'select',
|
199 |
-
'class' => 'chosen_select',
|
200 |
-
'options' => array(
|
201 |
-
'yes' => esc_html__('Yes', 'woocommerce-checkout-manager'),
|
202 |
-
'no' => esc_html__('No', 'woocommerce-checkout-manager'),
|
203 |
-
),
|
204 |
-
'default' => 'no',
|
205 |
-
),
|
206 |
-
array(
|
207 |
-
'name' => esc_html__('Remove order notes', 'woocommerce-checkout-manager'),
|
208 |
-
'desc_tip' => esc_html__('Remove order notes from checkout page.', 'woocommerce-checkout-manager'),
|
209 |
-
'id' => 'wooccm_checkout_remove_order_notes',
|
210 |
-
'type' => 'select',
|
211 |
-
'class' => 'chosen_select',
|
212 |
-
'options' => array(
|
213 |
-
'yes' => esc_html__('Yes', 'woocommerce-checkout-manager'),
|
214 |
-
'no' => esc_html__('No', 'woocommerce-checkout-manager'),
|
215 |
-
),
|
216 |
-
'default' => 'no',
|
217 |
-
),
|
218 |
-
array(
|
219 |
-
'name' => esc_html__('Order notes label', 'woocommerce-checkout-manager'),
|
220 |
-
'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
221 |
-
'id' => 'wooccm_checkout_order_notes_label',
|
222 |
-
'type' => 'text',
|
223 |
-
'placeholder' => esc_attr__('Order notes', 'woocommerce-checkout-manager'),
|
224 |
-
),
|
225 |
-
array(
|
226 |
-
'name' => esc_html__('Order notes placeholder', 'woocommerce-checkout-manager'),
|
227 |
-
'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
228 |
-
'id' => 'wooccm_checkout_order_notes_placeholder',
|
229 |
-
'type' => 'text',
|
230 |
-
'placeholder' => esc_attr__('Notes about your order, e.g. special notes for delivery.', 'woocommerce-checkout-manager'),
|
231 |
-
),
|
232 |
-
array(
|
233 |
-
'name' => esc_html__('Add message before checkout', 'woocommerce-checkout-manager'),
|
234 |
-
'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
235 |
-
'id' => 'wooccm_checkout_checkout_form_before_message',
|
236 |
-
'type' => 'textarea',
|
237 |
-
'placeholder' => ''
|
238 |
-
),
|
239 |
-
array(
|
240 |
-
'name' => esc_html__('Add message after checkout', 'woocommerce-checkout-manager'),
|
241 |
-
'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
242 |
-
'id' => 'wooccm_checkout_checkout_form_after_message',
|
243 |
-
'type' => 'textarea',
|
244 |
-
'placeholder' => ''
|
245 |
-
),
|
246 |
-
// thankyou
|
247 |
-
// -------------------------------------------------------------------------
|
248 |
-
//array(
|
249 |
-
// 'name' => esc_html__('Add thankyou custom fields', 'woocommerce-checkout-manager'),
|
250 |
-
// 'desc_tip' => esc_html__('Show the selected fields in the thankyou page.', 'woocommerce-checkout-manager'),
|
251 |
-
// 'id' => 'wooccm_checkout_thankyou_custom_fields',
|
252 |
-
// 'type' => 'select',
|
253 |
-
// 'class' => 'chosen_select',
|
254 |
-
// 'options' => array(
|
255 |
-
// 'yes' => esc_html__('Yes', 'woocommerce-checkout-manager'),
|
256 |
-
// 'no' => esc_html__('No', 'woocommerce-checkout-manager'),
|
257 |
-
// ),
|
258 |
-
// 'default' => 'no',
|
259 |
-
// ),
|
260 |
-
//array(
|
261 |
-
// 'name' => esc_html__('Add thankyou custom fields title', 'woocommerce-checkout-manager'),
|
262 |
-
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
263 |
-
// 'id' => 'wooccm_checkout_thankyou_custom_fields_text',
|
264 |
-
// 'type' => 'text',
|
265 |
-
// 'placeholder' => esc_html__('Checkout extra', 'woocommerce-checkout-manager')
|
266 |
-
// ),
|
267 |
-
// upload
|
268 |
-
// -------------------------------------------------------------------------
|
269 |
-
//array(
|
270 |
-
// 'name' => esc_html__('Add upload files limit', 'woocommerce-checkout-manager'),
|
271 |
-
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
272 |
-
// 'id' => 'wooccm_checkout_upload_files_limit',
|
273 |
-
// 'type' => 'number',
|
274 |
-
// 'placeholder' => 4
|
275 |
-
// ),
|
276 |
-
//array(
|
277 |
-
// 'name' => esc_html__('Add upload files types', 'woocommerce-checkout-manager'),
|
278 |
-
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
279 |
-
// 'id' => 'wooccm_checkout_upload_files_types',
|
280 |
-
// 'type' => 'text',
|
281 |
-
// 'placeholder' => 'jpg,gif,png'
|
282 |
-
// ),
|
283 |
-
array(
|
284 |
-
'type' => 'sectionend',
|
285 |
-
'id' => 'section_end'
|
286 |
-
)
|
287 |
-
);
|
288 |
-
}
|
289 |
-
|
290 |
-
public function add_header()
|
291 |
-
{
|
292 |
-
global $current_section;
|
293 |
-
?>
|
294 |
-
<li><a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=wooccm§ion' ) ); ?>" class="<?php echo ($current_section == '' ? 'current' : ''); ?>"><?php esc_html_e('Checkout', 'woocommerce-checkout-manager'); ?></a> | </li>
|
295 |
-
<?php
|
296 |
-
}
|
297 |
|
298 |
-
|
299 |
-
|
300 |
|
301 |
-
|
302 |
|
303 |
-
|
304 |
|
305 |
-
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
310 |
|
311 |
-
|
312 |
-
|
|
|
|
|
313 |
|
314 |
-
|
|
|
|
|
315 |
|
316 |
-
|
|
|
|
|
|
|
|
|
317 |
|
318 |
-
|
319 |
-
}
|
320 |
-
}
|
321 |
|
322 |
-
|
323 |
-
// ---------------------------------------------------------------------------
|
324 |
|
325 |
-
|
326 |
-
|
327 |
|
328 |
-
|
329 |
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
340 |
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
|
344 |
-
|
|
|
|
|
|
|
345 |
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
|
350 |
-
|
351 |
-
|
|
|
352 |
|
353 |
-
|
354 |
-
|
|
|
355 |
|
356 |
-
|
|
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
361 |
|
362 |
-
|
363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
-
|
366 |
-
|
367 |
|
368 |
-
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
|
374 |
-
|
375 |
-
|
376 |
|
377 |
-
|
378 |
-
|
379 |
|
380 |
-
|
|
|
|
|
381 |
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
|
386 |
-
|
387 |
-
|
388 |
|
389 |
-
|
390 |
-
|
391 |
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
|
394 |
-
|
395 |
-
|
396 |
-
}
|
397 |
|
398 |
-
|
399 |
-
|
|
|
400 |
|
401 |
-
|
402 |
-
|
403 |
|
404 |
-
|
|
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
|
410 |
-
|
411 |
-
|
412 |
}
|
413 |
|
414 |
WOOCCM_Checkout_Controller::instance();
|
1 |
<?php
|
2 |
|
3 |
+
class WOOCCM_Checkout_Controller {
|
4 |
+
|
5 |
+
protected static $_instance;
|
6 |
+
|
7 |
+
public function __construct() {
|
8 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
9 |
+
add_action( 'wooccm_sections_header', array( $this, 'add_header' ) );
|
10 |
+
add_action( 'woocommerce_sections_' . WOOCCM_PREFIX, array( $this, 'add_section' ), 99 );
|
11 |
+
add_action( 'woocommerce_settings_save_' . WOOCCM_PREFIX, array( $this, 'save_settings' ) );
|
12 |
+
|
13 |
+
// Force Shipping Address
|
14 |
+
// -----------------------------------------------------------------------
|
15 |
+
add_action( 'woocommerce_before_checkout_form', array( $this, 'add_inline_scripts' ) );
|
16 |
+
add_filter( 'woocommerce_checkout_posted_data', array( $this, 'checkout_force_shipping_address' ) );
|
17 |
+
|
18 |
+
// Note that this overrides the 'Shipping Destination' option in the Woo settings
|
19 |
+
add_filter( 'woocommerce_ship_to_different_address_checked', array( $this, 'force_shipping_address' ) );
|
20 |
+
// If you have the possibility of virtual-only orders you may want to comment this out
|
21 |
+
add_filter( 'woocommerce_cart_needs_shipping_address', array( $this, 'force_shipping_address' ) );
|
22 |
+
// Order always has shipping (even with local pickup for example)
|
23 |
+
add_filter( 'woocommerce_order_needs_shipping_address', array( $this, 'force_shipping_address' ) );
|
24 |
+
|
25 |
+
// Order Hooks
|
26 |
+
add_action( 'woocommerce_checkout_fields', array( $this, 'order_notes' ) );
|
27 |
+
add_action( 'woocommerce_before_checkout_form', array( $this, 'add_checkout_form_before_message' ) );
|
28 |
+
add_action( 'woocommerce_after_checkout_form', array( $this, 'add_checkout_form_after_message' ) );
|
29 |
+
add_action( 'woocommerce_enable_order_notes_field', array( $this, 'remove_order_notes' ) );
|
30 |
+
|
31 |
+
// Compatibility
|
32 |
+
// -----------------------------------------------------------------------
|
33 |
+
add_filter( 'default_option_wooccm_checkout_force_shipping_address', array( $this, 'additional_info' ) );
|
34 |
+
add_filter( 'default_option_wooccm_checkout_force_create_account', array( $this, 'auto_create_wccm_account' ) );
|
35 |
+
add_filter( 'default_option_wooccm_checkout_remove_order_notes', array( $this, 'notesenable' ) );
|
36 |
+
add_filter( 'default_option_wooccm_checkout_order_notes_label', array( $this, 'noteslabel' ) );
|
37 |
+
add_filter( 'default_option_wooccm_checkout_order_notes_placeholder', array( $this, 'notesplaceholder' ) );
|
38 |
+
add_filter( 'default_option_wooccm_checkout_checkout_form_before_message', array( $this, 'text1' ) );
|
39 |
+
add_filter( 'default_option_wooccm_checkout_checkout_form_after_message', array( $this, 'text2' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
public static function instance() {
|
43 |
+
if ( is_null( self::$_instance ) ) {
|
44 |
+
self::$_instance = new self();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
+
return self::$_instance;
|
47 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
public function enqueue_scripts() {
|
50 |
+
if ( is_checkout() || is_account_page() ) {
|
51 |
|
52 |
+
WOOCCM()->register_scripts();
|
53 |
|
54 |
+
$i18n = substr( get_user_locale(), 0, 2 );
|
55 |
|
56 |
+
wp_enqueue_style( 'wooccm' );
|
57 |
|
58 |
+
// Colorpicker
|
59 |
+
// ---------------------------------------------------------------------
|
60 |
+
wp_enqueue_style( 'wp-color-picker' );
|
61 |
+
wp_enqueue_script( 'wp-color-picker' );
|
62 |
|
63 |
+
// Farbtastic
|
64 |
+
// ---------------------------------------------------------------------
|
65 |
+
wp_enqueue_style( 'farbtastic' );
|
66 |
+
wp_enqueue_script( 'farbtastic' );
|
67 |
|
68 |
+
// Dashicons
|
69 |
+
// ---------------------------------------------------------------------
|
70 |
+
wp_enqueue_style( 'dashicons' );
|
71 |
|
72 |
+
// Checkout
|
73 |
+
// ---------------------------------------------------------------------
|
74 |
+
wp_enqueue_script( 'wooccm-checkout' );
|
75 |
+
}
|
76 |
+
}
|
77 |
|
78 |
+
public function checkout_force_shipping_address( $posted_data ) {
|
|
|
|
|
79 |
|
80 |
+
$posted_data['ship_to_different_address'] = true;
|
|
|
81 |
|
82 |
+
return $posted_data;
|
83 |
+
}
|
84 |
|
85 |
+
public function force_shipping_address( $value ) {
|
86 |
|
87 |
+
if ( get_option( 'wooccm_checkout_force_shipping_address', 'no' ) === 'yes' ) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
|
91 |
+
return $value;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function add_inline_scripts() {
|
95 |
+
if ( get_option( 'wooccm_checkout_force_shipping_address', 'no' ) === 'yes' ) {
|
96 |
+
?>
|
97 |
+
<style>
|
98 |
+
#ship-to-different-address {
|
99 |
+
pointer-events: none!important;
|
100 |
+
}
|
101 |
+
#ship-to-different-address-checkbox {
|
102 |
+
display: none;
|
103 |
+
}
|
104 |
+
.woocommerce-shipping-fields .shipping_address {
|
105 |
+
height: auto !important;
|
106 |
+
display: block !important;
|
107 |
+
}
|
108 |
+
</style>
|
109 |
+
<?php
|
110 |
+
}
|
111 |
|
112 |
+
if ( get_option( 'wooccm_checkout_force_create_account', 'no' ) === 'yes' ) {
|
113 |
+
?>
|
114 |
+
<style>
|
115 |
+
div.create-account {
|
116 |
+
display: block !important;
|
117 |
+
}
|
118 |
|
119 |
+
p.create-account {
|
120 |
+
display: none !important;
|
121 |
+
}
|
122 |
+
</style>
|
123 |
+
<script>
|
124 |
+
jQuery(document).ready(function(e) {
|
125 |
+
jQuery("input#createaccount").prop('checked', 'checked');
|
126 |
+
});
|
127 |
+
</script>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
}
|
131 |
|
132 |
+
// Frontend
|
133 |
+
// -------------------------------------------------------------------------
|
134 |
+
public function order_notes( $fields ) {
|
135 |
+
$options = get_option( 'wccs_settings' );
|
136 |
|
137 |
+
if ( $label = get_option( 'wooccm_checkout_order_notes_label', false ) ) {
|
138 |
+
$fields['order']['order_comments']['label'] = $label;
|
139 |
+
}
|
140 |
|
141 |
+
if ( $placeholder = get_option( 'wooccm_checkout_order_notes_placeholder', false ) ) {
|
142 |
+
$fields['order']['order_comments']['placeholder'] = $placeholder;
|
143 |
+
}
|
144 |
|
145 |
+
if ( get_option( 'wooccm_checkout_remove_order_notes', 'no' ) === 'yes' ) {
|
146 |
+
unset( $fields['order']['order_comments'] );
|
147 |
+
}
|
148 |
|
149 |
+
return $fields;
|
150 |
+
}
|
151 |
|
152 |
+
public function remove_order_notes( $value ) {
|
153 |
+
if ( get_option( 'wooccm_checkout_remove_order_notes', 'no' ) === 'yes' ) {
|
154 |
+
return false;
|
155 |
+
}
|
156 |
|
157 |
+
return $value;
|
158 |
+
}
|
159 |
+
|
160 |
+
function add_checkout_form_before_message( $param ) {
|
161 |
+
if ( $text = get_option( 'wooccm_checkout_checkout_form_before_message', false ) ) {
|
162 |
+
|
163 |
+
wc_get_template(
|
164 |
+
'notices/notice.php',
|
165 |
+
array(
|
166 |
+
'messages' => array_filter( (array) $text ),
|
167 |
+
'notices' => array(
|
168 |
+
0 => array(
|
169 |
+
'notice' => $text,
|
170 |
+
),
|
171 |
+
),
|
172 |
+
)
|
173 |
+
);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
function add_checkout_form_after_message( $param ) {
|
178 |
+
if ( $text = get_option( 'wooccm_checkout_checkout_form_after_message', false ) ) {
|
179 |
+
|
180 |
+
wc_get_template(
|
181 |
+
'notices/notice.php',
|
182 |
+
array(
|
183 |
+
'messages' => array_filter( (array) $text ),
|
184 |
+
'notices' => array(
|
185 |
+
0 => array(
|
186 |
+
'notice' => $text,
|
187 |
+
),
|
188 |
+
),
|
189 |
+
)
|
190 |
+
);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
// Admin
|
195 |
+
// ---------------------------------------------------------------------------
|
196 |
+
|
197 |
+
public function get_settings() {
|
198 |
+
return array(
|
199 |
+
array(
|
200 |
+
'type' => 'title',
|
201 |
+
'id' => 'section_title',
|
202 |
+
),
|
203 |
+
array(
|
204 |
+
'name' => esc_html__( 'Force shipping address', 'woocommerce-checkout-manager' ),
|
205 |
+
'desc_tip' => esc_html__( 'Force show shipping checkout fields.', 'woocommerce-checkout-manager' ),
|
206 |
+
'id' => 'wooccm_checkout_force_shipping_address',
|
207 |
+
'type' => 'select',
|
208 |
+
'class' => 'chosen_select',
|
209 |
+
'options' => array(
|
210 |
+
'yes' => esc_html__( 'Yes', 'woocommerce-checkout-manager' ),
|
211 |
+
'no' => esc_html__( 'No', 'woocommerce-checkout-manager' ),
|
212 |
+
),
|
213 |
+
'default' => 'no',
|
214 |
+
),
|
215 |
+
array(
|
216 |
+
'name' => esc_html__( 'Force create an account', 'woocommerce-checkout-manager' ),
|
217 |
+
'desc_tip' => esc_html__( 'Force create an account for guests users.', 'woocommerce-checkout-manager' ),
|
218 |
+
'id' => 'wooccm_checkout_force_create_account',
|
219 |
+
'type' => 'select',
|
220 |
+
'class' => 'chosen_select',
|
221 |
+
'options' => array(
|
222 |
+
'yes' => esc_html__( 'Yes', 'woocommerce-checkout-manager' ),
|
223 |
+
'no' => esc_html__( 'No', 'woocommerce-checkout-manager' ),
|
224 |
+
),
|
225 |
+
'default' => 'no',
|
226 |
+
),
|
227 |
+
array(
|
228 |
+
'name' => esc_html__( 'Remove order notes', 'woocommerce-checkout-manager' ),
|
229 |
+
'desc_tip' => esc_html__( 'Remove order notes from checkout page.', 'woocommerce-checkout-manager' ),
|
230 |
+
'id' => 'wooccm_checkout_remove_order_notes',
|
231 |
+
'type' => 'select',
|
232 |
+
'class' => 'chosen_select',
|
233 |
+
'options' => array(
|
234 |
+
'yes' => esc_html__( 'Yes', 'woocommerce-checkout-manager' ),
|
235 |
+
'no' => esc_html__( 'No', 'woocommerce-checkout-manager' ),
|
236 |
+
),
|
237 |
+
'default' => 'no',
|
238 |
+
),
|
239 |
+
array(
|
240 |
+
'name' => esc_html__( 'Order notes label', 'woocommerce-checkout-manager' ),
|
241 |
+
'desc_tip' => esc_html__( 'Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager' ),
|
242 |
+
'id' => 'wooccm_checkout_order_notes_label',
|
243 |
+
'type' => 'text',
|
244 |
+
'placeholder' => esc_attr__( 'Order notes', 'woocommerce-checkout-manager' ),
|
245 |
+
),
|
246 |
+
array(
|
247 |
+
'name' => esc_html__( 'Order notes placeholder', 'woocommerce-checkout-manager' ),
|
248 |
+
'desc_tip' => esc_html__( 'Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager' ),
|
249 |
+
'id' => 'wooccm_checkout_order_notes_placeholder',
|
250 |
+
'type' => 'text',
|
251 |
+
'placeholder' => esc_attr__( 'Notes about your order, e.g. special notes for delivery.', 'woocommerce-checkout-manager' ),
|
252 |
+
),
|
253 |
+
array(
|
254 |
+
'name' => esc_html__( 'Add message before checkout', 'woocommerce-checkout-manager' ),
|
255 |
+
'desc_tip' => esc_html__( 'Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager' ),
|
256 |
+
'id' => 'wooccm_checkout_checkout_form_before_message',
|
257 |
+
'type' => 'textarea',
|
258 |
+
'placeholder' => '',
|
259 |
+
),
|
260 |
+
array(
|
261 |
+
'name' => esc_html__( 'Add message after checkout', 'woocommerce-checkout-manager' ),
|
262 |
+
'desc_tip' => esc_html__( 'Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager' ),
|
263 |
+
'id' => 'wooccm_checkout_checkout_form_after_message',
|
264 |
+
'type' => 'textarea',
|
265 |
+
'placeholder' => '',
|
266 |
+
),
|
267 |
+
// thankyou
|
268 |
+
// -------------------------------------------------------------------------
|
269 |
+
// array(
|
270 |
+
// 'name' => esc_html__('Add thankyou custom fields', 'woocommerce-checkout-manager'),
|
271 |
+
// 'desc_tip' => esc_html__('Show the selected fields in the thankyou page.', 'woocommerce-checkout-manager'),
|
272 |
+
// 'id' => 'wooccm_checkout_thankyou_custom_fields',
|
273 |
+
// 'type' => 'select',
|
274 |
+
// 'class' => 'chosen_select',
|
275 |
+
// 'options' => array(
|
276 |
+
// 'yes' => esc_html__('Yes', 'woocommerce-checkout-manager'),
|
277 |
+
// 'no' => esc_html__('No', 'woocommerce-checkout-manager'),
|
278 |
+
// ),
|
279 |
+
// 'default' => 'no',
|
280 |
+
// ),
|
281 |
+
// array(
|
282 |
+
// 'name' => esc_html__('Add thankyou custom fields title', 'woocommerce-checkout-manager'),
|
283 |
+
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
284 |
+
// 'id' => 'wooccm_checkout_thankyou_custom_fields_text',
|
285 |
+
// 'type' => 'text',
|
286 |
+
// 'placeholder' => esc_html__('Checkout extra', 'woocommerce-checkout-manager')
|
287 |
+
// ),
|
288 |
+
// upload
|
289 |
+
// -------------------------------------------------------------------------
|
290 |
+
// array(
|
291 |
+
// 'name' => esc_html__('Add upload files limit', 'woocommerce-checkout-manager'),
|
292 |
+
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
293 |
+
// 'id' => 'wooccm_checkout_upload_files_limit',
|
294 |
+
// 'type' => 'number',
|
295 |
+
// 'placeholder' => 4
|
296 |
+
// ),
|
297 |
+
// array(
|
298 |
+
// 'name' => esc_html__('Add upload files types', 'woocommerce-checkout-manager'),
|
299 |
+
// 'desc_tip' => esc_html__('Add custom title for the custom fields table in the thankyou page.', 'woocommerce-checkout-manager'),
|
300 |
+
// 'id' => 'wooccm_checkout_upload_files_types',
|
301 |
+
// 'type' => 'text',
|
302 |
+
// 'placeholder' => 'jpg,gif,png'
|
303 |
+
// ),
|
304 |
+
array(
|
305 |
+
'type' => 'sectionend',
|
306 |
+
'id' => 'section_end',
|
307 |
+
),
|
308 |
+
);
|
309 |
+
}
|
310 |
+
|
311 |
+
public function add_header() {
|
312 |
+
global $current_section;
|
313 |
+
?>
|
314 |
+
<li><a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=wooccm§ion' ) ); ?>" class="<?php echo ( $current_section == '' ? 'current' : '' ); ?>"><?php esc_html_e( 'Checkout', 'woocommerce-checkout-manager' ); ?></a> | </li>
|
315 |
+
<?php
|
316 |
+
}
|
317 |
+
|
318 |
+
public function add_section() {
|
319 |
+
global $current_section;
|
320 |
+
|
321 |
+
if ( '' == $current_section ) {
|
322 |
+
|
323 |
+
$settings = $this->get_settings();
|
324 |
+
|
325 |
+
include_once WOOCCM_PLUGIN_DIR . 'includes/view/backend/pages/checkout.php';
|
326 |
+
}
|
327 |
+
}
|
328 |
|
329 |
+
public function save_settings() {
|
330 |
+
global $current_section;
|
331 |
|
332 |
+
if ( '' == $current_section ) {
|
333 |
|
334 |
+
woocommerce_update_options( $this->get_settings() );
|
335 |
+
}
|
336 |
+
}
|
337 |
|
338 |
+
// Compatibility
|
339 |
+
// ---------------------------------------------------------------------------
|
340 |
|
341 |
+
public function additional_info( $value ) {
|
342 |
+
$options = get_option( 'wccs_settings' );
|
343 |
|
344 |
+
if ( ! empty( $options['checkness']['additional_info'] ) ) {
|
345 |
+
return 'yes';
|
346 |
+
}
|
347 |
|
348 |
+
if ( ! empty( $options['checkness']['show_shipping_fields'] ) ) {
|
349 |
+
return 'yes';
|
350 |
+
}
|
351 |
|
352 |
+
return $value;
|
353 |
+
}
|
354 |
|
355 |
+
public function auto_create_wccm_account( $value ) {
|
356 |
+
$options = get_option( 'wccs_settings' );
|
357 |
|
358 |
+
if ( ! empty( $options['checkness']['auto_create_wccm_account'] ) ) {
|
359 |
+
return 'yes';
|
360 |
+
}
|
361 |
+
|
362 |
+
return $value;
|
363 |
+
}
|
364 |
+
|
365 |
+
public function notesenable( $value ) {
|
366 |
+
$options = get_option( 'wccs_settings' );
|
367 |
+
|
368 |
+
if ( ! empty( $options['checkness']['notesenable'] ) ) {
|
369 |
+
return 'yes';
|
370 |
+
}
|
371 |
+
|
372 |
+
return $value;
|
373 |
+
}
|
374 |
+
|
375 |
+
public function noteslabel( $value ) {
|
376 |
+
$options = get_option( 'wccs_settings' );
|
377 |
+
|
378 |
+
if ( $text = @$options['checkness']['noteslabel'] ) {
|
379 |
+
return $text;
|
380 |
+
}
|
381 |
+
|
382 |
+
return $value;
|
383 |
+
}
|
384 |
+
|
385 |
+
public function notesplaceholder( $value ) {
|
386 |
+
$options = get_option( 'wccs_settings' );
|
387 |
+
|
388 |
+
if ( $text = @$options['checkness']['notesplaceholder'] ) {
|
389 |
+
return $text;
|
390 |
+
}
|
391 |
+
|
392 |
+
return $value;
|
393 |
+
}
|
394 |
|
395 |
+
public function text1( $value ) {
|
396 |
+
$options = get_option( 'wccs_settings' );
|
|
|
397 |
|
398 |
+
if ( $text = @$options['checkness']['text1'] ) {
|
399 |
+
return $text;
|
400 |
+
}
|
401 |
|
402 |
+
return $value;
|
403 |
+
}
|
404 |
|
405 |
+
public function text2( $value ) {
|
406 |
+
$options = get_option( 'wccs_settings' );
|
407 |
|
408 |
+
if ( $text = @$options['checkness']['text2'] ) {
|
409 |
+
return $text;
|
410 |
+
}
|
411 |
|
412 |
+
return $value;
|
413 |
+
}
|
414 |
}
|
415 |
|
416 |
WOOCCM_Checkout_Controller::instance();
|
includes/controller/class-wooccm-field.php
CHANGED
@@ -14,6 +14,7 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
14 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-billing.php');
|
15 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-shipping.php');
|
16 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-additional.php');
|
|
|
17 |
|
18 |
if (!is_admin()) {
|
19 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-register.php');
|
@@ -21,7 +22,6 @@ class WOOCCM_Field_Controller extends WOOCCM_Controller
|
|
21 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-disable.php');
|
22 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-conditional.php');
|
23 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-handler.php');
|
24 |
-
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-i18n.php');
|
25 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-filters.php');
|
26 |
}
|
27 |
|
14 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-billing.php');
|
15 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-shipping.php');
|
16 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/controller/class-wooccm-field-additional.php');
|
17 |
+
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-i18n.php');
|
18 |
|
19 |
if (!is_admin()) {
|
20 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-register.php');
|
22 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-disable.php');
|
23 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-conditional.php');
|
24 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-handler.php');
|
|
|
25 |
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/frontend/class-wooccm-fields-filters.php');
|
26 |
}
|
27 |
|
includes/view/frontend/class-wooccm-fields-i18n.php
CHANGED
@@ -1,94 +1,180 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class WOOCCM_Fields_i18n
|
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 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
WOOCCM_Fields_i18n::instance();
|
1 |
<?php
|
2 |
|
3 |
+
class WOOCCM_Fields_i18n {
|
4 |
+
|
5 |
+
protected static $_instance;
|
6 |
+
protected static $domain = 'woocommerce';
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
add_action( 'init', array( $this, 'init_polylang' ) );
|
10 |
+
add_action( 'admin_init', array( $this, 'init_wpml' ) );
|
11 |
+
// add_filter( 'wooccm_checkout_field_filter', array( $this, 'translate_field' ) );
|
12 |
+
}
|
13 |
+
|
14 |
+
function init_polylang() {
|
15 |
+
|
16 |
+
if ( function_exists( 'pll_register_string' ) ) {
|
17 |
+
|
18 |
+
$billing_fields = WOOCCM()->billing->get_fields();
|
19 |
+
$billing_label = esc_html__( 'Billing', 'woocommerce-checkout-manager' );
|
20 |
+
|
21 |
+
$shipping_fields = WOOCCM()->shipping->get_fields();
|
22 |
+
$shipping_label = esc_html__( 'Shipping', 'woocommerce-checkout-manager' );
|
23 |
+
|
24 |
+
$additional_fields = WOOCCM()->additional->get_fields();
|
25 |
+
$additional_label = esc_html__( 'Additional', 'woocommerce-checkout-manager' );
|
26 |
+
|
27 |
+
$this->register_polylang_fields( $billing_fields, $billing_label );
|
28 |
+
$this->register_polylang_fields( $shipping_fields, $shipping_label );
|
29 |
+
$this->register_polylang_fields( $additional_fields, $additional_label );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
function init_wpml() {
|
34 |
+
if ( function_exists( 'icl_register_string' ) ) {
|
35 |
+
|
36 |
+
$billing_fields = WOOCCM()->billing->get_fields();
|
37 |
+
$billing_label = esc_html__( 'Billing', 'woocommerce-checkout-manager' );
|
38 |
+
|
39 |
+
$shipping_fields = WOOCCM()->shipping->get_fields();
|
40 |
+
$shipping_label = esc_html__( 'Shipping', 'woocommerce-checkout-manager' );
|
41 |
+
|
42 |
+
$additional_fields = WOOCCM()->additional->get_fields();
|
43 |
+
$additional_label = esc_html__( 'Additional', 'woocommerce-checkout-manager' );
|
44 |
+
|
45 |
+
$this->register_wpml_fields( $billing_fields, $billing_label );
|
46 |
+
$this->register_wpml_fields( $shipping_fields, $shipping_label );
|
47 |
+
$this->register_wpml_fields( $additional_fields, $additional_label );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
function register_polylang_fields( $fields, $label ) {
|
52 |
+
|
53 |
+
if ( function_exists( 'pll_register_string' ) ) {
|
54 |
+
|
55 |
+
if ( is_array( $fields ) ) {
|
56 |
+
|
57 |
+
$name = sprintf( 'WCM / %s', $label );
|
58 |
+
|
59 |
+
foreach ( $fields as $field ) {
|
60 |
+
if ( isset( $field['label'] ) && $field['label'] != '' ) {
|
61 |
+
pll_register_string( $field['label'], $field['label'], $name );
|
62 |
+
}
|
63 |
+
if ( isset( $field['placeholder'] ) && $field['placeholder'] != '' ) {
|
64 |
+
pll_register_string( $field['placeholder'], $field['placeholder'], $name );
|
65 |
+
}
|
66 |
+
if ( isset( $field['description'] ) && $field['description'] != '' ) {
|
67 |
+
pll_register_string( $field['description'], $field['description'], $name );
|
68 |
+
}
|
69 |
+
|
70 |
+
foreach ( $field['options'] as $option_data ) {
|
71 |
+
if ( isset( $field['options'] ) ) {
|
72 |
+
pll_register_string( $option_data['label'], $option_data['label'], sprintf( '%s / %s', $name, $field['label'] ) );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
function register_wpml_fields( $fields, $label ) {
|
81 |
+
|
82 |
+
if ( function_exists( 'icl_register_string' ) ) {
|
83 |
+
|
84 |
+
$icl_language_code = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : get_bloginfo( 'language' );
|
85 |
+
|
86 |
+
if ( is_array( $fields ) ) {
|
87 |
+
|
88 |
+
foreach ( $fields as $field ) {
|
89 |
+
if ( isset( $field['label'] ) && $field['label'] != '' ) {
|
90 |
+
icl_register_string( 'woocommerce-checkout-manager', $field['label'], $field['label'], false, $icl_language_code );
|
91 |
+
}
|
92 |
+
if ( isset( $field['placeholder'] ) && $field['placeholder'] != '' ) {
|
93 |
+
icl_register_string( 'woocommerce-checkout-manager', $field['placeholder'], $field['placeholder'], false, $icl_language_code );
|
94 |
+
}
|
95 |
+
if ( isset( $field['description'] ) && $field['description'] != '' ) {
|
96 |
+
icl_register_string( 'woocommerce-checkout-manager', $field['description'], $field['description'], false, $icl_language_code );
|
97 |
+
}
|
98 |
+
if ( isset( $field['options'] ) ) {
|
99 |
+
foreach ( $field['options'] as $option_data ) {
|
100 |
+
icl_register_string( 'woocommerce-checkout-manager', $option_data['label'], $option_data['label'], false, $icl_language_code );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
public static function instance() {
|
109 |
+
if ( is_null( self::$_instance ) ) {
|
110 |
+
self::$_instance = new self();
|
111 |
+
}
|
112 |
+
return self::$_instance;
|
113 |
+
}
|
114 |
+
|
115 |
+
/*
|
116 |
+
public function register_wpml_string( $value ) {
|
117 |
+
if ( ! empty( $value ) && function_exists( 'icl_register_string' ) ) {
|
118 |
+
|
119 |
+
if ( is_array( $value ) ) {
|
120 |
+
|
121 |
+
foreach ( $value as $key => $name ) {
|
122 |
+
icl_register_string( WOOCCM_PLUGIN_NAME, $name, $name );
|
123 |
+
}
|
124 |
+
|
125 |
+
return $value;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ( is_string( $value ) ) {
|
129 |
+
icl_register_string( WOOCCM_PLUGIN_NAME, $value, $value );
|
130 |
+
return $value;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
return $value;
|
135 |
+
}
|
136 |
+
|
137 |
+
public function i18n( $string ) {
|
138 |
+
if ( function_exists( 'icl_t' ) ) {
|
139 |
+
return icl_t( WOOCCM_PLUGIN_NAME, $string, $string );
|
140 |
+
}
|
141 |
+
|
142 |
+
return esc_html__( $string, self::$domain );
|
143 |
+
}
|
144 |
+
|
145 |
+
public function translate( $value ) {
|
146 |
+
if ( ! empty( $value ) ) {
|
147 |
+
|
148 |
+
if ( is_array( $value ) ) {
|
149 |
+
foreach ( $value as $key => $name ) {
|
150 |
+
if ( is_string( $name ) ) {
|
151 |
+
$value[ $key ] = $this->i18n( $name );
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
if ( is_string( $value ) ) {
|
157 |
+
$value = $this->i18n( $value );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
return $value;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function translate_field( $field ) {
|
165 |
+
// ii18n
|
166 |
+
// -----------------------------------------------------------------------
|
167 |
+
|
168 |
+
if ( ! empty( $field['label'] ) ) {
|
169 |
+
$field['label'] = $this->translate( $field['label'] );
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( ! empty( $field['placeholder'] ) ) {
|
173 |
+
$field['placeholder'] = $this->translate( $field['placeholder'] );
|
174 |
+
}
|
175 |
+
|
176 |
+
return $field;
|
177 |
+
} */
|
178 |
}
|
179 |
|
180 |
WOOCCM_Fields_i18n::instance();
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: checkout field editor, woocommerce checkout field editor, checkout manager
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0.1
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 6.0
|
9 |
WC requires at least: 3.1.0
|
10 |
WC tested up to: 6.7
|
11 |
License: GPLv3
|
@@ -149,6 +149,11 @@ Your Order data can be reviewed in each order within the default WooCommerce Ord
|
|
149 |
|
150 |
== Changelog ==
|
151 |
|
|
|
|
|
|
|
|
|
|
|
152 |
= 6.0.9
|
153 |
* Fix. WooCommerce Checkout required fields save
|
154 |
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0.1
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 6.1.0
|
9 |
WC requires at least: 3.1.0
|
10 |
WC tested up to: 6.7
|
11 |
License: GPLv3
|
149 |
|
150 |
== Changelog ==
|
151 |
|
152 |
+
= 6.1.0
|
153 |
+
* Fix. WooCommerce Checkout force shipping address
|
154 |
+
* Fix. WooCommerce Checkout WPML compatbility
|
155 |
+
* New. WooCommerce Checkout Polylang compatbility
|
156 |
+
|
157 |
= 6.0.9
|
158 |
* Fix. WooCommerce Checkout required fields save
|
159 |
|
woocommerce-checkout-manager.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Checkout Fields Manager for WooCommerce
|
5 |
* Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
|
6 |
* Description: Manage and customize WooCommerce Checkout fields (Add, Edit, Delete or re-order fields).
|
7 |
-
* Version: 6.0
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
@@ -20,7 +20,7 @@ if ( ! defined( 'WOOCCM_PLUGIN_NAME' ) ) {
|
|
20 |
define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
|
21 |
}
|
22 |
if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
|
23 |
-
define( 'WOOCCM_PLUGIN_VERSION', '6.0
|
24 |
}
|
25 |
if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
|
26 |
define( 'WOOCCM_PLUGIN_FILE', __FILE__ );
|
4 |
* Plugin Name: Checkout Fields Manager for WooCommerce
|
5 |
* Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
|
6 |
* Description: Manage and customize WooCommerce Checkout fields (Add, Edit, Delete or re-order fields).
|
7 |
+
* Version: 6.1.0
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
20 |
define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
|
21 |
}
|
22 |
if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
|
23 |
+
define( 'WOOCCM_PLUGIN_VERSION', '6.1.0' );
|
24 |
}
|
25 |
if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
|
26 |
define( 'WOOCCM_PLUGIN_FILE', __FILE__ );
|