| @@ -14,11 +14,10 @@ | ||
| 14 | 14 | * Hook functionality before including modules options. |
| 15 | 15 | * |
| 16 | 16 | * @since 1.9.8 |
| 17 | 17 | */ |
| 18 | -do_action( 'merchant_admin_before_include_modules_options', Merchant_Pre_Orders::MODULE_ID ); | |
| 19 | 18 | |
| 20 | -Merchant_Admin_Options::create( | |
| 19 | +return array( | |
| 21 | 20 | array( |
| 22 | 21 | 'title' => esc_html__( 'Pre-order Rule', 'merchant' ), |
| 23 | 22 | 'module' => Merchant_Pre_Orders::MODULE_ID, |
| 24 | 23 | 'fields' => array( |
| @@ -33,10 +32,24 @@ | ||
| 33 | 32 | 'layouts' => array( |
| 34 | 33 | 'rule-details' => array( |
| 35 | 34 | 'title' => esc_html__( 'Campaign', 'merchant' ), |
| 36 | 35 | 'title-field' => 'offer-title', // text field ID to use as title for the layout |
| 36 | + 'status-field' => 'campaign_status', | |
| 37 | 37 | 'fields' => array( |
| 38 | 38 | array( |
| 39 | + 'id' => 'campaign_status', | |
| 40 | + 'type' => 'select', | |
| 41 | + 'title' => esc_html__( 'Status', 'merchant' ), | |
| 42 | + 'options' => array( | |
| 43 | + 'active' => esc_html__( 'Active', 'merchant' ), | |
| 44 | + 'inactive' => esc_html__( 'Inactive', 'merchant' ), | |
| 45 | + ), | |
| 46 | + 'default' => 'active', | |
| 47 | + 'ai_meta' => array( | |
| 48 | + 'usage_hint' => 'Controls whether this campaign is active or inactive. Set to active to enable, inactive to disable.', | |
| 49 | + ), | |
| 50 | + ), | |
| 51 | + array( | |
| 39 | 52 | 'id' => 'offer-title', |
| 40 | 53 | 'type' => 'text', |
| 41 | 54 | 'title' => esc_html__( 'Order name', 'merchant' ), |
| 42 | 55 | 'default' => esc_html__( 'Custom Pre-order', 'merchant' ), |
| @@ -50,10 +63,15 @@ | ||
| 50 | 63 | 'all' => esc_html__( 'All Products', 'merchant' ), |
| 51 | 64 | 'product' => esc_html__( 'Specific Products', 'merchant' ), |
| 52 | 65 | 'category' => esc_html__( 'Specific Categories', 'merchant' ), |
| 53 | 66 | 'tags' => esc_html__( 'Specific Tags', 'merchant' ), |
| 67 | + 'brands' => esc_html__( 'Specific Brands', 'merchant' ), | |
| 54 | 68 | ), |
| 55 | 69 | 'default' => 'product', |
| 70 | + 'ai_meta' => array( | |
| 71 | + 'semantic_group' => 'product_targeting', | |
| 72 | + 'usage_hint' => 'Controls which products this pre-order campaign applies to. Set this BEFORE setting product_ids, category_slugs, tag_slugs, or brand_slugs — those fields are conditional on this value.', | |
| 73 | + ), | |
| 56 | 74 | ), |
| 57 | 75 | array( |
| 58 | 76 | 'id' => 'product_ids', |
| 59 | 77 | 'type' => 'products_selector', |
| @@ -60,8 +78,16 @@ | ||
| 60 | 78 | 'multiple' => true, |
| 61 | 79 | 'allowed_types' => array( 'simple', 'variable', 'variation', 'merchant_pro_bundle' ), |
| 62 | 80 | 'desc' => esc_html__( 'Select the product(s) included in this pre-order.', 'merchant' ), |
| 63 | 81 | 'condition' => array( 'trigger_on', '==', 'product' ), |
| 82 | + 'ai_meta' => array( | |
| 83 | + 'entity' => 'product', | |
| 84 | + 'reference_type' => 'static', | |
| 85 | + 'value_format' => 'product_id', | |
| 86 | + 'semantic_group' => 'product_targeting', | |
| 87 | + 'abstraction_level' => 1, | |
| 88 | + 'usage_hint' => 'Product IDs included in this pre-order. Only used when trigger_on is set to product.', | |
| 89 | + ), | |
| 64 | 90 | ), |
| 65 | 91 | array( |
| 66 | 92 | 'id' => 'category_slugs', |
| 67 | 93 | 'type' => 'select_ajax', |
| @@ -71,8 +97,17 @@ | ||
| 71 | 97 | 'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 72 | 98 | 'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 73 | 99 | 'desc' => esc_html__( 'Select the category or categories for which the products will be available for pre-order.', 'merchant' ), |
| 74 | 100 | 'condition' => array( 'trigger_on', '==', 'category' ), |
| 101 | + 'ai_meta' => array( | |
| 102 | + 'entity' => 'category', | |
| 103 | + 'reference_type' => 'dynamic', | |
| 104 | + 'taxonomy' => 'product_cat', | |
| 105 | + 'value_format' => 'slug', | |
| 106 | + 'semantic_group' => 'product_targeting', | |
| 107 | + 'abstraction_level' => 3, | |
| 108 | + 'usage_hint' => 'Category slugs for this pre-order. Only used when trigger_on is set to category.', | |
| 109 | + ), | |
| 75 | 110 | ), |
| 76 | 111 | array( |
| 77 | 112 | 'id' => 'tag_slugs', |
| 78 | 113 | 'type' => 'select_ajax', |
| @@ -82,15 +117,45 @@ | ||
| 82 | 117 | 'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 83 | 118 | 'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 84 | 119 | 'desc' => esc_html__( 'Select the tag or tags for which the products will be available for pre-order.', 'merchant' ), |
| 85 | 120 | 'condition' => array( 'trigger_on', '==', 'tags' ), |
| 121 | + 'ai_meta' => array( | |
| 122 | + 'entity' => 'tag', | |
| 123 | + 'reference_type' => 'dynamic', | |
| 124 | + 'taxonomy' => 'product_tag', | |
| 125 | + 'value_format' => 'slug', | |
| 126 | + 'semantic_group' => 'product_targeting', | |
| 127 | + 'abstraction_level' => 2, | |
| 128 | + 'usage_hint' => 'Tag slugs for this pre-order. Only used when trigger_on is set to tags.', | |
| 129 | + ), | |
| 86 | 130 | ), |
| 131 | + array( | |
| 132 | + 'id' => 'brand_slugs', | |
| 133 | + 'type' => 'select_ajax', | |
| 134 | + 'title' => esc_html__( 'Brands', 'merchant' ), | |
| 135 | + 'source' => 'options', | |
| 136 | + 'multiple' => true, | |
| 137 | + 'options' => Merchant_Admin_Options::get_brand_select2_choices(), | |
| 138 | + 'placeholder' => esc_html__( 'Select brands', 'merchant' ), | |
| 139 | + 'desc' => esc_html__( 'Select the brand or brands for which the products will be available for pre-order.', 'merchant' ), | |
| 140 | + 'condition' => array( 'trigger_on', '==', 'brands' ), | |
| 141 | + 'ai_meta' => array( | |
| 142 | + 'entity' => 'brand', | |
| 143 | + 'reference_type' => 'dynamic', | |
| 144 | + 'taxonomy' => 'product_brand', | |
| 145 | + 'value_format' => 'slug', | |
| 146 | + 'semantic_group' => 'product_targeting', | |
| 147 | + 'abstraction_level' => 4, | |
| 148 | + 'usage_hint' => 'Brand slugs for this pre-order. Only used when trigger_on is set to brands.', | |
| 149 | + ), | |
| 150 | + ), | |
| 87 | 151 | |
| 152 | + // Individual exclusion toggles | |
| 88 | 153 | array( |
| 89 | - 'id' => 'exclusion_enabled', | |
| 154 | + 'id' => 'exclude_products_toggle', | |
| 90 | 155 | 'type' => 'switcher', |
| 91 | - 'title' => esc_html__( 'Exclusion List', 'merchant' ), | |
| 92 | - 'desc' => esc_html__( 'Select the products that will not show the offer.', 'merchant' ), | |
| 156 | + 'title' => esc_html__( 'Exclude products', 'merchant' ), | |
| 157 | + 'desc' => esc_html__( 'Exclude specific products from this pre-order campaign.', 'merchant' ), | |
| 93 | 158 | 'default' => 0, |
| 94 | 159 | 'conditions' => array( |
| 95 | 160 | 'relation' => 'AND', |
| 96 | 161 | 'terms' => array( |
| @@ -96,21 +161,35 @@ | ||
| 96 | 161 | 'terms' => array( |
| 97 | 162 | array( |
| 98 | 163 | 'field' => 'trigger_on', |
| 99 | 164 | 'operator' => 'in', |
| 100 | - 'value' => array( 'all', 'category', 'tags' ), | |
| 165 | + 'value' => array( 'all', 'category', 'tags', 'brands' ), | |
| 101 | 166 | ), |
| 102 | 167 | ), |
| 103 | 168 | ), |
| 169 | + 'ai_meta' => array( | |
| 170 | + 'toggle_for' => 'excluded_products', | |
| 171 | + 'semantic_group' => 'product_exclusion', | |
| 172 | + 'usage_hint' => 'Enable this to reveal the excluded_products field.', | |
| 173 | + ), | |
| 104 | 174 | ), |
| 105 | 175 | |
| 106 | 176 | array( |
| 107 | 177 | 'id' => 'excluded_products', |
| 108 | 178 | 'type' => 'products_selector', |
| 109 | - 'title' => esc_html__( 'Exclude products', 'merchant' ), | |
| 110 | - 'desc' => esc_html__( 'Exclude products from this discount campaign.', 'merchant' ), | |
| 179 | + 'title' => esc_html__( 'Excluded Products List', 'merchant' ), | |
| 180 | + 'desc' => esc_html__( 'Exclude products from this pre-order campaign.', 'merchant' ), | |
| 111 | 181 | 'allowed_types' => array( 'simple', 'variable' ), |
| 112 | 182 | 'multiple' => true, |
| 183 | + 'ai_meta' => array( | |
| 184 | + 'entity' => 'product', | |
| 185 | + 'reference_type' => 'static', | |
| 186 | + 'value_format' => 'product_id', | |
| 187 | + 'semantic_group' => 'product_exclusion', | |
| 188 | + 'abstraction_level' => 1, | |
| 189 | + 'toggled_by' => 'exclude_products_toggle', | |
| 190 | + 'usage_hint' => 'Products excluded from this pre-order campaign. Requires exclude_products_toggle.', | |
| 191 | + ), | |
| 113 | 192 | 'conditions' => array( |
| 114 | 193 | 'relation' => 'AND', |
| 115 | 194 | 'terms' => array( |
| 116 | 195 | array( |
| @@ -115,12 +194,12 @@ | ||
| 115 | 194 | 'terms' => array( |
| 116 | 195 | array( |
| 117 | 196 | 'field' => 'trigger_on', |
| 118 | 197 | 'operator' => 'in', |
| 119 | - 'value' => array( 'all', 'category', 'tags' ), | |
| 198 | + 'value' => array( 'all', 'category', 'tags', 'brands' ), | |
| 120 | 199 | ), |
| 121 | 200 | array( |
| 122 | - 'field' => 'exclusion_enabled', | |
| 201 | + 'field' => 'exclude_products_toggle', | |
| 123 | 202 | 'operator' => '===', |
| 124 | 203 | 'value' => true, |
| 125 | 204 | ), |
| 126 | 205 | ), |
| @@ -127,16 +206,49 @@ | ||
| 127 | 206 | ), |
| 128 | 207 | ), |
| 129 | 208 | |
| 130 | 209 | array( |
| 210 | + 'id' => 'exclude_categories_toggle', | |
| 211 | + 'type' => 'switcher', | |
| 212 | + 'title' => esc_html__( 'Exclude categories', 'merchant' ), | |
| 213 | + 'desc' => esc_html__( 'Exclude specific categories from this pre-order campaign.', 'merchant' ), | |
| 214 | + 'default' => 0, | |
| 215 | + 'conditions' => array( | |
| 216 | + 'relation' => 'AND', | |
| 217 | + 'terms' => array( | |
| 218 | + array( | |
| 219 | + 'field' => 'trigger_on', | |
| 220 | + 'operator' => 'in', | |
| 221 | + 'value' => array( 'all', 'tags', 'brands' ), | |
| 222 | + ), | |
| 223 | + ), | |
| 224 | + ), | |
| 225 | + 'ai_meta' => array( | |
| 226 | + 'toggle_for' => 'excluded_categories', | |
| 227 | + 'semantic_group' => 'product_exclusion', | |
| 228 | + 'usage_hint' => 'Enable this to reveal the excluded_categories field.', | |
| 229 | + ), | |
| 230 | + ), | |
| 231 | + | |
| 232 | + array( | |
| 131 | 233 | 'id' => 'excluded_categories', |
| 132 | 234 | 'type' => 'select_ajax', |
| 133 | - 'title' => esc_html__( 'Exclude Categories', 'merchant' ), | |
| 235 | + 'title' => esc_html__( 'Excluded Categories List', 'merchant' ), | |
| 134 | 236 | 'source' => 'options', |
| 135 | 237 | 'multiple' => true, |
| 136 | 238 | 'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 137 | 239 | 'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 138 | - 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ), | |
| 240 | + 'desc' => esc_html__( 'Exclude categories from this pre-order campaign.', 'merchant' ), | |
| 241 | + 'ai_meta' => array( | |
| 242 | + 'entity' => 'category', | |
| 243 | + 'reference_type' => 'dynamic', | |
| 244 | + 'taxonomy' => 'product_cat', | |
| 245 | + 'value_format' => 'slug', | |
| 246 | + 'semantic_group' => 'product_exclusion', | |
| 247 | + 'abstraction_level' => 3, | |
| 248 | + 'toggled_by' => 'exclude_categories_toggle', | |
| 249 | + 'usage_hint' => 'Categories excluded from this pre-order campaign. Requires exclude_categories_toggle.', | |
| 250 | + ), | |
| 139 | 251 | 'conditions' => array( |
| 140 | 252 | 'relation' => 'AND', |
| 141 | 253 | 'terms' => array( |
| 142 | 254 | array( |
| @@ -141,12 +253,12 @@ | ||
| 141 | 253 | 'terms' => array( |
| 142 | 254 | array( |
| 143 | 255 | 'field' => 'trigger_on', |
| 144 | 256 | 'operator' => 'in', |
| 145 | - 'value' => array( 'all' ), | |
| 257 | + 'value' => array( 'all', 'tags', 'brands' ), | |
| 146 | 258 | ), |
| 147 | 259 | array( |
| 148 | - 'field' => 'exclusion_enabled', | |
| 260 | + 'field' => 'exclude_categories_toggle', | |
| 149 | 261 | 'operator' => '===', |
| 150 | 262 | 'value' => true, |
| 151 | 263 | ), |
| 152 | 264 | ), |
| @@ -153,16 +265,76 @@ | ||
| 153 | 265 | ), |
| 154 | 266 | ), |
| 155 | 267 | |
| 156 | 268 | array( |
| 269 | + 'id' => 'include_subcategories', | |
| 270 | + 'type' => 'switcher', | |
| 271 | + 'title' => esc_html__( 'Include subcategories', 'merchant' ), | |
| 272 | + 'desc' => esc_html__( 'When enabled, selecting a parent category also applies to all of its child categories.', 'merchant' ), | |
| 273 | + 'default' => 0, | |
| 274 | + 'conditions' => array( | |
| 275 | + 'relation' => 'OR', | |
| 276 | + 'terms' => array( | |
| 277 | + array( | |
| 278 | + 'field' => 'trigger_on', | |
| 279 | + 'operator' => '===', | |
| 280 | + 'value' => 'category', | |
| 281 | + ), | |
| 282 | + array( | |
| 283 | + 'field' => 'exclude_categories_toggle', | |
| 284 | + 'operator' => '===', | |
| 285 | + 'value' => true, | |
| 286 | + ), | |
| 287 | + ), | |
| 288 | + ), | |
| 289 | + 'ai_meta' => array( | |
| 290 | + 'semantic_group' => 'product_targeting', | |
| 291 | + '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.', | |
| 292 | + ), | |
| 293 | + ), | |
| 294 | + | |
| 295 | + array( | |
| 296 | + 'id' => 'exclude_tags_toggle', | |
| 297 | + 'type' => 'switcher', | |
| 298 | + 'title' => esc_html__( 'Exclude tags', 'merchant' ), | |
| 299 | + 'desc' => esc_html__( 'Exclude specific tags from this pre-order campaign.', 'merchant' ), | |
| 300 | + 'default' => 0, | |
| 301 | + 'conditions' => array( | |
| 302 | + 'relation' => 'AND', | |
| 303 | + 'terms' => array( | |
| 304 | + array( | |
| 305 | + 'field' => 'trigger_on', | |
| 306 | + 'operator' => 'in', | |
| 307 | + 'value' => array( 'all', 'category', 'brands' ), | |
| 308 | + ), | |
| 309 | + ), | |
| 310 | + ), | |
| 311 | + 'ai_meta' => array( | |
| 312 | + 'toggle_for' => 'excluded_tags', | |
| 313 | + 'semantic_group' => 'product_exclusion', | |
| 314 | + 'usage_hint' => 'Enable this to reveal the excluded_tags field.', | |
| 315 | + ), | |
| 316 | + ), | |
| 317 | + | |
| 318 | + array( | |
| 157 | 319 | 'id' => 'excluded_tags', |
| 158 | 320 | 'type' => 'select_ajax', |
| 159 | - 'title' => esc_html__( 'Exclude Tags', 'merchant' ), | |
| 321 | + 'title' => esc_html__( 'Excluded Tags List', 'merchant' ), | |
| 160 | 322 | 'source' => 'options', |
| 161 | 323 | 'multiple' => true, |
| 162 | 324 | 'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 163 | 325 | 'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 164 | - 'desc' => esc_html__( 'Exclude tags from this campaign.', 'merchant' ), | |
| 326 | + 'desc' => esc_html__( 'Exclude tags from this pre-order campaign.', 'merchant' ), | |
| 327 | + 'ai_meta' => array( | |
| 328 | + 'entity' => 'tag', | |
| 329 | + 'reference_type' => 'dynamic', | |
| 330 | + 'taxonomy' => 'product_tag', | |
| 331 | + 'value_format' => 'slug', | |
| 332 | + 'semantic_group' => 'product_exclusion', | |
| 333 | + 'abstraction_level' => 2, | |
| 334 | + 'toggled_by' => 'exclude_tags_toggle', | |
| 335 | + 'usage_hint' => 'Tags excluded from this pre-order campaign. Requires exclude_tags_toggle.', | |
| 336 | + ), | |
| 165 | 337 | 'conditions' => array( |
| 166 | 338 | 'relation' => 'AND', |
| 167 | 339 | 'terms' => array( |
| 168 | 340 | array( |
| @@ -167,12 +339,12 @@ | ||
| 167 | 339 | 'terms' => array( |
| 168 | 340 | array( |
| 169 | 341 | 'field' => 'trigger_on', |
| 170 | 342 | 'operator' => 'in', |
| 171 | - 'value' => array( 'all' ), | |
| 343 | + 'value' => array( 'all', 'category', 'brands' ), | |
| 172 | 344 | ), |
| 173 | 345 | array( |
| 174 | - 'field' => 'exclusion_enabled', | |
| 346 | + 'field' => 'exclude_tags_toggle', | |
| 175 | 347 | 'operator' => '===', |
| 176 | 348 | 'value' => true, |
| 177 | 349 | ), |
| 178 | 350 | ), |
| @@ -179,12 +351,76 @@ | ||
| 179 | 351 | ), |
| 180 | 352 | ), |
| 181 | 353 | |
| 182 | 354 | array( |
| 355 | + 'id' => 'exclude_brands_toggle', | |
| 356 | + 'type' => 'switcher', | |
| 357 | + 'title' => esc_html__( 'Exclude brands', 'merchant' ), | |
| 358 | + 'desc' => esc_html__( 'Exclude specific brands from this pre-order campaign.', 'merchant' ), | |
| 359 | + 'default' => 0, | |
| 360 | + 'conditions' => array( | |
| 361 | + 'relation' => 'AND', | |
| 362 | + 'terms' => array( | |
| 363 | + array( | |
| 364 | + 'field' => 'trigger_on', | |
| 365 | + 'operator' => 'in', | |
| 366 | + 'value' => array( 'all', 'category', 'tags' ), | |
| 367 | + ), | |
| 368 | + ), | |
| 369 | + ), | |
| 370 | + 'ai_meta' => array( | |
| 371 | + 'toggle_for' => 'excluded_brands', | |
| 372 | + 'semantic_group' => 'product_exclusion', | |
| 373 | + 'usage_hint' => 'Enable this to reveal the excluded_brands field.', | |
| 374 | + ), | |
| 375 | + ), | |
| 376 | + | |
| 377 | + array( | |
| 378 | + 'id' => 'excluded_brands', | |
| 379 | + 'type' => 'select_ajax', | |
| 380 | + 'title' => esc_html__( 'Excluded Brands List', 'merchant' ), | |
| 381 | + 'source' => 'options', | |
| 382 | + 'multiple' => true, | |
| 383 | + 'options' => Merchant_Admin_Options::get_brand_select2_choices(), | |
| 384 | + 'placeholder' => esc_html__( 'Select brands', 'merchant' ), | |
| 385 | + 'desc' => esc_html__( 'Exclude brands from this pre-order campaign.', 'merchant' ), | |
| 386 | + 'ai_meta' => array( | |
| 387 | + 'entity' => 'brand', | |
| 388 | + 'reference_type' => 'dynamic', | |
| 389 | + 'taxonomy' => 'product_brand', | |
| 390 | + 'value_format' => 'slug', | |
| 391 | + 'semantic_group' => 'product_exclusion', | |
| 392 | + 'abstraction_level' => 4, | |
| 393 | + 'toggled_by' => 'exclude_brands_toggle', | |
| 394 | + 'usage_hint' => 'Brands excluded from this pre-order campaign. Requires exclude_brands_toggle.', | |
| 395 | + ), | |
| 396 | + 'conditions' => array( | |
| 397 | + 'relation' => 'AND', | |
| 398 | + 'terms' => array( | |
| 399 | + array( | |
| 400 | + 'field' => 'trigger_on', | |
| 401 | + 'operator' => 'in', | |
| 402 | + 'value' => array( 'all', 'category', 'tags' ), | |
| 403 | + ), | |
| 404 | + array( | |
| 405 | + 'field' => 'exclude_brands_toggle', | |
| 406 | + 'operator' => '===', | |
| 407 | + 'value' => true, | |
| 408 | + ), | |
| 409 | + ), | |
| 410 | + ), | |
| 411 | + ), | |
| 412 | + | |
| 413 | + array( | |
| 183 | 414 | 'id' => 'discount_toggle', |
| 184 | 415 | 'type' => 'switcher', |
| 185 | 416 | 'title' => __( 'Do you want to offer a discount on this pre-order?', 'merchant' ), |
| 186 | 417 | 'default' => 0, |
| 418 | + 'ai_meta' => array( | |
| 419 | + 'toggle_for' => 'discount_type', | |
| 420 | + 'semantic_group' => 'offer_rules', | |
| 421 | + 'usage_hint' => 'Enable this to reveal discount_type and discount_amount fields for this pre-order.', | |
| 422 | + ), | |
| 187 | 423 | ), |
| 188 | 424 | array( |
| 189 | 425 | 'id' => 'discount_type', |
| 190 | 426 | 'type' => 'radio', |
| @@ -193,8 +429,12 @@ | ||
| 193 | 429 | 'percentage' => esc_html__( 'Percentage', 'merchant' ), |
| 194 | 430 | 'fixed' => esc_html__( 'Fixed', 'merchant' ), |
| 195 | 431 | ), |
| 196 | 432 | 'default' => 'percentage', |
| 433 | + 'ai_meta' => array( | |
| 434 | + 'semantic_group' => 'offer_rules', | |
| 435 | + 'usage_hint' => 'Type of discount applied to this pre-order. Only relevant when discount_toggle is enabled.', | |
| 436 | + ), | |
| 197 | 437 | 'conditions' => array( |
| 198 | 438 | 'terms' => array( |
| 199 | 439 | array( |
| 200 | 440 | 'field' => 'discount_toggle', // field ID |
| @@ -208,8 +448,12 @@ | ||
| 208 | 448 | 'id' => 'discount_amount', |
| 209 | 449 | 'type' => 'number', |
| 210 | 450 | 'step' => 0.01, |
| 211 | 451 | 'default' => 10, |
| 452 | + 'ai_meta' => array( | |
| 453 | + 'semantic_group' => 'offer_rules', | |
| 454 | + 'usage_hint' => 'Discount amount for this pre-order. Interpretation depends on discount_type (percentage or fixed). Only relevant when discount_toggle is enabled.', | |
| 455 | + ), | |
| 212 | 456 | 'conditions' => array( |
| 213 | 457 | 'terms' => array( |
| 214 | 458 | array( |
| 215 | 459 | 'field' => 'discount_toggle', // field ID |
| @@ -230,8 +474,13 @@ | ||
| 230 | 474 | 'merchant' ), |
| 231 | 475 | '<strong>' . wp_timezone_string() . '</strong>', |
| 232 | 476 | '<a href="' . esc_url( admin_url( 'options-general.php' ) ) . '" target="_blank">' . esc_html__( 'WordPress Settings', 'merchant' ) . '</a>' |
| 233 | 477 | ), |
| 478 | + 'ai_meta' => array( | |
| 479 | + 'allow_empty' => false, | |
| 480 | + 'value_format' => 'm-d-Y h:i A', | |
| 481 | + 'usage_hint' => 'Required. Shipping date in m-d-Y h:i A format (e.g., 06-24-2026 03:30 PM). Uses WordPress timezone.', | |
| 482 | + ), | |
| 234 | 483 | ), |
| 235 | 484 | array( |
| 236 | 485 | 'id' => 'pre_order_start', |
| 237 | 486 | 'type' => 'date_time', |
| @@ -237,8 +486,13 @@ | ||
| 237 | 486 | 'type' => 'date_time', |
| 238 | 487 | 'title' => esc_html__( 'Pre-order starts at', 'merchant' ), |
| 239 | 488 | 'placeholder' => esc_html__( 'mm/dd/yy, --:-- --', 'merchant' ), |
| 240 | 489 | 'desc' => esc_html__( 'If you want your pre-order settings to take effect immediately, leave the pre-order start empty.', 'merchant' ), |
| 490 | + 'ai_meta' => array( | |
| 491 | + 'allow_empty' => true, | |
| 492 | + 'value_format' => 'm-d-Y h:i A', | |
| 493 | + 'usage_hint' => 'Optional. Leave empty to start immediately. Format: m-d-Y h:i A (e.g., 06-24-2026 03:30 PM).', | |
| 494 | + ), | |
| 241 | 495 | ), |
| 242 | 496 | array( |
| 243 | 497 | 'id' => 'pre_order_end', |
| 244 | 498 | 'type' => 'date_time', |
| @@ -250,8 +504,13 @@ | ||
| 250 | 504 | 'merchant' ), |
| 251 | 505 | '<strong>' . wp_timezone_string() . '</strong>', |
| 252 | 506 | '<a href="' . esc_url( admin_url( 'options-general.php' ) ) . '" target="_blank">' . esc_html__( 'WordPress Settings', 'merchant' ) . '</a>' |
| 253 | 507 | ), |
| 508 | + 'ai_meta' => array( | |
| 509 | + 'allow_empty' => true, | |
| 510 | + 'value_format' => 'm-d-Y h:i A', | |
| 511 | + 'usage_hint' => 'Optional. Leave empty for no end date. Format: m-d-Y h:i A (e.g., 06-24-2026 03:30 PM).', | |
| 512 | + ), | |
| 254 | 513 | ), |
| 255 | 514 | |
| 256 | 515 | array( |
| 257 | 516 | 'id' => 'user_condition', |
| @@ -262,8 +521,12 @@ | ||
| 262 | 521 | 'customers' => esc_html__( 'Selected Users', 'merchant' ), |
| 263 | 522 | 'roles' => esc_html__( 'Selected Roles', 'merchant' ), |
| 264 | 523 | ), |
| 265 | 524 | 'default' => 'all', |
| 525 | + 'ai_meta' => array( | |
| 526 | + 'semantic_group' => 'user_targeting', | |
| 527 | + 'usage_hint' => 'Controls which users see this pre-order campaign. Set this BEFORE setting user_condition_users or user_condition_roles.', | |
| 528 | + ), | |
| 266 | 529 | ), |
| 267 | 530 | |
| 268 | 531 | array( |
| 269 | 532 | 'id' => 'user_condition_roles', |
| @@ -274,8 +537,16 @@ | ||
| 274 | 537 | 'multiple' => true, |
| 275 | 538 | 'classes' => array( 'flex-grow' ), |
| 276 | 539 | 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), |
| 277 | 540 | 'condition' => array( 'user_condition', '==', 'roles' ), |
| 541 | + 'ai_meta' => array( | |
| 542 | + 'entity' => 'role', | |
| 543 | + 'reference_type' => 'dynamic', | |
| 544 | + 'value_format' => 'role_slug', | |
| 545 | + 'semantic_group' => 'user_targeting', | |
| 546 | + 'abstraction_level' => 2, | |
| 547 | + 'usage_hint' => 'Roles allowed for this pre-order campaign. Only used when user_condition is roles.', | |
| 548 | + ), | |
| 278 | 549 | ), |
| 279 | 550 | |
| 280 | 551 | array( |
| 281 | 552 | 'id' => 'user_condition_users', |
| @@ -285,10 +556,111 @@ | ||
| 285 | 556 | 'source' => 'user', |
| 286 | 557 | 'multiple' => true, |
| 287 | 558 | 'classes' => array( 'flex-grow' ), |
| 288 | 559 | 'condition' => array( 'user_condition', '==', 'customers' ), |
| 560 | + 'ai_meta' => array( | |
| 561 | + 'entity' => 'user', | |
| 562 | + 'reference_type' => 'static', | |
| 563 | + 'value_format' => 'user_id', | |
| 564 | + 'semantic_group' => 'user_targeting', | |
| 565 | + 'abstraction_level' => 1, | |
| 566 | + 'usage_hint' => 'Specific users for this pre-order campaign. Only used when user_condition is customers.', | |
| 567 | + ), | |
| 289 | 568 | ), |
| 569 | + | |
| 290 | 570 | array( |
| 571 | + 'id' => 'user_exclusion_enabled', | |
| 572 | + 'type' => 'switcher', | |
| 573 | + 'title' => esc_html__( 'Exclusion List', 'merchant' ), | |
| 574 | + 'desc' => esc_html__( 'Select the users that will not show the offer.', 'merchant' ), | |
| 575 | + 'default' => 0, | |
| 576 | + 'conditions' => array( | |
| 577 | + 'relation' => 'AND', | |
| 578 | + 'terms' => array( | |
| 579 | + array( | |
| 580 | + 'field' => 'user_condition', | |
| 581 | + 'operator' => 'in', | |
| 582 | + 'value' => array( 'all', 'roles' ), | |
| 583 | + ), | |
| 584 | + ), | |
| 585 | + ), | |
| 586 | + 'ai_meta' => array( | |
| 587 | + 'toggle_for' => 'exclude_roles', | |
| 588 | + 'semantic_group' => 'user_exclusion', | |
| 589 | + 'usage_hint' => 'Enable this to reveal exclude_roles and exclude_users fields.', | |
| 590 | + ), | |
| 591 | + ), | |
| 592 | + | |
| 593 | + array( | |
| 594 | + 'id' => 'exclude_roles', | |
| 595 | + 'type' => 'select_ajax', | |
| 596 | + 'title' => esc_html__( 'Exclude Roles', 'merchant' ), | |
| 597 | + 'desc' => esc_html__( 'This will exclude the offer for users with these roles.', 'merchant' ), | |
| 598 | + 'source' => 'options', | |
| 599 | + 'multiple' => true, | |
| 600 | + 'classes' => array( 'flex-grow' ), | |
| 601 | + 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), | |
| 602 | + 'ai_meta' => array( | |
| 603 | + 'entity' => 'role', | |
| 604 | + 'reference_type' => 'dynamic', | |
| 605 | + 'value_format' => 'role_slug', | |
| 606 | + 'semantic_group' => 'user_exclusion', | |
| 607 | + 'abstraction_level' => 2, | |
| 608 | + 'toggled_by' => 'user_exclusion_enabled', | |
| 609 | + 'usage_hint' => 'Roles excluded from this pre-order campaign. Requires user_exclusion_enabled.', | |
| 610 | + ), | |
| 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 | + ), | |
| 627 | + | |
| 628 | + array( | |
| 629 | + 'id' => 'exclude_users', | |
| 630 | + 'type' => 'select_ajax', | |
| 631 | + 'title' => esc_html__( 'Exclude Users', 'merchant' ), | |
| 632 | + 'desc' => esc_html__( 'This will exclude the offer for the selected customers.', 'merchant' ), | |
| 633 | + 'source' => 'user', | |
| 634 | + 'multiple' => true, | |
| 635 | + 'classes' => array( 'flex-grow' ), | |
| 636 | + 'ai_meta' => array( | |
| 637 | + 'entity' => 'user', | |
| 638 | + 'reference_type' => 'static', | |
| 639 | + 'value_format' => 'user_id', | |
| 640 | + 'semantic_group' => 'user_exclusion', | |
| 641 | + 'abstraction_level' => 1, | |
| 642 | + 'toggled_by' => 'user_exclusion_enabled', | |
| 643 | + 'usage_hint' => 'Users excluded from this pre-order campaign. Requires user_exclusion_enabled.', | |
| 644 | + ), | |
| 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 | + ), | |
| 661 | + | |
| 662 | + array( | |
| 291 | 663 | 'id' => 'button_text', |
| 292 | 664 | 'type' => 'text', |
| 293 | 665 | 'title' => esc_html__( 'Button text', 'merchant' ), |
| 294 | 666 | 'default' => esc_html__( 'Pre-Order', 'merchant' ), |
| @@ -345,8 +717,28 @@ | ||
| 345 | 717 | 'default' => '#414141', |
| 346 | 718 | ), |
| 347 | 719 | |
| 348 | 720 | array( |
| 721 | + 'id' => 'border-width', | |
| 722 | + 'type' => 'range', | |
| 723 | + 'title' => esc_html__( 'Button Border Width (px)', 'merchant' ), | |
| 724 | + 'min' => 0, | |
| 725 | + 'max' => 10, | |
| 726 | + 'step' => 1, | |
| 727 | + 'default' => 0, | |
| 728 | + ), | |
| 729 | + | |
| 730 | + array( | |
| 731 | + 'id' => 'border-radius', | |
| 732 | + 'type' => 'range', | |
| 733 | + 'title' => esc_html__( 'Button Border Radius (px)', 'merchant' ), | |
| 734 | + 'min' => 0, | |
| 735 | + 'max' => 50, | |
| 736 | + 'step' => 1, | |
| 737 | + 'default' => 0, | |
| 738 | + ), | |
| 739 | + | |
| 740 | + array( | |
| 349 | 741 | 'id' => 'background-color', |
| 350 | 742 | 'type' => 'color', |
| 351 | 743 | 'title' => esc_html__( 'Button background color', 'merchant' ), |
| 352 | 744 | 'default' => '#212121', |
| @@ -435,6 +827,6 @@ | ||
| 435 | 827 | ), |
| 436 | 828 | ), |
| 437 | 829 | ), |
| 438 | 830 | ), |
| 439 | - ) | |
| 440 | -); | |
| 831 | + ), | |
| 832 | +); | |