PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.0
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.0
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 / volume-discounts / admin / options.php

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

1,098 lines 42.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Volume Discounts — Option group definitions.
5 *
6 * Pure data file. Returns the option groups array
7 * consumed by init_option_groups().
8 *
9 * @package Merchant
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 return array(
17 array(
18 'title' => esc_html__( 'Offers', 'merchant' ),
19 'module' => Merchant_Volume_Discounts::MODULE_ID,
20 'fields' => array(
21 array(
22 'id' => 'offers',
23 'type' => 'flexible_content',
24 'button_label' => esc_html__( 'Add New Offer', 'merchant' ),
25 'style' => Merchant_Volume_Discounts::MODULE_ID . '-style default',
26 'sorting' => true,
27 'accordion' => true,
28 'duplicate' => true,
29 'layouts' => array(
30 'offer-details' => array(
31 'title' => esc_html__( 'Create Discount Tiers', 'merchant' ),
32 'title-field' => 'offer-title', // text field ID to use as title for the layout
33 'status-field' => 'campaign_status',
34 'fields' => array(
35 array(
36 'id' => 'campaign_status',
37 'type' => 'select',
38 'title' => esc_html__( 'Status', 'merchant' ),
39 'options' => array(
40 'active' => esc_html__( 'Active', 'merchant' ),
41 'inactive' => esc_html__( 'Inactive', 'merchant' ),
42 ),
43 'default' => 'active',
44 'ai_meta' => array(
45 'usage_hint' => 'Controls whether this campaign is active or inactive. Set to active to enable, inactive to disable.',
46 ),
47 ),
48 array(
49 'id' => 'offer-title',
50 'type' => 'text',
51 'title' => esc_html__( 'Offer name', 'merchant' ),
52 'default' => esc_html__( 'Campaign', 'merchant' ),
53 ),
54 array(
55 'id' => 'rules_to_display',
56 'type' => 'select',
57 'title' => esc_html__( 'Offered product(s)', 'merchant' ),
58 'options' => array(
59 'all' => esc_html__( 'All Products', 'merchant' ),
60 'products' => esc_html__( 'Specific Products', 'merchant' ),
61 'categories' => esc_html__( 'Specific Categories', 'merchant' ),
62 'tags' => esc_html__( 'Specific Tags', 'merchant' ),
63 'brands' => esc_html__( 'Specific Brands', 'merchant' ),
64 ),
65 'default' => 'products',
66 'ai_meta' => array(
67 'semantic_group' => 'product_targeting',
68 'usage_hint' => 'Controls which products this campaign applies to. Set this BEFORE setting product_id, category_slugs, tag_slugs, or brand_slugs — those fields are conditional on this value.',
69 ),
70 ),
71 array(
72 'id' => 'include_all_cart_products',
73 'type' => 'switcher',
74 'title' => esc_html__( 'Include all cart products', 'merchant' ),
75 'desc' => esc_html__( 'Apply the discount based on the total quantity of products added to the cart, rather than requiring a specific quantity of each individual product.', 'merchant' ),
76 'default' => false,
77 'condition' => array( 'rules_to_display', '==', 'all' ),
78 'ai_meta' => array(
79 'usage_hint' => 'When enabled, quantity thresholds count total cart items rather than per-product. Only applies when rules_to_display=all.',
80 ),
81 ),
82 array(
83 'id' => 'product_id',
84 'type' => 'products_selector',
85 //'title' => esc_html__( 'Select product', 'merchant' ),
86 'multiple' => true,
87 'desc' => esc_html__( 'Select the product that the customer will get a discount on when they purchase the minimum required quantity.',
88 'merchant' ),
89 'allowed_types' => array( 'simple', 'variable' ),
90 'condition' => array( 'rules_to_display', '==', 'products' ),
91 'ai_meta' => array(
92 'entity' => 'product',
93 'reference_type' => 'static',
94 'value_format' => 'product_id',
95 'semantic_group' => 'product_targeting',
96 'abstraction_level' => 1,
97 'usage_hint' => 'Use when targeting specific individual products by name. Requires rules_to_display=products.',
98 ),
99 ),
100 array(
101 'id' => 'category_slugs',
102 'type' => 'select_ajax',
103 'title' => esc_html__( 'Categories', 'merchant' ),
104 'source' => 'options',
105 'multiple' => true,
106 'options' => Merchant_Admin_Options::get_category_select2_choices(),
107 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
108 'desc' => esc_html__( 'Select the product categories that will show the offer.', 'merchant' ),
109 'condition' => array( 'rules_to_display', '==', 'categories' ),
110 'ai_meta' => array(
111 'entity' => 'category',
112 'reference_type' => 'dynamic',
113 'taxonomy' => 'product_cat',
114 'value_format' => 'slug',
115 'semantic_group' => 'product_targeting',
116 'abstraction_level' => 3,
117 'usage_hint' => 'Use when targeting products by category. Dynamic: future products added to the category are included. Requires rules_to_display=categories.',
118 ),
119 ),
120 array(
121 'id' => 'include_all_category_products',
122 'type' => 'switcher',
123 'title' => esc_html__( 'Include all category products', 'merchant' ),
124 'desc' => esc_html__( 'Apply the discount based on the total quantity of products within the same category added to the cart, rather than requiring a specific quantity of each individual product.', 'merchant' ),
125 'default' => false,
126 'condition' => array( 'rules_to_display', '==', 'categories' ),
127 'ai_meta' => array(
128 'usage_hint' => 'When enabled, quantity thresholds count all products within the selected categories rather than per-product. Only applies when rules_to_display=categories.',
129 ),
130 ),
131 array(
132 'id' => 'include_all_products_info',
133 'type' => 'info',
134 'content' => esc_html__( 'When configuring offer priorities, consider the order in which they are applied. Typically, more general offers should be prioritized higher to ensure consistent discount application. You can control the priority by sorting the offers—offers listed at the top have the highest priority. However, note that this setup will not work on the thank you page.',
135 'merchant' ),
136 'conditions' => array(
137 'relation' => 'OR', // AND/OR, If not provided, only first term will be considered
138 'terms' => array(
139 array(
140 'relation' => 'AND', // AND/OR, If not provided, only first term will be considered
141 'terms' => array(
142 array(
143 'field' => 'rules_to_display', // field ID
144 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
145 'value' => 'categories', // can be a single value or an array of string/number/int
146 ),
147 array(
148 'field' => 'include_all_category_products', // field ID
149 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
150 'value' => true, // can be a single value or an array of string/number/int
151 ),
152 ),
153 ),
154 array(
155 'relation' => 'AND', // AND/OR, If not provided, only first term will be considered
156 'terms' => array(
157 array(
158 'field' => 'rules_to_display', // field ID
159 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
160 'value' => 'all', // can be a single value or an array of string/number/int
161 ),
162 array(
163 'field' => 'include_all_cart_products', // field ID
164 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
165 'value' => true, // can be a single value or an array of string/number/int
166 ),
167 ),
168 ),
169 ),
170 ),
171 ),
172 array(
173 'id' => 'tag_slugs',
174 'type' => 'select_ajax',
175 'title' => esc_html__( 'Tags', 'merchant' ),
176 'source' => 'options',
177 'multiple' => true,
178 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
179 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
180 'desc' => esc_html__( 'Select the product tags that will show the offer.', 'merchant' ),
181 'condition' => array( 'rules_to_display', '==', 'tags' ),
182 'ai_meta' => array(
183 'entity' => 'tag',
184 'reference_type' => 'dynamic',
185 'taxonomy' => 'product_tag',
186 'value_format' => 'slug',
187 'semantic_group' => 'product_targeting',
188 'abstraction_level' => 2,
189 'usage_hint' => 'Use when targeting products by tag. Dynamic: future products added to the tag are included. Requires rules_to_display=tags.',
190 ),
191 ),
192 array(
193 'id' => 'brand_slugs',
194 'type' => 'select_ajax',
195 'title' => esc_html__( 'Brands', 'merchant' ),
196 'source' => 'options',
197 'multiple' => true,
198 'options' => Merchant_Admin_Options::get_brand_select2_choices(),
199 'placeholder' => esc_html__( 'Select brands', 'merchant' ),
200 'desc' => esc_html__( 'Select the product brands that will show the offer.', 'merchant' ),
201 'condition' => array( 'rules_to_display', '==', 'brands' ),
202 'ai_meta' => array(
203 'entity' => 'brand',
204 'reference_type' => 'dynamic',
205 'taxonomy' => 'product_brand',
206 'value_format' => 'slug',
207 'semantic_group' => 'product_targeting',
208 'abstraction_level' => 4,
209 'usage_hint' => 'Use when targeting products by brand. Dynamic: future products added to the brand are included. Requires rules_to_display=brands.',
210 ),
211 ),
212
213 array(
214 'id' => 'exclude_products_toggle',
215 'type' => 'switcher',
216 'title' => esc_html__( 'Exclude products', 'merchant' ),
217 'default' => 0,
218 'conditions' => array(
219 'relation' => 'AND',
220 'terms' => array(
221 array(
222 'field' => 'rules_to_display',
223 'operator' => 'in',
224 'value' => array( 'all', 'categories', 'tags', 'brands' ),
225 ),
226 ),
227 ),
228 'ai_meta' => array(
229 'toggle_for' => 'excluded_products',
230 'semantic_group' => 'product_exclusion',
231 'usage_hint' => 'Enable this toggle before setting excluded_products. Only available when rules_to_display is all, categories, tags, or brands.',
232 ),
233 ),
234
235 array(
236 'id' => 'excluded_products',
237 'type' => 'products_selector',
238 'title' => esc_html__( 'Exclude Products', 'merchant' ),
239 'multiple' => true,
240 'desc' => esc_html__( 'Exclude products from this campaign.', 'merchant' ),
241 'conditions' => array(
242 'relation' => 'AND',
243 'terms' => array(
244 array(
245 'field' => 'rules_to_display',
246 'operator' => 'in',
247 'value' => array( 'all', 'categories', 'tags', 'brands' ),
248 ),
249 array(
250 'field' => 'exclude_products_toggle',
251 'operator' => '===',
252 'value' => true,
253 ),
254 ),
255 ),
256 'ai_meta' => array(
257 'entity' => 'product',
258 'reference_type' => 'static',
259 'value_format' => 'product_id',
260 'semantic_group' => 'product_exclusion',
261 'abstraction_level' => 1,
262 'toggled_by' => 'exclude_products_toggle',
263 'usage_hint' => 'Use ONLY for excluding specific individual products. For brand/category/tag exclusions, prefer excluded_brands/excluded_categories/excluded_tags — they are dynamic and auto-exclude future products.',
264 ),
265 ),
266
267 array(
268 'id' => 'exclude_categories_toggle',
269 'type' => 'switcher',
270 'title' => esc_html__( 'Exclude categories', 'merchant' ),
271 'default' => 0,
272 'conditions' => array(
273 'relation' => 'AND',
274 'terms' => array(
275 array(
276 'field' => 'rules_to_display',
277 'operator' => 'in',
278 'value' => array( 'all', 'tags', 'brands' ),
279 ),
280 ),
281 ),
282 'ai_meta' => array(
283 'toggle_for' => 'excluded_categories',
284 'semantic_group' => 'product_exclusion',
285 'usage_hint' => 'Enable this toggle before setting excluded_categories. Only available when rules_to_display is all, tags, or brands.',
286 ),
287 ),
288
289 array(
290 'id' => 'excluded_categories',
291 'type' => 'select_ajax',
292 'title' => esc_html__( 'Excluded Categories List', 'merchant' ),
293 'source' => 'options',
294 'multiple' => true,
295 'options' => Merchant_Admin_Options::get_category_select2_choices(),
296 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
297 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ),
298 'conditions' => array(
299 'relation' => 'AND',
300 'terms' => array(
301 array(
302 'field' => 'rules_to_display',
303 'operator' => 'in',
304 'value' => array( 'all', 'tags', 'brands' ),
305 ),
306 array(
307 'field' => 'exclude_categories_toggle',
308 'operator' => '===',
309 'value' => true,
310 ),
311 ),
312 ),
313 'ai_meta' => array(
314 'entity' => 'category',
315 'reference_type' => 'dynamic',
316 'taxonomy' => 'product_cat',
317 'value_format' => 'slug',
318 'semantic_group' => 'product_exclusion',
319 'abstraction_level' => 3,
320 'toggled_by' => 'exclude_categories_toggle',
321 'usage_hint' => 'Use when excluding products by category. Dynamic: future products added to the category are automatically excluded.',
322 ),
323 ),
324
325 array(
326 'id' => 'exclude_tags_toggle',
327 'type' => 'switcher',
328 'title' => esc_html__( 'Exclude product tags', 'merchant' ),
329 'default' => 0,
330 'conditions' => array(
331 'relation' => 'AND',
332 'terms' => array(
333 array(
334 'field' => 'rules_to_display',
335 'operator' => 'in',
336 'value' => array( 'all', 'categories', 'brands' ),
337 ),
338 ),
339 ),
340 'ai_meta' => array(
341 'toggle_for' => 'excluded_tags',
342 'semantic_group' => 'product_exclusion',
343 'usage_hint' => 'Enable this toggle before setting excluded_tags. Only available when rules_to_display is all, categories, or brands.',
344 ),
345 ),
346
347 array(
348 'id' => 'excluded_tags',
349 'type' => 'select_ajax',
350 'title' => esc_html__( 'Excluded Tags List', 'merchant' ),
351 'source' => 'options',
352 'multiple' => true,
353 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
354 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
355 'desc' => esc_html__( 'Exclude tags from this campaign.', 'merchant' ),
356 'conditions' => array(
357 'relation' => 'AND',
358 'terms' => array(
359 array(
360 'field' => 'rules_to_display',
361 'operator' => 'in',
362 'value' => array( 'all', 'categories', 'brands' ),
363 ),
364 array(
365 'field' => 'exclude_tags_toggle',
366 'operator' => '===',
367 'value' => true,
368 ),
369 ),
370 ),
371 'ai_meta' => array(
372 'entity' => 'tag',
373 'reference_type' => 'dynamic',
374 'taxonomy' => 'product_tag',
375 'value_format' => 'slug',
376 'semantic_group' => 'product_exclusion',
377 'abstraction_level' => 2,
378 'toggled_by' => 'exclude_tags_toggle',
379 'usage_hint' => 'Use when excluding products by tag. Dynamic: future products added to the tag are automatically excluded.',
380 ),
381 ),
382
383 array(
384 'id' => 'exclude_brands_toggle',
385 'type' => 'switcher',
386 'title' => esc_html__( 'Exclude brands', 'merchant' ),
387 'default' => 0,
388 'conditions' => array(
389 'relation' => 'AND',
390 'terms' => array(
391 array(
392 'field' => 'rules_to_display',
393 'operator' => 'in',
394 'value' => array( 'all', 'categories', 'tags' ),
395 ),
396 ),
397 ),
398 'ai_meta' => array(
399 'toggle_for' => 'excluded_brands',
400 'semantic_group' => 'product_exclusion',
401 'usage_hint' => 'Enable this toggle before setting excluded_brands. Only available when rules_to_display is all, categories, or tags.',
402 ),
403 ),
404
405 array(
406 'id' => 'excluded_brands',
407 'type' => 'select_ajax',
408 'title' => esc_html__( 'Excluded Brands List', 'merchant' ),
409 'source' => 'options',
410 'multiple' => true,
411 'options' => Merchant_Admin_Options::get_brand_select2_choices(),
412 'placeholder' => esc_html__( 'Select brands', 'merchant' ),
413 'desc' => esc_html__( 'Exclude brands from this campaign.', 'merchant' ),
414 'conditions' => array(
415 'relation' => 'AND',
416 'terms' => array(
417 array(
418 'field' => 'rules_to_display',
419 'operator' => 'in',
420 'value' => array( 'all', 'categories', 'tags' ),
421 ),
422 array(
423 'field' => 'exclude_brands_toggle',
424 'operator' => '===',
425 'value' => true,
426 ),
427 ),
428 ),
429 'ai_meta' => array(
430 'entity' => 'brand',
431 'reference_type' => 'dynamic',
432 'taxonomy' => 'product_brand',
433 'value_format' => 'slug',
434 'semantic_group' => 'product_exclusion',
435 'abstraction_level' => 4,
436 'toggled_by' => 'exclude_brands_toggle',
437 'usage_hint' => 'Use when excluding products by brand. Dynamic: future products added to the brand are automatically excluded. Prefer this over excluded_products when intent is brand-level.',
438 ),
439 ),
440
441 array(
442 'id' => 'exclude_onsale_products_toggle',
443 'type' => 'switcher',
444 'title' => esc_html__( 'Exclude On-Sale products', 'merchant' ),
445 'default' => 0,
446 'conditions' => array(
447 'relation' => 'AND',
448 'terms' => array(
449 array(
450 'field' => 'rules_to_display',
451 'operator' => 'in',
452 'value' => array( 'all', 'categories', 'tags', 'brands' ),
453 ),
454 ),
455 ),
456 'ai_meta' => array(
457 'semantic_group' => 'product_exclusion',
458 'usage_hint' => 'When enabled, products currently on sale are excluded from this campaign. Standalone flag — no additional data field required.',
459 ),
460 ),
461
462 array(
463 'id' => 'quantity',
464 'type' => 'number',
465 'title' => esc_html__( 'Quantity', 'merchant' ),
466 'min' => 1,
467 'default' => 2,
468 'ai_meta' => array(
469 'semantic_group' => 'offer_rules',
470 'usage_hint' => 'Minimum quantity to trigger this tier discount.',
471 ),
472 ),
473
474 array(
475 'id' => 'discount_type',
476 'type' => 'radio',
477 'title' => esc_html__( 'Discount', 'merchant' ),
478 'options' => array(
479 'percentage_discount' => esc_html__( 'Percentage', 'merchant' ),
480 'fixed_discount' => esc_html__( 'Fixed', 'merchant' ),
481 ),
482 'default' => 'percentage_discount',
483 'ai_meta' => array(
484 'usage_hint' => 'Choose percentage_discount for relative discounts or fixed_discount for absolute amounts.',
485 ),
486 ),
487 array(
488 'id' => 'discount',
489 'type' => 'number',
490 'step' => 0.01,
491 'default' => 10,
492 'ai_meta' => array(
493 'semantic_group' => 'offer_rules',
494 'usage_hint' => 'The discount amount. Percentage (e.g. 10 for 10% off) or fixed currency amount, depending on discount_type.',
495 ),
496 ),
497
498 array(
499 'id' => 'discount_target',
500 'type' => 'select',
501 'title' => esc_html__( 'Apply discount to', 'merchant' ),
502 'options' => array(
503 'regular' => esc_html__( 'Regular Price', 'merchant' ),
504 'sale' => esc_html__( 'Sale Price', 'merchant' ),
505 ),
506 'default' => 'sale',
507 'ai_meta' => array(
508 'semantic_group' => 'offer_rules',
509 'usage_hint' => 'Whether the discount is calculated from the regular price or the sale price.',
510 ),
511 ),
512
513 array(
514 'id' => 'exclude_coupon',
515 'type' => 'switcher',
516 'title' => esc_html__( 'Exclude coupons', 'merchant' ),
517 'desc' => esc_html__( 'Coupon codes will not be applicable on top of this offer campaign.', 'merchant' ),
518 'default' => false,
519 'ai_meta' => array(
520 'usage_hint' => 'When enabled, coupon codes cannot be stacked on top of this volume discount campaign.',
521 ),
522 ),
523
524 array(
525 'id' => 'user_condition',
526 'type' => 'select',
527 'title' => esc_html__( 'User Condition', 'merchant' ),
528 'options' => array(
529 'all' => esc_html__( 'All Users', 'merchant' ),
530 'customers' => esc_html__( 'Selected Users', 'merchant' ),
531 'roles' => esc_html__( 'Selected Roles', 'merchant' ),
532 ),
533 'default' => 'all',
534 'ai_meta' => array(
535 'semantic_group' => 'user_targeting',
536 'usage_hint' => 'Controls which users see this campaign. Set this BEFORE setting user_condition_roles or user_condition_users.',
537 ),
538 ),
539
540 array(
541 'id' => 'user_condition_roles',
542 'type' => 'select_ajax',
543 'title' => esc_html__( 'User Roles', 'merchant' ),
544 'desc' => esc_html__( 'This will limit the offer to users with these roles.', 'merchant' ),
545 'source' => 'options',
546 'multiple' => true,
547 'classes' => array( 'flex-grow' ),
548 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
549 'condition' => array( 'user_condition', '==', 'roles' ),
550 'ai_meta' => array(
551 'entity' => 'role',
552 'reference_type' => 'dynamic',
553 'value_format' => 'role_slug',
554 'semantic_group' => 'user_targeting',
555 'abstraction_level' => 2,
556 'usage_hint' => 'Use when targeting users by role. Dynamic: future users assigned the role are included. Requires user_condition=roles.',
557 ),
558 ),
559
560 array(
561 'id' => 'user_condition_users',
562 'type' => 'select_ajax',
563 'title' => esc_html__( 'Users', 'merchant' ),
564 'desc' => esc_html__( 'This will limit the offer to the selected customers.', 'merchant' ),
565 'source' => 'user',
566 'multiple' => true,
567 'classes' => array( 'flex-grow' ),
568 'condition' => array( 'user_condition', '==', 'customers' ),
569 'ai_meta' => array(
570 'entity' => 'user',
571 'reference_type' => 'static',
572 'value_format' => 'user_id',
573 'semantic_group' => 'user_targeting',
574 'abstraction_level' => 1,
575 'usage_hint' => 'Use when targeting specific individual users. Static: only selected users, not future users. Requires user_condition=customers.',
576 ),
577 ),
578
579 array(
580 'id' => 'user_exclusion_enabled',
581 'type' => 'switcher',
582 'title' => esc_html__( 'Exclusion List', 'merchant' ),
583 'desc' => esc_html__( 'Select the users that will not show the offer.', 'merchant' ),
584 'default' => 0,
585 'conditions' => array(
586 'relation' => 'AND',
587 'terms' => array(
588 array(
589 'field' => 'user_condition',
590 'operator' => 'in',
591 'value' => array( 'all', 'roles' ),
592 ),
593 ),
594 ),
595 'ai_meta' => array(
596 'toggle_for' => 'exclude_roles',
597 'semantic_group' => 'user_exclusion',
598 'usage_hint' => 'Enable this toggle before setting exclude_roles or exclude_users. Gates both user exclusion fields.',
599 ),
600 ),
601
602 array(
603 'id' => 'exclude_roles',
604 'type' => 'select_ajax',
605 'title' => esc_html__( 'Exclude Roles', 'merchant' ),
606 'desc' => esc_html__( 'This will exclude the offer for users with these roles.', 'merchant' ),
607 'source' => 'options',
608 'multiple' => true,
609 'classes' => array( 'flex-grow' ),
610 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
611 'conditions' => array(
612 'relation' => 'AND',
613 'terms' => array(
614 array(
615 'field' => 'user_condition',
616 'operator' => 'in',
617 'value' => array( 'all' ),
618 ),
619 array(
620 'field' => 'user_exclusion_enabled',
621 'operator' => '===',
622 'value' => true,
623 ),
624 ),
625 ),
626 'ai_meta' => array(
627 'entity' => 'role',
628 'reference_type' => 'dynamic',
629 'value_format' => 'role_slug',
630 'semantic_group' => 'user_exclusion',
631 'abstraction_level' => 2,
632 'toggled_by' => 'user_exclusion_enabled',
633 'usage_hint' => 'Use when excluding users by role. Dynamic: future users assigned the role are excluded. Prefer over exclude_users for role-level exclusions.',
634 ),
635 ),
636
637 array(
638 'id' => 'exclude_users',
639 'type' => 'select_ajax',
640 'title' => esc_html__( 'Exclude Users', 'merchant' ),
641 'desc' => esc_html__( 'This will exclude the offer for the selected customers.', 'merchant' ),
642 'source' => 'user',
643 'multiple' => true,
644 'classes' => array( 'flex-grow' ),
645 'conditions' => array(
646 'relation' => 'AND',
647 'terms' => array(
648 array(
649 'field' => 'user_condition',
650 'operator' => 'in',
651 'value' => array( 'all', 'roles' ),
652 ),
653 array(
654 'field' => 'user_exclusion_enabled',
655 'operator' => '===',
656 'value' => true,
657 ),
658 ),
659 ),
660 'ai_meta' => array(
661 'entity' => 'user',
662 'reference_type' => 'static',
663 'value_format' => 'user_id',
664 'semantic_group' => 'user_exclusion',
665 'abstraction_level' => 1,
666 'toggled_by' => 'user_exclusion_enabled',
667 'usage_hint' => 'Use ONLY for excluding specific individual users. For role-level exclusions, prefer exclude_roles.',
668 ),
669 ),
670
671 array(
672 'id' => 'product_single_page',
673 'type' => 'fields_group',
674 'title' => esc_html__( 'Product Single Page', 'merchant' ),
675 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on product pages.', 'merchant' ),
676 'state' => 'open',
677 'accordion' => true,
678 'display_status' => true,
679 'default' => 'active',
680 'fields' => array(
681 array(
682 'id' => 'single_product_placement',
683 'type' => 'radio',
684 'title' => esc_html__( 'Placement on product page', 'merchant' ),
685 'options' => array(
686 'before-cart-form' => esc_html__( 'Before add to cart', 'merchant' ),
687 'after-cart-form' => esc_html__( 'After add to cart', 'merchant' ),
688 ),
689 'default' => 'before-cart-form',
690 ),
691
692 // text formatting
693 array(
694 'id' => 'table_title',
695 'type' => 'text',
696 'title' => esc_html__( 'Offer title', 'merchant' ),
697 'default' => __( 'Buy more, save more!', 'merchant' ),
698 ),
699
700 // `hidden_desc` depends on `desc`
701 array(
702 'id' => 'save_label',
703 'type' => 'text',
704 'title' => esc_html__( 'Save label', 'merchant' ),
705 'default' => esc_html__( 'Save {amount}', 'merchant' ),
706 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
707 'hidden_desc' => sprintf(
708 /* Translators: %1$s: Discount amount, %2$s: Discount percentage */
709 __( '<strong>%1$s:</strong> to show discount amount<br><strong>%2$s:</strong> to show discount percentage', 'merchant' ),
710 '{amount}',
711 '{percent}'
712 ),
713 ),
714
715 array(
716 'id' => 'buy_text',
717 'type' => 'text',
718 'title' => esc_html__( 'Tier format text', 'merchant' ),
719 'default' => esc_html__( 'Buy {quantity}, get {discount} off each', 'merchant' ),
720 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
721 'hidden_desc' => sprintf(
722 /* Translators: %1$s: Discount percentage, %2$s: Quantity, %3$s: Discount amount */
723 __( '<strong>%1$s:</strong> to show discount percentage<br><strong>%2$s:</strong> to show the number of items needed to buy to get the discount<br><strong>%3$s:</strong> to show discount amount on each item',
724 'merchant' ),
725 '{percent}',
726 '{quantity}',
727 '{discount}'
728 ),
729 ),
730
731 array(
732 'id' => 'item_text',
733 'type' => 'text',
734 'title' => esc_html__( 'Item text', 'merchant' ),
735 'default' => esc_html__( 'Per item:', 'merchant' ),
736 ),
737
738 array(
739 'id' => 'total_text',
740 'type' => 'text',
741 'title' => esc_html__( 'Total text', 'merchant' ),
742 'default' => esc_html__( 'Total price:', 'merchant' ),
743 ),
744
745 array(
746 'id' => 'cart_title_text',
747 'type' => 'text',
748 'title' => esc_html__( 'Cart item discount title', 'merchant' ),
749 'default' => esc_html__( 'Discount', 'merchant' ),
750 'desc' => esc_html__( 'This is displayed on the cart page.', 'merchant' ),
751 ),
752
753 array(
754 'id' => 'cart_description_text',
755 'type' => 'text',
756 'title' => esc_html__( 'Cart item discount description', 'merchant' ),
757 'default' => esc_html__( 'A discount of {amount} has been applied.', 'merchant' ),
758 'desc' => __( 'This is displayed on the cart page. You can use these codes in the content.', 'merchant' ),
759 'hidden_desc' => sprintf(
760 /* Translators: %1$s: Discount amount, %2$s: Discount percentage */
761 __( '<strong>%1$s:</strong> to show discount amount<br><strong>%2$s:</strong> to show discount percentage', 'merchant' ),
762 '{amount}',
763 '{percent}'
764 ),
765 ),
766
767 // style settings
768 array(
769 'id' => 'title_font_size',
770 'type' => 'range',
771 'title' => esc_html__( 'Title font size', 'merchant' ),
772 'min' => 0,
773 'max' => 100,
774 'step' => 1,
775 'unit' => 'px',
776 'default' => 16,
777 ),
778
779 array(
780 'id' => 'title_font_weight',
781 'type' => 'select',
782 'title' => esc_html__( 'Title font weight', 'merchant' ),
783 'options' => array(
784 'lighter' => esc_html__( 'Light', 'merchant' ),
785 'normal' => esc_html__( 'Normal', 'merchant' ),
786 'bold' => esc_html__( 'Bold', 'merchant' ),
787 ),
788 'default' => 'normal',
789 ),
790
791 array(
792 'id' => 'title_text_color',
793 'type' => 'color',
794 'title' => esc_html__( 'Title text color', 'merchant' ),
795 'default' => '#212121',
796 ),
797
798 array(
799 'id' => 'title_text_color_hover',
800 'type' => 'color',
801 'title' => esc_html__( 'Title text color hover', 'merchant' ),
802 'default' => '#212121',
803 ),
804
805 array(
806 'id' => 'table_item_bg_color',
807 'type' => 'color',
808 'title' => esc_html__( 'Background color', 'merchant' ),
809 'default' => '#fcf0f1',
810 ),
811
812 array(
813 'id' => 'table_item_bg_color_hover',
814 'type' => 'color',
815 'title' => esc_html__( 'Background color hover', 'merchant' ),
816 'default' => '#fcf0f1',
817 ),
818
819 array(
820 'id' => 'table_item_border_color',
821 'type' => 'color',
822 'title' => esc_html__( 'Border color', 'merchant' ),
823 'default' => '#d83b3b',
824 ),
825
826 array(
827 'id' => 'table_item_border_color_hover',
828 'type' => 'color',
829 'title' => esc_html__( 'Border color hover', 'merchant' ),
830 'default' => '#d83b3b',
831 ),
832
833 array(
834 'id' => 'table_item_text_color',
835 'type' => 'color',
836 'title' => esc_html__( 'Text color', 'merchant' ),
837 'default' => '#3c434a',
838 ),
839
840 array(
841 'id' => 'table_item_text_color_hover',
842 'type' => 'color',
843 'title' => esc_html__( 'Text color hover', 'merchant' ),
844 'default' => '#3c434a',
845 ),
846
847 array(
848 'id' => 'table_label_bg_color',
849 'type' => 'color',
850 'title' => esc_html__( 'Label background color', 'merchant' ),
851 'default' => '#d83b3b',
852 ),
853
854 array(
855 'id' => 'table_label_text_color',
856 'type' => 'color',
857 'title' => esc_html__( 'Label text color', 'merchant' ),
858 'default' => '#ffffff',
859 ),
860 ),
861 ),
862 array(
863 'id' => 'cart_page',
864 'type' => 'fields_group',
865 'title' => esc_html__( 'Cart Page', 'merchant' ),
866 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the cart page.', 'merchant' ),
867 'state' => 'closed',
868 'accordion' => true,
869 'display_status' => true,
870 'default' => 'inactive',
871 'fields' => array(
872 // Text Formatting Settings
873 array(
874 'id' => 'title',
875 'type' => 'text',
876 'title' => esc_html__( 'Offer title', 'merchant' ),
877 'default' => esc_html__( 'Add {quantity} more to get a {discount} discount off each', 'merchant' ),
878 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
879 'hidden_desc' => sprintf(
880 /* Translators: %1$s: offer quantity, %2$s: discount amount */
881 __(
882 '<strong>%1$s:</strong> to show offer quantity<br><strong>%2$s:</strong> to show discount amount',
883 'merchant'
884 ),
885 '{quantity}',
886 '{discount}'
887 ),
888 ),
889
890 array(
891 'id' => 'button_text',
892 'type' => 'text',
893 'title' => esc_html__( 'Button text', 'merchant' ),
894 'default' => esc_html__( 'Add To Cart', 'merchant' ),
895 ),
896 ),
897 ),
898 array(
899 'id' => 'checkout_page',
900 'type' => 'fields_group',
901 'title' => esc_html__( 'Checkout Page', 'merchant' ),
902 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the checkout page.', 'merchant' ),
903 'state' => 'closed',
904 'default' => 'inactive',
905 'accordion' => true,
906 'display_status' => true,
907 'fields' => array(
908 array(
909 'id' => 'placement',
910 'type' => 'select',
911 'title' => esc_html__( 'Placement', 'merchant' ),
912 'options' => array(
913 'before_billing_details' => esc_html__( 'Before Billing Details', 'merchant' ),
914 'after_billing_details' => esc_html__( 'After Billing Details', 'merchant' ),
915 'before_order_details' => esc_html__( 'Before Order Details', 'merchant' ),
916 'before_payment_options' => esc_html__( 'Before Payment Gateways', 'merchant' ),
917 'before_order_placement_btn' => esc_html__( 'Before Order Placement Button', 'merchant' ),
918 'after_order_placement_btn' => esc_html__( 'After Order Placement Button', 'merchant' ),
919 ),
920 'default' => 'before_billing_details',
921 ),
922 array(
923 'id' => 'title',
924 'type' => 'text',
925 'title' => esc_html__( 'Offer title', 'merchant' ),
926 'default' => esc_html__( 'Add {quantity} more to get {discount} off', 'merchant' ),
927 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
928 'hidden_desc' => sprintf(
929 /* Translators: %1$s: offer quantity, %2$s: discount amount */
930 __(
931 '<strong>%1$s:</strong> to show offer quantity<br><strong>%2$s:</strong> to show discount amount',
932 'merchant'
933 ),
934 '{quantity}',
935 '{discount}'
936 ),
937 ),
938 array(
939 'id' => 'discount_text',
940 'type' => 'text',
941 'title' => esc_html__( 'Discount text', 'merchant' ),
942 'default' => esc_html__( '{product_price}', 'merchant' ),
943 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
944 'hidden_desc' => sprintf(
945 /* Translators: %1$s: product price */
946 __(
947 '<strong>%1$s:</strong> to show product price<br><strong>%2$s:</strong> to show offer discount amount',
948 'merchant'
949 ),
950 '{product_price}',
951 '{discount}'
952 ),
953 ),
954 array(
955 'id' => 'button_text',
956 'type' => 'text',
957 'title' => esc_html__( 'Button text', 'merchant' ),
958 'default' => esc_html__( 'Add To Cart', 'merchant' ),
959 ),
960 ),
961 ),
962 array(
963 'id' => 'thank_you_page',
964 'type' => 'fields_group',
965 'title' => esc_html__( 'Thank You Page', 'merchant' ),
966 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the thank you page.', 'merchant' ),
967 'state' => 'closed',
968 'accordion' => true,
969 'display_status' => true,
970 'default' => 'inactive',
971 'fields' => array(
972 // Text Formatting Settings
973 array(
974 'id' => 'title',
975 'type' => 'text',
976 'title' => esc_html__( 'Offer title', 'merchant' ),
977 'default' => esc_html__( 'Add {quantity} more to get {discount} off', 'merchant' ),
978 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
979 'hidden_desc' => sprintf(
980 /* Translators: %1$s: quantity, %2$s: post purchase discount, %3$s: In Stock, %4$s: Total quantity */
981 __(
982 '<strong>%1$s:</strong> to show product quantity<br><strong>%2$s:</strong> to show the discount amount',
983 'merchant'
984 ),
985 '{quantity}',
986 '{discount}'
987 ),
988 ),
989
990 array(
991 'id' => 'placement',
992 'type' => 'select',
993 'title' => esc_html__( 'Placement', 'merchant' ),
994 'options' => array(
995 'on_top' => esc_html__( 'On Top', 'merchant' ),
996 'before_order_details' => esc_html__( 'Before Order details', 'merchant' ),
997 'after_order_details' => esc_html__( 'After Order details', 'merchant' ),
998 ),
999 'default' => 'before_order_details',
1000 ),
1001
1002 array(
1003 'id' => 'discount_text',
1004 'type' => 'text',
1005 'title' => esc_html__( 'Discount text', 'merchant' ),
1006 'default' => esc_html__( '{product_price}', 'merchant' ),
1007 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
1008 'hidden_desc' => sprintf(
1009 /* Translators: %1$s: Discount amount, %2$s: product price */
1010 __(
1011 '<strong>%1$s:</strong> to show the discount amount<br><strong>%2$s:</strong> to show the product price before and after the offer discount',
1012 'merchant'
1013 ),
1014 '{discount}',
1015 '{product_price}'
1016 ),
1017 ),
1018
1019 array(
1020 'id' => 'bonus_tip_text',
1021 'type' => 'text',
1022 'title' => esc_html__( 'Bonus tip text', 'merchant' ),
1023 'default' => esc_html__( 'Bonus: You will also receive this discount off each item you just purchased as part of this bulk discount offer.', 'merchant' ),
1024 ),
1025
1026 array(
1027 'id' => 'button_text',
1028 'type' => 'text',
1029 'title' => esc_html__( 'Button text', 'merchant' ),
1030 'default' => esc_html__( 'Add To Cart', 'merchant' ),
1031 ),
1032 ),
1033 ),
1034 ),
1035 ),
1036 ),
1037 'default' => array(
1038 array(
1039 'layout' => 'offer-details',
1040 'min_quantity' => 2,
1041 'discount' => 10,
1042 'discount_type' => 'fixed_discount',
1043 ),
1044 ),
1045 ),
1046 ),
1047 ),
1048 array(
1049 'title' => esc_html__( 'General', 'merchant' ),
1050 'module' => Merchant_Volume_Discounts::MODULE_ID,
1051 'fields' => array(
1052 array(
1053 'id' => 'max_checkout_offers',
1054 'type' => 'number',
1055 'title' => __( 'Max offers on checkout page', 'merchant' ),
1056 'desc' => __( 'Set the maximum offers can be displayed on the checkout page.', 'merchant' ),
1057 'default' => 3,
1058 ),
1059
1060 array(
1061 'id' => 'offers_display_style',
1062 'type' => 'radio',
1063 'title' => esc_html__( 'Discount Display Style', 'merchant' ),
1064 'options' => array(
1065 'standard' => esc_html__( 'Standard Boxes', 'merchant' ),
1066 'radio' => esc_html__( 'Tiered Radio Select', 'merchant' ),
1067 ),
1068 'default' => 'standard',
1069 ),
1070 ),
1071 ),
1072 array(
1073 'module' => Merchant_Volume_Discounts::MODULE_ID,
1074 'title' => esc_html__( 'Use shortcode', 'merchant' ),
1075 'fields' => array(
1076 array(
1077 'id' => 'use_shortcode',
1078 'type' => 'switcher',
1079 'title' => __( 'Use shortcode', 'merchant' ),
1080 'default' => 0,
1081 ),
1082 array(
1083 'type' => 'info',
1084 'id' => 'shortcode_info',
1085 'content' => esc_html__( 'If you are using a page builder or a theme that supports shortcodes, then you can output the module using the shortcode above. This might be useful if, for example, you find that you want to control the position of the module output more precisely than with the module settings. Note that the shortcodes can only be used on single product pages.',
1086 'merchant' ),
1087 ),
1088 array(
1089 'id' => 'shortcode_text',
1090 'type' => 'text_readonly',
1091 'title' => esc_html__( 'Shortcode text', 'merchant' ),
1092 'default' => '[merchant_module_' . str_replace( '-', '_', Merchant_Volume_Discounts::MODULE_ID ) . ']',
1093 'condition' => array( 'use_shortcode', '==', '1' ),
1094 ),
1095 ),
1096 ),
1097 );
1098