PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.7
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / inc / modules / pre-orders / admin / options.php

options.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.7, at inc/modules/pre-orders/admin/options.php

634 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Pre Orders.
4 *
5 * @package Merchant
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly
10 }
11
12
13 /**
14 * Hook functionality before including modules options.
15 *
16 * @since 1.9.8
17 */
18 do_action( 'merchant_admin_before_include_modules_options', Merchant_Pre_Orders::MODULE_ID );
19
20 Merchant_Admin_Options::create(
21 array(
22 'title' => esc_html__( 'Pre-order Rule', 'merchant' ),
23 'module' => Merchant_Pre_Orders::MODULE_ID,
24 'fields' => array(
25 array(
26 'id' => 'rules',
27 'type' => 'flexible_content',
28 'sorting' => true,
29 'duplicate' => true,
30 'accordion' => true,
31 'style' => Merchant_Pre_Orders::MODULE_ID . '-style default',
32 'button_label' => esc_html__( 'Add New Pre-Order', 'merchant' ),
33 'layouts' => array(
34 'rule-details' => array(
35 'title' => esc_html__( 'Campaign', 'merchant' ),
36 'title-field' => 'offer-title', // text field ID to use as title for the layout
37 'status-field' => 'campaign_status',
38 'fields' => array(
39 array(
40 'id' => 'campaign_status',
41 'type' => 'select',
42 'title' => esc_html__( 'Status', 'merchant' ),
43 'options' => array(
44 'active' => esc_html__( 'Active', 'merchant' ),
45 'inactive' => esc_html__( 'Inactive', 'merchant' ),
46 ),
47 'default' => 'active',
48 ),
49 array(
50 'id' => 'offer-title',
51 'type' => 'text',
52 'title' => esc_html__( 'Order name', 'merchant' ),
53 'default' => esc_html__( 'Custom Pre-order', 'merchant' ),
54 'desc' => esc_html__( 'Internal campaign name. This is not visible to customers.', 'merchant' ),
55 ),
56 array(
57 'id' => 'trigger_on',
58 'type' => 'select',
59 'title' => esc_html__( 'Trigger', 'merchant' ),
60 'options' => array(
61 'all' => esc_html__( 'All Products', 'merchant' ),
62 'product' => esc_html__( 'Specific Products', 'merchant' ),
63 'category' => esc_html__( 'Specific Categories', 'merchant' ),
64 'tags' => esc_html__( 'Specific Tags', 'merchant' ),
65 'brands' => esc_html__( 'Specific Brands', 'merchant' ),
66 ),
67 'default' => 'product',
68 ),
69 array(
70 'id' => 'product_ids',
71 'type' => 'products_selector',
72 'multiple' => true,
73 'allowed_types' => array( 'simple', 'variable', 'variation', 'merchant_pro_bundle' ),
74 'desc' => esc_html__( 'Select the product(s) included in this pre-order.', 'merchant' ),
75 'condition' => array( 'trigger_on', '==', 'product' ),
76 ),
77 array(
78 'id' => 'category_slugs',
79 'type' => 'select_ajax',
80 'title' => esc_html__( 'Categories', 'merchant' ),
81 'source' => 'options',
82 'multiple' => true,
83 'options' => Merchant_Admin_Options::get_category_select2_choices(),
84 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
85 'desc' => esc_html__( 'Select the category or categories for which the products will be available for pre-order.', 'merchant' ),
86 'condition' => array( 'trigger_on', '==', 'category' ),
87 ),
88 array(
89 'id' => 'tag_slugs',
90 'type' => 'select_ajax',
91 'title' => esc_html__( 'Tags', 'merchant' ),
92 'source' => 'options',
93 'multiple' => true,
94 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
95 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
96 'desc' => esc_html__( 'Select the tag or tags for which the products will be available for pre-order.', 'merchant' ),
97 'condition' => array( 'trigger_on', '==', 'tags' ),
98 ),
99 array(
100 'id' => 'brand_slugs',
101 'type' => 'select_ajax',
102 'title' => esc_html__( 'Brands', 'merchant' ),
103 'source' => 'options',
104 'multiple' => true,
105 'options' => Merchant_Admin_Options::get_brand_select2_choices(),
106 'placeholder' => esc_html__( 'Select brands', 'merchant' ),
107 'desc' => esc_html__( 'Select the brand or brands for which the products will be available for pre-order.', 'merchant' ),
108 'condition' => array( 'trigger_on', '==', 'brands' ),
109 ),
110
111 // Individual exclusion toggles
112 array(
113 'id' => 'exclude_products_toggle',
114 'type' => 'switcher',
115 'title' => esc_html__( 'Exclude products', 'merchant' ),
116 'desc' => esc_html__( 'Exclude specific products from this pre-order campaign.', 'merchant' ),
117 'default' => 0,
118 'conditions' => array(
119 'relation' => 'AND',
120 'terms' => array(
121 array(
122 'field' => 'trigger_on',
123 'operator' => 'in',
124 'value' => array( 'all', 'category', 'tags', 'brands' ),
125 ),
126 ),
127 ),
128 ),
129
130 array(
131 'id' => 'excluded_products',
132 'type' => 'products_selector',
133 'title' => esc_html__( 'Excluded Products List', 'merchant' ),
134 'desc' => esc_html__( 'Exclude products from this pre-order campaign.', 'merchant' ),
135 'allowed_types' => array( 'simple', 'variable' ),
136 'multiple' => true,
137 'conditions' => array(
138 'relation' => 'AND',
139 'terms' => array(
140 array(
141 'field' => 'trigger_on',
142 'operator' => 'in',
143 'value' => array( 'all', 'category', 'tags', 'brands' ),
144 ),
145 array(
146 'field' => 'exclude_products_toggle',
147 'operator' => '===',
148 'value' => true,
149 ),
150 ),
151 ),
152 ),
153
154 array(
155 'id' => 'exclude_categories_toggle',
156 'type' => 'switcher',
157 'title' => esc_html__( 'Exclude categories', 'merchant' ),
158 'desc' => esc_html__( 'Exclude specific categories from this pre-order campaign.', 'merchant' ),
159 'default' => 0,
160 'conditions' => array(
161 'relation' => 'AND',
162 'terms' => array(
163 array(
164 'field' => 'trigger_on',
165 'operator' => 'in',
166 'value' => array( 'all', 'tags', 'brands' ),
167 ),
168 ),
169 ),
170 ),
171
172 array(
173 'id' => 'excluded_categories',
174 'type' => 'select_ajax',
175 'title' => esc_html__( 'Excluded Categories List', 'merchant' ),
176 'source' => 'options',
177 'multiple' => true,
178 'options' => Merchant_Admin_Options::get_category_select2_choices(),
179 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
180 'desc' => esc_html__( 'Exclude categories from this pre-order campaign.', 'merchant' ),
181 'conditions' => array(
182 'relation' => 'AND',
183 'terms' => array(
184 array(
185 'field' => 'trigger_on',
186 'operator' => 'in',
187 'value' => array( 'all', 'tags', 'brands' ),
188 ),
189 array(
190 'field' => 'exclude_categories_toggle',
191 'operator' => '===',
192 'value' => true,
193 ),
194 ),
195 ),
196 ),
197
198 array(
199 'id' => 'exclude_tags_toggle',
200 'type' => 'switcher',
201 'title' => esc_html__( 'Exclude tags', 'merchant' ),
202 'desc' => esc_html__( 'Exclude specific tags from this pre-order campaign.', 'merchant' ),
203 'default' => 0,
204 'conditions' => array(
205 'relation' => 'AND',
206 'terms' => array(
207 array(
208 'field' => 'trigger_on',
209 'operator' => 'in',
210 'value' => array( 'all', 'category', 'brands' ),
211 ),
212 ),
213 ),
214 ),
215
216 array(
217 'id' => 'excluded_tags',
218 'type' => 'select_ajax',
219 'title' => esc_html__( 'Excluded Tags List', 'merchant' ),
220 'source' => 'options',
221 'multiple' => true,
222 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
223 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
224 'desc' => esc_html__( 'Exclude tags from this pre-order campaign.', 'merchant' ),
225 'conditions' => array(
226 'relation' => 'AND',
227 'terms' => array(
228 array(
229 'field' => 'trigger_on',
230 'operator' => 'in',
231 'value' => array( 'all', 'category', 'brands' ),
232 ),
233 array(
234 'field' => 'exclude_tags_toggle',
235 'operator' => '===',
236 'value' => true,
237 ),
238 ),
239 ),
240 ),
241
242 array(
243 'id' => 'exclude_brands_toggle',
244 'type' => 'switcher',
245 'title' => esc_html__( 'Exclude brands', 'merchant' ),
246 'desc' => esc_html__( 'Exclude specific brands from this pre-order campaign.', 'merchant' ),
247 'default' => 0,
248 'conditions' => array(
249 'relation' => 'AND',
250 'terms' => array(
251 array(
252 'field' => 'trigger_on',
253 'operator' => 'in',
254 'value' => array( 'all', 'category', 'tags' ),
255 ),
256 ),
257 ),
258 ),
259
260 array(
261 'id' => 'excluded_brands',
262 'type' => 'select_ajax',
263 'title' => esc_html__( 'Excluded Brands List', 'merchant' ),
264 'source' => 'options',
265 'multiple' => true,
266 'options' => Merchant_Admin_Options::get_brand_select2_choices(),
267 'placeholder' => esc_html__( 'Select brands', 'merchant' ),
268 'desc' => esc_html__( 'Exclude brands from this pre-order campaign.', 'merchant' ),
269 'conditions' => array(
270 'relation' => 'AND',
271 'terms' => array(
272 array(
273 'field' => 'trigger_on',
274 'operator' => 'in',
275 'value' => array( 'all', 'category', 'tags' ),
276 ),
277 array(
278 'field' => 'exclude_brands_toggle',
279 'operator' => '===',
280 'value' => true,
281 ),
282 ),
283 ),
284 ),
285
286 array(
287 'id' => 'discount_toggle',
288 'type' => 'switcher',
289 'title' => __( 'Do you want to offer a discount on this pre-order?', 'merchant' ),
290 'default' => 0,
291 ),
292 array(
293 'id' => 'discount_type',
294 'type' => 'radio',
295 'title' => esc_html__( 'Discount Type', 'merchant' ),
296 'options' => array(
297 'percentage' => esc_html__( 'Percentage', 'merchant' ),
298 'fixed' => esc_html__( 'Fixed', 'merchant' ),
299 ),
300 'default' => 'percentage',
301 'conditions' => array(
302 'terms' => array(
303 array(
304 'field' => 'discount_toggle', // field ID
305 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
306 'value' => true, // can be a single value or an array of string/number/int
307 ),
308 ),
309 ),
310 ),
311 array(
312 'id' => 'discount_amount',
313 'type' => 'number',
314 'step' => 0.01,
315 'default' => 10,
316 'conditions' => array(
317 'terms' => array(
318 array(
319 'field' => 'discount_toggle', // field ID
320 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
321 'value' => true, // can be a single value or an array of string/number/int
322 ),
323 ),
324 ),
325 ),
326 array(
327 'id' => 'shipping_date',
328 'type' => 'date_time',
329 'title' => esc_html__( 'Shipping date', 'merchant' ),
330 'placeholder' => esc_html__( 'mm/dd/yy, --:-- --', 'merchant' ),
331 'desc' => sprintf(
332 /* Translators: %1$s: Time zone, %2$s WordPress setting link */
333 esc_html__( 'The times set above are in the %1$s timezone, according to your settings from %2$s.',
334 'merchant' ),
335 '<strong>' . wp_timezone_string() . '</strong>',
336 '<a href="' . esc_url( admin_url( 'options-general.php' ) ) . '" target="_blank">' . esc_html__( 'WordPress Settings', 'merchant' ) . '</a>'
337 ),
338 ),
339 array(
340 'id' => 'pre_order_start',
341 'type' => 'date_time',
342 'title' => esc_html__( 'Pre-order starts at', 'merchant' ),
343 'placeholder' => esc_html__( 'mm/dd/yy, --:-- --', 'merchant' ),
344 'desc' => esc_html__( 'If you want your pre-order settings to take effect immediately, leave the pre-order start empty.', 'merchant' ),
345 ),
346 array(
347 'id' => 'pre_order_end',
348 'type' => 'date_time',
349 'title' => esc_html__( 'Pre-order ends at', 'merchant' ),
350 'placeholder' => esc_html__( 'mm/dd/yy, --:-- --', 'merchant' ),
351 'desc' => sprintf(
352 /* Translators: %1$s: Time zone, %2$s WordPress setting link */
353 esc_html__( 'Leave it empty if you don’t want to have an end date. The times set above are in the %1$s timezone, according to your settings from %2$s.',
354 'merchant' ),
355 '<strong>' . wp_timezone_string() . '</strong>',
356 '<a href="' . esc_url( admin_url( 'options-general.php' ) ) . '" target="_blank">' . esc_html__( 'WordPress Settings', 'merchant' ) . '</a>'
357 ),
358 ),
359
360 array(
361 'id' => 'user_condition',
362 'type' => 'select',
363 'title' => esc_html__( 'User Condition', 'merchant' ),
364 'options' => array(
365 'all' => esc_html__( 'All Users', 'merchant' ),
366 'customers' => esc_html__( 'Selected Users', 'merchant' ),
367 'roles' => esc_html__( 'Selected Roles', 'merchant' ),
368 ),
369 'default' => 'all',
370 ),
371
372 array(
373 'id' => 'user_condition_roles',
374 'type' => 'select_ajax',
375 'title' => esc_html__( 'User Roles', 'merchant' ),
376 'desc' => esc_html__( 'This will limit the rule to users with these roles.', 'merchant' ),
377 'source' => 'options',
378 'multiple' => true,
379 'classes' => array( 'flex-grow' ),
380 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
381 'condition' => array( 'user_condition', '==', 'roles' ),
382 ),
383
384 array(
385 'id' => 'user_condition_users',
386 'type' => 'select_ajax',
387 'title' => esc_html__( 'Users', 'merchant' ),
388 'desc' => esc_html__( 'This will limit the rule to the selected customers.', 'merchant' ),
389 'source' => 'user',
390 'multiple' => true,
391 'classes' => array( 'flex-grow' ),
392 'condition' => array( 'user_condition', '==', 'customers' ),
393 ),
394
395 array(
396 'id' => 'user_exclusion_enabled',
397 'type' => 'switcher',
398 'title' => esc_html__( 'Exclusion List', 'merchant' ),
399 'desc' => esc_html__( 'Select the users that will not show the offer.', 'merchant' ),
400 'default' => 0,
401 'conditions' => array(
402 'relation' => 'AND',
403 'terms' => array(
404 array(
405 'field' => 'user_condition',
406 'operator' => 'in',
407 'value' => array( 'all', 'roles' ),
408 ),
409 ),
410 ),
411 ),
412
413 array(
414 'id' => 'exclude_roles',
415 'type' => 'select_ajax',
416 'title' => esc_html__( 'Exclude Roles', 'merchant' ),
417 'desc' => esc_html__( 'This will exclude the offer for users with these roles.', 'merchant' ),
418 'source' => 'options',
419 'multiple' => true,
420 'classes' => array( 'flex-grow' ),
421 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
422 'conditions' => array(
423 'relation' => 'AND',
424 'terms' => array(
425 array(
426 'field' => 'user_condition',
427 'operator' => 'in',
428 'value' => array( 'all' ),
429 ),
430 array(
431 'field' => 'user_exclusion_enabled',
432 'operator' => '===',
433 'value' => true,
434 ),
435 ),
436 ),
437 ),
438
439 array(
440 'id' => 'exclude_users',
441 'type' => 'select_ajax',
442 'title' => esc_html__( 'Exclude Users', 'merchant' ),
443 'desc' => esc_html__( 'This will exclude the offer for the selected customers.', 'merchant' ),
444 'source' => 'user',
445 'multiple' => true,
446 'classes' => array( 'flex-grow' ),
447 'conditions' => array(
448 'relation' => 'AND',
449 'terms' => array(
450 array(
451 'field' => 'user_condition',
452 'operator' => 'in',
453 'value' => array( 'all', 'roles' ),
454 ),
455 array(
456 'field' => 'user_exclusion_enabled',
457 'operator' => '===',
458 'value' => true,
459 ),
460 ),
461 ),
462 ),
463
464 array(
465 'id' => 'button_text',
466 'type' => 'text',
467 'title' => esc_html__( 'Button text', 'merchant' ),
468 'default' => esc_html__( 'Pre-Order', 'merchant' ),
469 ),
470
471 array(
472 'id' => 'additional_text',
473 'type' => 'text',
474 'title' => esc_html__( 'Additional information', 'merchant' ),
475 'default' => esc_html__( 'Ships on {date}', 'merchant' ),
476 ),
477
478 array(
479 'id' => 'placement',
480 'type' => 'radio',
481 'title' => esc_html__( 'Placement', 'merchant' ),
482 'options' => array(
483 'before' => esc_html__( 'Before Button', 'merchant' ),
484 'after' => esc_html__( 'After Button', 'merchant' ),
485 ),
486 'default' => 'before',
487 ),
488 array(
489 'id' => 'cart_label_text',
490 'type' => 'text',
491 'title' => esc_html__( 'Label text on cart', 'merchant' ),
492 'default' => esc_html__( 'Ships on', 'merchant' ),
493 ),
494 array(
495 'id' => 'text-color',
496 'type' => 'color',
497 'title' => esc_html__( 'Button text color', 'merchant' ),
498 'default' => '#FFF',
499 ),
500
501 array(
502 'id' => 'text-hover-color',
503 'type' => 'color',
504 'title' => esc_html__( 'Button text color hover', 'merchant' ),
505 'default' => '#FFF',
506 ),
507
508 array(
509 'id' => 'border-color',
510 'type' => 'color',
511 'title' => esc_html__( 'Button border color', 'merchant' ),
512 'default' => '#212121',
513 ),
514
515 array(
516 'id' => 'border-hover-color',
517 'type' => 'color',
518 'title' => esc_html__( 'Button border color hover', 'merchant' ),
519 'default' => '#414141',
520 ),
521
522 array(
523 'id' => 'border-width',
524 'type' => 'range',
525 'title' => esc_html__( 'Button Border Width (px)', 'merchant' ),
526 'min' => 0,
527 'max' => 10,
528 'step' => 1,
529 'default' => 0,
530 ),
531
532 array(
533 'id' => 'border-radius',
534 'type' => 'range',
535 'title' => esc_html__( 'Button Border Radius (px)', 'merchant' ),
536 'min' => 0,
537 'max' => 50,
538 'step' => 1,
539 'default' => 0,
540 ),
541
542 array(
543 'id' => 'background-color',
544 'type' => 'color',
545 'title' => esc_html__( 'Button background color', 'merchant' ),
546 'default' => '#212121',
547 ),
548
549 array(
550 'id' => 'background-hover-color',
551 'type' => 'color',
552 'title' => esc_html__( 'Button background color hover', 'merchant' ),
553 'default' => '#414141',
554 ),
555 ),
556 ),
557 ),
558 'default' => array(
559 array(
560 'layout' => 'rule-details',
561 ),
562 ),
563 ),
564 array(
565 'id' => 'modes',
566 'type' => 'select',
567 'title' => esc_html__( 'Pre-order Modes', 'merchant' ),
568 'options' => array(
569 'only_pre_orders' => esc_html__( 'Allow only pre-orders', 'merchant' ),
570 'unified_order' => esc_html__( 'Treat the whole order as pre-order', 'merchant' ),
571 // 'separate_order_for_pre_orders' => esc_html__( 'Generate separate orders for each pre-order product', 'merchant' ),
572 // 'group_pre_order_into_one_order' => esc_html__( 'Generate two separate orders, one for pre-orders and one for in-stock products', 'merchant' ),
573 ),
574 'default' => 'unified_order',
575 ),
576 array(
577 'id' => 'helping_instructions_only_pre_orders',
578 'type' => 'info_block',
579 'description' => esc_html__( 'Use this mode if you want to only allow your customers to either choose pre-order products or available ones.', 'merchant' ),
580 'conditions' => array(
581 'terms' => array(
582 array(
583 'field' => 'modes', // field ID
584 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
585 'value' => 'only_pre_orders', // can be a single value or an array of string/number/int
586 ),
587 ),
588 ),
589 ),
590 array(
591 'id' => 'helping_instructions_unified_order',
592 'type' => 'info_block',
593 'description' => esc_html__( 'Use this mode if you want to treat the whole order as a pre-order if at least one product is a pre-order.', 'merchant' ),
594 'conditions' => array(
595 'terms' => array(
596 array(
597 'field' => 'modes', // field ID
598 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
599 'value' => 'unified_order', // can be a single value or an array of string/number/int
600 ),
601 ),
602 ),
603 ),
604 array(
605 'id' => 'helping_instructions_separate_order_for_pre_orders',
606 'type' => 'info_block',
607 'description' => esc_html__( 'Use this mode if you want to generate separate orders for each pre-order product.', 'merchant' ),
608 'conditions' => array(
609 'terms' => array(
610 array(
611 'field' => 'modes', // field ID
612 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
613 'value' => 'separate_order_for_pre_orders', // can be a single value or an array of string/number/int
614 ),
615 ),
616 ),
617 ),
618 array(
619 'id' => 'helping_instructions_group_pre_order_into_one_order',
620 'type' => 'info_block',
621 'description' => esc_html__( 'Use this mode if you want to generate two separate orders, one for pre-orders and one for in-stock products.', 'merchant' ),
622 'conditions' => array(
623 'terms' => array(
624 array(
625 'field' => 'modes', // field ID
626 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
627 'value' => 'group_pre_order_into_one_order', // can be a single value or an array of string/number/int
628 ),
629 ),
630 ),
631 ),
632 ),
633 )
634 );