PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
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
← All changes | inc/modules/complementary-products/admin/options.php +234 -18 2.2.72.3.2 View file →
@@ -1,9 +1,12 @@
1 1 <?php
2 2
3 3 /**
4 - * Add To Cart Text Options.
4 + * Add To Cart Text — Option group definitions.
5 5 *
6 + * Pure data file. Returns the option groups array
7 + * consumed by init_option_groups().
8 + *
6 9 * @package Merchant
7 10 */
8 11
9 12 if ( ! defined( 'ABSPATH' ) ) {
@@ -9,10 +12,10 @@
9 12 if ( ! defined( 'ABSPATH' ) ) {
10 13 exit; // Exit if accessed directly
11 14 }
12 15
13 -// Settings
14 -Merchant_Admin_Options::create( array(
16 +return array(
17 + array(
15 18 'title' => esc_html__( 'Complementary Offers', 'merchant' ),
16 19 'module' => Merchant_Complementary_Products::MODULE_ID,
17 20 'fields' => array(
18 21 array(
@@ -37,8 +40,12 @@
37 40 'active' => esc_html__( 'Active', 'merchant' ),
38 41 'inactive' => esc_html__( 'Inactive', 'merchant' ),
39 42 ),
40 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 +
41 48 ),
42 49 array(
43 50 'id' => 'offer-title',
44 51 'type' => 'text',
@@ -56,8 +63,13 @@
56 63 'tags' => esc_html__( 'Specific Tags', 'merchant' ),
57 64 'brands' => esc_html__( 'Specific Brands', 'merchant' ),
58 65 ),
59 66 'default' => 'products',
67 + 'ai_meta' => array(
68 + 'semantic_group' => 'product_targeting',
69 + '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.',
70 + ),
71 +
60 72 ),
61 73 array(
62 74 'id' => 'product_to_display',
63 75 'type' => 'products_selector',
@@ -64,8 +76,17 @@
64 76 'title' => esc_html__( 'Select a product', 'merchant' ),
65 77 'multiple' => false,
66 78 'desc' => esc_html__( 'Select the product you want to pair with the complementary items.', 'merchant' ),
67 79 'condition' => array( 'rules_to_display', '==', 'products' ),
80 + 'ai_meta' => array(
81 + 'entity' => 'product',
82 + 'reference_type' => 'static',
83 + 'value_format' => 'product_id',
84 + 'semantic_group' => 'product_targeting',
85 + 'abstraction_level' => 1,
86 + 'usage_hint' => 'Use when targeting specific individual products by name or SKU. Requires rules_to_display=products.',
87 + ),
88 +
68 89 ),
69 90 array(
70 91 'id' => 'category_slugs',
71 92 'type' => 'select_ajax',
@@ -75,8 +96,18 @@
75 96 'options' => Merchant_Admin_Options::get_category_select2_choices(),
76 97 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
77 98 'desc' => esc_html__( 'Select the product categories that will show the complementary items.', 'merchant' ),
78 99 'condition' => array( 'rules_to_display', '==', 'categories' ),
100 + 'ai_meta' => array(
101 + 'entity' => 'category',
102 + 'reference_type' => 'dynamic',
103 + 'taxonomy' => 'product_cat',
104 + 'value_format' => 'slug',
105 + 'semantic_group' => 'product_targeting',
106 + 'abstraction_level' => 3,
107 + 'usage_hint' => 'Use when targeting products by category. Dynamic: future products added to the category are included. Requires rules_to_display=categories.',
108 + ),
109 +
79 110 ),
80 111
81 112 array(
82 113 'id' => 'tag_slugs',
@@ -87,8 +118,18 @@
87 118 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
88 119 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
89 120 'desc' => esc_html__( 'Select the product tags that will show the complementary items.', 'merchant' ),
90 121 'condition' => array( 'rules_to_display', '==', 'tags' ),
122 + 'ai_meta' => array(
123 + 'entity' => 'tag',
124 + 'reference_type' => 'dynamic',
125 + 'taxonomy' => 'product_tag',
126 + 'value_format' => 'slug',
127 + 'semantic_group' => 'product_targeting',
128 + 'abstraction_level' => 2,
129 + 'usage_hint' => 'Use when targeting products by tag. Dynamic: future products added to the tag are included. Requires rules_to_display=tags.',
130 + ),
131 +
91 132 ),
92 133 array(
93 134 'id' => 'brand_slugs',
94 135 'type' => 'select_ajax',
@@ -98,8 +139,18 @@
98 139 'options' => Merchant_Admin_Options::get_brand_select2_choices(),
99 140 'placeholder' => esc_html__( 'Select brands', 'merchant' ),
100 141 'desc' => esc_html__( 'Select the product brands that will show the complementary items.', 'merchant' ),
101 142 'condition' => array( 'rules_to_display', '==', 'brands' ),
143 + 'ai_meta' => array(
144 + 'entity' => 'brand',
145 + 'reference_type' => 'dynamic',
146 + 'taxonomy' => 'product_brand',
147 + 'value_format' => 'slug',
148 + 'semantic_group' => 'product_targeting',
149 + 'abstraction_level' => 4,
150 + 'usage_hint' => 'Use when targeting products by brand. Dynamic: future products added to the brand are included. Requires rules_to_display=brands.',
151 + ),
152 +
102 153 ),
103 154
104 155 array(
105 156 'id' => 'exclude_products_toggle',
@@ -115,8 +166,14 @@
115 166 'value' => array( 'all', 'categories', 'tags', 'brands' ),
116 167 ),
117 168 ),
118 169 ),
170 + 'ai_meta' => array(
171 + 'toggle_for' => 'excluded_products',
172 + 'semantic_group' => 'product_exclusion',
173 + 'usage_hint' => 'Enable this toggle before setting excluded_products. Only available when rules_to_display is all, categories, tags, or brands.',
174 + ),
175 +
119 176 ),
120 177
121 178 array(
122 179 'id' => 'excluded_products',
@@ -138,8 +195,18 @@
138 195 'value' => true,
139 196 ),
140 197 ),
141 198 ),
199 + 'ai_meta' => array(
200 + 'entity' => 'product',
201 + 'reference_type' => 'static',
202 + 'value_format' => 'product_id',
203 + 'semantic_group' => 'product_exclusion',
204 + 'abstraction_level' => 1,
205 + 'toggled_by' => 'exclude_products_toggle',
206 + 'usage_hint' => 'Use ONLY for excluding specific individual products. For brand/category/tag exclusions, prefer excluded_brands/excluded_categories/excluded_tags.',
207 + ),
208 +
142 209 ),
143 210
144 211 array(
145 212 'id' => 'exclude_categories_toggle',
@@ -155,8 +222,14 @@
155 222 'value' => array( 'all', 'tags', 'brands' ),
156 223 ),
157 224 ),
158 225 ),
226 + 'ai_meta' => array(
227 + 'toggle_for' => 'excluded_categories',
228 + 'semantic_group' => 'product_exclusion',
229 + 'usage_hint' => 'Enable this toggle before setting excluded_categories. Only available when rules_to_display is all, tags, or brands.',
230 + ),
231 +
159 232 ),
160 233
161 234 array(
162 235 'id' => 'excluded_categories',
@@ -181,11 +254,59 @@
181 254 'value' => true,
182 255 ),
183 256 ),
184 257 ),
258 + 'ai_meta' => array(
259 + 'entity' => 'category',
260 + 'reference_type' => 'dynamic',
261 + 'taxonomy' => 'product_cat',
262 + 'value_format' => 'slug',
263 + 'semantic_group' => 'product_exclusion',
264 + 'abstraction_level' => 3,
265 + 'toggled_by' => 'exclude_categories_toggle',
266 + 'usage_hint' => 'Use when excluding products by category. Dynamic: future products added to the category are automatically excluded.',
267 + ),
268 +
185 269 ),
186 270
187 271 array(
272 + 'id' => 'include_subcategories',
273 + 'type' => 'switcher',
274 + 'title' => esc_html__( 'Include subcategories', 'merchant' ),
275 + 'desc' => esc_html__( 'When enabled, selecting a parent category also applies to all of its child categories.', 'merchant' ),
276 + 'default' => 0,
277 + 'conditions' => array(
278 + 'relation' => 'OR',
279 + 'terms' => array(
280 + array(
281 + 'field' => 'rules_to_display',
282 + 'operator' => '===',
283 + 'value' => 'categories',
284 + ),
285 + array(
286 + 'relation' => 'AND',
287 + 'terms' => array(
288 + array(
289 + 'field' => 'rules_to_display',
290 + 'operator' => 'in',
291 + 'value' => array( 'all', 'tags', 'brands' ),
292 + ),
293 + array(
294 + 'field' => 'exclude_categories_toggle',
295 + 'operator' => '===',
296 + 'value' => true,
297 + ),
298 + ),
299 + ),
300 + ),
301 + ),
302 + 'ai_meta' => array(
303 + 'semantic_group' => 'product_targeting',
304 + 'usage_hint' => 'Enable so selected parent categories also cover their child categories, for both targeting and exclusion. Off by default, which matches only the exact categories chosen.',
305 + ),
306 + ),
307 +
308 + array(
188 309 'id' => 'exclude_tags_toggle',
189 310 'type' => 'switcher',
190 311 'title' => esc_html__( 'Exclude product tags', 'merchant' ),
191 312 'default' => 0,
@@ -198,8 +319,14 @@
198 319 'value' => array( 'all', 'categories', 'brands' ),
199 320 ),
200 321 ),
201 322 ),
323 + 'ai_meta' => array(
324 + 'toggle_for' => 'excluded_tags',
325 + 'semantic_group' => 'product_exclusion',
326 + 'usage_hint' => 'Enable this toggle before setting excluded_tags. Only available when rules_to_display is all, categories, or brands.',
327 + ),
328 +
202 329 ),
203 330
204 331 array(
205 332 'id' => 'excluded_tags',
@@ -224,8 +351,19 @@
224 351 'value' => true,
225 352 ),
226 353 ),
227 354 ),
355 + 'ai_meta' => array(
356 + 'entity' => 'tag',
357 + 'reference_type' => 'dynamic',
358 + 'taxonomy' => 'product_tag',
359 + 'value_format' => 'slug',
360 + 'semantic_group' => 'product_exclusion',
361 + 'abstraction_level' => 2,
362 + 'toggled_by' => 'exclude_tags_toggle',
363 + 'usage_hint' => 'Use when excluding products by tag. Dynamic: future products added to the tag are automatically excluded.',
364 + ),
365 +
228 366 ),
229 367
230 368 array(
231 369 'id' => 'exclude_brands_toggle',
@@ -241,8 +379,14 @@
241 379 'value' => array( 'all', 'categories', 'tags' ),
242 380 ),
243 381 ),
244 382 ),
383 + 'ai_meta' => array(
384 + 'toggle_for' => 'excluded_brands',
385 + 'semantic_group' => 'product_exclusion',
386 + 'usage_hint' => 'Enable this toggle before setting excluded_brands. Only available when rules_to_display is all, categories, or tags.',
387 + ),
388 +
245 389 ),
246 390
247 391 array(
248 392 'id' => 'excluded_brands',
@@ -267,8 +411,19 @@
267 411 'value' => true,
268 412 ),
269 413 ),
270 414 ),
415 + 'ai_meta' => array(
416 + 'entity' => 'brand',
417 + 'reference_type' => 'dynamic',
418 + 'taxonomy' => 'product_brand',
419 + 'value_format' => 'slug',
420 + 'semantic_group' => 'product_exclusion',
421 + 'abstraction_level' => 4,
422 + 'toggled_by' => 'exclude_brands_toggle',
423 + 'usage_hint' => 'Use when excluding products by brand. Dynamic: future products added to the brand are automatically excluded.',
424 + ),
425 +
271 426 ),
272 427
273 428 array(
274 429 'id' => 'products',
@@ -275,8 +430,17 @@
275 430 'title' => esc_html__( 'Complementary products', 'merchant' ),
276 431 'type' => 'products_selector',
277 432 'multiple' => true,
278 433 'desc' => esc_html__( 'Select the products you want to sell alongside the main product', 'merchant' ),
434 + 'ai_meta' => array(
435 + 'entity' => 'product',
436 + 'reference_type' => 'static',
437 + 'value_format' => 'product_id',
438 + 'semantic_group' => 'offer_rules',
439 + 'abstraction_level' => 1,
440 + 'usage_hint' => 'The complementary products to suggest alongside the trigger products.',
441 + ),
442 +
279 443 ),
280 444 array(
281 445 'id' => 'enable_discount',
282 446 'type' => 'switcher',
@@ -303,8 +467,12 @@
303 467 'value' => true,
304 468 ),
305 469 ),
306 470 ),
471 + 'ai_meta' => array(
472 + 'usage_hint' => 'Choose percentage_discount for relative discounts or fixed_discount for absolute amounts.',
473 + ),
474 +
307 475 ),
308 476 array(
309 477 'id' => 'discount_value',
310 478 'type' => 'number',
@@ -324,8 +492,13 @@
324 492 'value' => array( 'percentage_discount', 'fixed_discount' ),
325 493 ),
326 494 ),
327 495 ),
496 + 'ai_meta' => array(
497 + 'semantic_group' => 'offer_rules',
498 + 'usage_hint' => 'The discount amount. Percentage (e.g. 10 for 10%% off) or fixed currency amount, depending on discount_type.',
499 + ),
500 +
328 501 ),
329 502 array(
330 503 'id' => 'min_selection_discount',
331 504 'title' => esc_html__( 'Minimum product selection to trigger the discount', 'merchant' ),
@@ -362,8 +535,13 @@
362 535 'customers' => esc_html__( 'Selected Users', 'merchant' ),
363 536 'roles' => esc_html__( 'Selected Roles', 'merchant' ),
364 537 ),
365 538 'default' => 'all',
539 + 'ai_meta' => array(
540 + 'semantic_group' => 'user_targeting',
541 + 'usage_hint' => 'Controls which users see this campaign. Set this BEFORE setting user_condition_roles or user_condition_users.',
542 + ),
543 +
366 544 ),
367 545 array(
368 546 'id' => 'user_condition_roles',
369 547 'type' => 'select_ajax',
@@ -373,8 +551,17 @@
373 551 'multiple' => true,
374 552 'classes' => array( 'flex-grow' ),
375 553 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
376 554 'condition' => array( 'user_condition', '==', 'roles' ),
555 + 'ai_meta' => array(
556 + 'entity' => 'role',
557 + 'reference_type' => 'dynamic',
558 + 'value_format' => 'role_slug',
559 + 'semantic_group' => 'user_targeting',
560 + 'abstraction_level' => 2,
561 + 'usage_hint' => 'Use when targeting users by role. Dynamic: future users assigned the role are included. Requires user_condition=roles.',
562 + ),
563 +
377 564 ),
378 565
379 566 array(
380 567 'id' => 'user_condition_users',
@@ -384,8 +571,17 @@
384 571 'source' => 'user',
385 572 'multiple' => true,
386 573 'classes' => array( 'flex-grow' ),
387 574 'condition' => array( 'user_condition', '==', 'customers' ),
575 + 'ai_meta' => array(
576 + 'entity' => 'user',
577 + 'reference_type' => 'static',
578 + 'value_format' => 'user_id',
579 + 'semantic_group' => 'user_targeting',
580 + 'abstraction_level' => 1,
581 + 'usage_hint' => 'Use when targeting specific individual users. Static: only selected users, not future users. Requires user_condition=customers.',
582 + ),
583 +
388 584 ),
389 585
390 586 array(
391 587 'id' => 'user_exclusion_enabled',
@@ -402,8 +598,14 @@
402 598 'value' => array( 'all', 'roles' ),
403 599 ),
404 600 ),
405 601 ),
602 + 'ai_meta' => array(
603 + 'toggle_for' => 'exclude_roles',
604 + 'semantic_group' => 'user_exclusion',
605 + 'usage_hint' => 'Enable this toggle before setting exclude_roles or exclude_users. Gates both user exclusion fields.',
606 + ),
607 +
406 608 ),
407 609
408 610 array(
409 611 'id' => 'exclude_roles',
@@ -428,8 +630,18 @@
428 630 'value' => true,
429 631 ),
430 632 ),
431 633 ),
634 + 'ai_meta' => array(
635 + 'entity' => 'role',
636 + 'reference_type' => 'dynamic',
637 + 'value_format' => 'role_slug',
638 + 'semantic_group' => 'user_exclusion',
639 + 'abstraction_level' => 2,
640 + 'toggled_by' => 'user_exclusion_enabled',
641 + 'usage_hint' => 'Use when excluding users by role. Dynamic: future users assigned the role are excluded.',
642 + ),
643 +
432 644 ),
433 645
434 646 array(
435 647 'id' => 'exclude_users',
@@ -453,8 +665,18 @@
453 665 'value' => true,
454 666 ),
455 667 ),
456 668 ),
669 + 'ai_meta' => array(
670 + 'entity' => 'user',
671 + 'reference_type' => 'static',
672 + 'value_format' => 'user_id',
673 + 'semantic_group' => 'user_exclusion',
674 + 'abstraction_level' => 1,
675 + 'toggled_by' => 'user_exclusion_enabled',
676 + 'usage_hint' => 'Use ONLY for excluding specific individual users. For role-level exclusions, prefer exclude_roles.',
677 + ),
678 +
457 679 ),
458 680
459 681 array(
460 682 'id' => 'product_single_page',
@@ -675,15 +897,11 @@
675 897 ),
676 898 ),
677 899 ),
678 900 ),
679 -) );
680 -
681 -
682 -/**
683 - * Style
684 - */
685 -Merchant_Admin_Options::create( array(
901 +),
902 + // Style
903 + array(
686 904 'title' => esc_html__( 'Look and Feel', 'merchant' ),
687 905 'module' => Merchant_Complementary_Products::MODULE_ID,
688 906 'fields' => array(
689 907 array(
@@ -805,14 +1023,11 @@
805 1023 'default' => 0,
806 1024 'unit' => 'px',
807 1025 ),
808 1026 ),
809 -) );
810 -
811 -// Shortcode
812 -$merchant_module_id = Merchant_Complementary_Products::MODULE_ID;
813 -Merchant_Admin_Options::create( array(
814 - 'module' => $merchant_module_id,
1027 +),
1028 + array(
1029 + 'module' => Merchant_Complementary_Products::MODULE_ID,
815 1030 'title' => esc_html__( 'Use shortcode', 'merchant' ),
816 1031 'fields' => array(
817 1032 array(
818 1033 'id' => 'use_shortcode',
@@ -829,9 +1044,10 @@
829 1044 array(
830 1045 'id' => 'shortcode_text',
831 1046 'type' => 'text_readonly',
832 1047 'title' => esc_html__( 'Shortcode text', 'merchant' ),
833 - 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']',
1048 + 'default' => '[merchant_module_' . str_replace( '-', '_', Merchant_Complementary_Products::MODULE_ID ) . ']',
834 1049 'condition' => array( 'use_shortcode', '==', '1' ),
835 1050 ),
836 1051 ),
837 -) );
1052 +),
1053 +);