| @@ -1,9 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Side Cart Options. | |
| 4 | + * Side Cart — 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,9 +12,10 @@ | ||
| 9 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | 13 | exit; // Exit if accessed directly |
| 11 | 14 | } |
| 12 | 15 | |
| 13 | -Merchant_Admin_Options::create( array( | |
| 16 | +return array( | |
| 17 | + array( | |
| 14 | 18 | 'module' => Merchant_Side_Cart::MODULE_ID, |
| 15 | 19 | 'title' => esc_html__( 'Display Settings', 'merchant' ), |
| 16 | 20 | 'fields' => array( |
| 17 | 21 | array( |
| @@ -117,12 +121,10 @@ | ||
| 117 | 121 | ), |
| 118 | 122 | 'default' => array( 'desktop', 'mobile' ), |
| 119 | 123 | ), |
| 120 | 124 | ), |
| 121 | -) ); | |
| 122 | - | |
| 123 | -// Upsells | |
| 124 | -Merchant_Admin_Options::create( array( | |
| 125 | +), | |
| 126 | + array( | |
| 125 | 127 | 'module' => Merchant_Side_Cart::MODULE_ID, |
| 126 | 128 | 'title' => esc_html__( 'Upsells', 'merchant' ), |
| 127 | 129 | 'fields' => array( |
| 128 | 130 | array( |
| @@ -198,8 +200,12 @@ | ||
| 198 | 200 | 'products' => esc_html__( 'Specific product', 'merchant' ), |
| 199 | 201 | 'categories' => esc_html__( 'Specific category', 'merchant' ), |
| 200 | 202 | ), |
| 201 | 203 | 'default' => 'products', |
| 204 | + 'ai_meta' => array( | |
| 205 | + 'semantic_group' => 'product_targeting', | |
| 206 | + 'usage_hint' => 'Controls which cart products trigger this upsell. Set this BEFORE setting product_ids or category_slugs — those fields are conditional on this value.', | |
| 207 | + ), | |
| 202 | 208 | ), |
| 203 | 209 | array( |
| 204 | 210 | 'id' => 'product_ids', |
| 205 | 211 | 'type' => 'products_selector', |
| @@ -216,8 +222,16 @@ | ||
| 216 | 222 | 'value' => 'products', // can be a single value or an array of string/number/int |
| 217 | 223 | ), |
| 218 | 224 | ), |
| 219 | 225 | ), |
| 226 | + 'ai_meta' => array( | |
| 227 | + 'entity' => 'product', | |
| 228 | + 'reference_type' => 'static', | |
| 229 | + 'value_format' => 'product_id', | |
| 230 | + 'semantic_group' => 'product_targeting', | |
| 231 | + 'abstraction_level' => 1, | |
| 232 | + 'usage_hint' => 'Use when triggering the upsell for specific individual products in the cart. Requires upsell_based_on=products.', | |
| 233 | + ), | |
| 220 | 234 | ), |
| 221 | 235 | array( |
| 222 | 236 | 'id' => 'category_slugs', |
| 223 | 237 | 'type' => 'select_ajax', |
| @@ -236,8 +250,17 @@ | ||
| 236 | 250 | 'value' => 'categories', // can be a single value or an array of string/number/int |
| 237 | 251 | ), |
| 238 | 252 | ), |
| 239 | 253 | ), |
| 254 | + 'ai_meta' => array( | |
| 255 | + 'entity' => 'category', | |
| 256 | + 'reference_type' => 'dynamic', | |
| 257 | + 'taxonomy' => 'product_cat', | |
| 258 | + 'value_format' => 'slug', | |
| 259 | + 'semantic_group' => 'product_targeting', | |
| 260 | + 'abstraction_level' => 3, | |
| 261 | + 'usage_hint' => 'Use when triggering the upsell for products from specific categories in the cart. Dynamic: future products in the category are included. Requires upsell_based_on=categories.', | |
| 262 | + ), | |
| 240 | 263 | ), |
| 241 | 264 | array( |
| 242 | 265 | 'id' => 'exclusion_toggle', |
| 243 | 266 | 'type' => 'switcher', |
| @@ -253,8 +276,13 @@ | ||
| 253 | 276 | 'value' => array( 'all', 'categories' ), // can be a single value or an array of string/number/int |
| 254 | 277 | ), |
| 255 | 278 | ), |
| 256 | 279 | ), |
| 280 | + 'ai_meta' => array( | |
| 281 | + 'toggle_for' => 'excluded_product_ids', | |
| 282 | + 'semantic_group' => 'product_exclusion', | |
| 283 | + 'usage_hint' => 'Enable this toggle before setting excluded_product_ids or excluded_category_slugs. Only available when upsell_based_on is all or categories.', | |
| 284 | + ), | |
| 257 | 285 | ), |
| 258 | 286 | array( |
| 259 | 287 | 'id' => 'excluded_product_ids', |
| 260 | 288 | 'type' => 'products_selector', |
| @@ -296,8 +324,17 @@ | ||
| 296 | 324 | ), |
| 297 | 325 | ), |
| 298 | 326 | ), |
| 299 | 327 | ), |
| 328 | + 'ai_meta' => array( | |
| 329 | + 'entity' => 'product', | |
| 330 | + 'reference_type' => 'static', | |
| 331 | + 'value_format' => 'product_id', | |
| 332 | + 'semantic_group' => 'product_exclusion', | |
| 333 | + 'abstraction_level' => 1, | |
| 334 | + 'toggled_by' => 'exclusion_toggle', | |
| 335 | + 'usage_hint' => 'Products in the cart that will NOT show this upsell. Requires exclusion_toggle=true.', | |
| 336 | + ), | |
| 300 | 337 | ), |
| 301 | 338 | array( |
| 302 | 339 | 'id' => 'excluded_category_slugs', |
| 303 | 340 | 'type' => 'select_ajax', |
| @@ -321,10 +358,46 @@ | ||
| 321 | 358 | 'value' => true, // can be a single value or an array of string/number/int |
| 322 | 359 | ), |
| 323 | 360 | ), |
| 324 | 361 | ), |
| 362 | + 'ai_meta' => array( | |
| 363 | + 'entity' => 'category', | |
| 364 | + 'reference_type' => 'dynamic', | |
| 365 | + 'taxonomy' => 'product_cat', | |
| 366 | + 'value_format' => 'slug', | |
| 367 | + 'semantic_group' => 'product_exclusion', | |
| 368 | + 'abstraction_level' => 3, | |
| 369 | + 'toggled_by' => 'exclusion_toggle', | |
| 370 | + 'usage_hint' => 'Cart products from these categories will NOT trigger this upsell. Dynamic: future products in the category are automatically excluded. Requires exclusion_toggle=true and upsell_based_on=all.', | |
| 371 | + ), | |
| 325 | 372 | ), |
| 326 | 373 | array( |
| 374 | + 'id' => 'include_subcategories', | |
| 375 | + 'type' => 'switcher', | |
| 376 | + 'title' => esc_html__( 'Include subcategories', 'merchant' ), | |
| 377 | + 'desc' => esc_html__( 'When enabled, selecting a parent category also applies to all of its child categories.', 'merchant' ), | |
| 378 | + 'default' => 0, | |
| 379 | + 'conditions' => array( | |
| 380 | + 'relation' => 'OR', | |
| 381 | + 'terms' => array( | |
| 382 | + array( | |
| 383 | + 'field' => 'upsell_based_on', | |
| 384 | + 'operator' => '===', | |
| 385 | + 'value' => 'categories', | |
| 386 | + ), | |
| 387 | + array( | |
| 388 | + 'field' => 'exclusion_toggle', | |
| 389 | + 'operator' => '===', | |
| 390 | + 'value' => true, | |
| 391 | + ), | |
| 392 | + ), | |
| 393 | + ), | |
| 394 | + 'ai_meta' => array( | |
| 395 | + 'semantic_group' => 'product_targeting', | |
| 396 | + 'usage_hint' => 'Enable so selected parent categories also cover their child categories, for both the upsell trigger and the category exclusion. Off by default, which matches only the exact categories chosen. Does not affect which products are recommended.', | |
| 397 | + ), | |
| 398 | + ), | |
| 399 | + array( | |
| 327 | 400 | 'id' => 'custom_upsell_type', |
| 328 | 401 | 'type' => 'select', |
| 329 | 402 | 'title' => esc_html__( 'Trigger upsells', 'merchant' ), |
| 330 | 403 | 'options' => array( |
| @@ -331,8 +404,11 @@ | ||
| 331 | 404 | 'products' => esc_html__( 'Specific product', 'merchant' ), |
| 332 | 405 | 'categories' => esc_html__( 'Specific category', 'merchant' ), |
| 333 | 406 | ), |
| 334 | 407 | 'default' => 'products', |
| 408 | + 'ai_meta' => array( | |
| 409 | + 'usage_hint' => 'Controls whether the recommended upsell products are selected individually or by category. Set this BEFORE setting upsells_product_ids or upsells_category_slugs.', | |
| 410 | + ), | |
| 335 | 411 | ), |
| 336 | 412 | array( |
| 337 | 413 | 'id' => 'upsells_product_ids', |
| 338 | 414 | 'type' => 'products_selector', |
| @@ -349,8 +425,14 @@ | ||
| 349 | 425 | 'value' => 'products', // can be a single value or an array of string/number/int |
| 350 | 426 | ), |
| 351 | 427 | ), |
| 352 | 428 | ), |
| 429 | + 'ai_meta' => array( | |
| 430 | + 'entity' => 'product', | |
| 431 | + 'reference_type' => 'static', | |
| 432 | + 'value_format' => 'product_id', | |
| 433 | + 'usage_hint' => 'The specific products to recommend as upsells. Requires custom_upsell_type=products.', | |
| 434 | + ), | |
| 353 | 435 | ), |
| 354 | 436 | array( |
| 355 | 437 | 'id' => 'upsells_category_slugs', |
| 356 | 438 | 'type' => 'select_ajax', |
| @@ -369,8 +451,15 @@ | ||
| 369 | 451 | 'value' => 'categories', // can be a single value or an array of string/number/int |
| 370 | 452 | ), |
| 371 | 453 | ), |
| 372 | 454 | ), |
| 455 | + 'ai_meta' => array( | |
| 456 | + 'entity' => 'category', | |
| 457 | + 'reference_type' => 'dynamic', | |
| 458 | + 'taxonomy' => 'product_cat', | |
| 459 | + 'value_format' => 'slug', | |
| 460 | + 'usage_hint' => 'Recommend products from these categories as upsells. Requires custom_upsell_type=categories.', | |
| 461 | + ), | |
| 373 | 462 | ), |
| 374 | 463 | ), |
| 375 | 464 | ), |
| 376 | 465 | ), |
| @@ -467,12 +556,10 @@ | ||
| 467 | 556 | ), |
| 468 | 557 | ), |
| 469 | 558 | ), |
| 470 | 559 | ), |
| 471 | -) ); | |
| 472 | - | |
| 473 | -// Floating Mini Cart | |
| 474 | -Merchant_Admin_Options::create( array( | |
| 560 | +), | |
| 561 | + array( | |
| 475 | 562 | 'module' => Merchant_Side_Cart::MODULE_ID, |
| 476 | 563 | 'title' => esc_html__( 'Floating Mini Cart', 'merchant' ), |
| 477 | 564 | 'fields' => array( |
| 478 | 565 | array( |
| @@ -589,12 +676,10 @@ | ||
| 589 | 676 | 'default' => '#757575', |
| 590 | 677 | 'condition' => array( 'enable-floating-cart', '==', '1' ), |
| 591 | 678 | ), |
| 592 | 679 | ), |
| 593 | -) ); | |
| 594 | - | |
| 595 | -// Side Cart Settings | |
| 596 | -Merchant_Admin_Options::create( array( | |
| 680 | +), | |
| 681 | + array( | |
| 597 | 682 | 'module' => Merchant_Side_Cart::MODULE_ID, |
| 598 | 683 | 'title' => esc_html__( 'Look and Feel', 'merchant' ), |
| 599 | 684 | 'fields' => array( |
| 600 | 685 | |
| @@ -713,5 +798,6 @@ | ||
| 713 | 798 | 'title' => esc_html__( 'Button background color hover', 'merchant' ), |
| 714 | 799 | 'default' => '#313131', |
| 715 | 800 | ), |
| 716 | 801 | ), |
| 717 | -) ); | |
| 802 | +), | |
| 803 | +); | |