| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Spending Goal — 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 |
// Settings |
| 17 |
|
| 18 |
return array( |
| 19 |
array( |
| 20 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 21 |
'module' => Merchant_Spending_Goal::MODULE_ID, |
| 22 |
'fields' => array( |
| 23 |
|
| 24 |
array( |
| 25 |
'id' => 'spending_goal', |
| 26 |
'type' => 'number', |
| 27 |
'title' => esc_html__( 'Spending goal', 'merchant' ), |
| 28 |
'step' => 0.01, |
| 29 |
'default' => 150, |
| 30 |
'ai_meta' => array( |
| 31 |
'semantic_group' => 'offer_rules', |
| 32 |
'usage_hint' => 'The cart total threshold the customer must reach to unlock the spending goal discount.', |
| 33 |
), |
| 34 |
), |
| 35 |
|
| 36 |
array( |
| 37 |
'id' => 'total_type', |
| 38 |
'type' => 'select', |
| 39 |
'title' => esc_html__( 'Based on', 'merchant' ), |
| 40 |
'desc' => esc_html__( 'Choose the basis for the spending goal. “Cart Subtotal” excludes additional calculated discounts, whereas “Cart Total” includes them.', 'merchant' ), |
| 41 |
'options' => array( |
| 42 |
'subtotal' => esc_html__( 'Cart subtotal', 'merchant' ), |
| 43 |
'total' => esc_html__( 'Cart total', 'merchant' ), |
| 44 |
), |
| 45 |
'default' => 'subtotal', |
| 46 |
'ai_meta' => array( |
| 47 |
'semantic_group' => 'offer_rules', |
| 48 |
'usage_hint' => 'Determines whether the spending_goal threshold is compared against the cart subtotal (pre-discount) or cart total (post-discount).', |
| 49 |
), |
| 50 |
), |
| 51 |
|
| 52 |
array( |
| 53 |
'id' => 'discount_type', |
| 54 |
'type' => 'select', |
| 55 |
'title' => esc_html__( 'Discount type', 'merchant' ), |
| 56 |
'options' => array( |
| 57 |
'percent' => esc_html__( 'Percent', 'merchant' ), |
| 58 |
'fixed' => esc_html__( 'Fixed amount', 'merchant' ), |
| 59 |
), |
| 60 |
'default' => 'percent', |
| 61 |
'ai_meta' => array( |
| 62 |
'semantic_group' => 'offer_rules', |
| 63 |
'usage_hint' => 'Type of discount granted when the spending goal is reached. percent = percentage off cart total; fixed = fixed amount off.', |
| 64 |
), |
| 65 |
), |
| 66 |
|
| 67 |
array( |
| 68 |
'id' => 'discount_amount', |
| 69 |
'type' => 'number', |
| 70 |
'title' => esc_html__( 'Discount amount', 'merchant' ), |
| 71 |
'step' => 0.01, |
| 72 |
'default' => 10, |
| 73 |
'ai_meta' => array( |
| 74 |
'semantic_group' => 'offer_rules', |
| 75 |
'usage_hint' => 'Amount of the discount applied when the spending goal is reached. Interpretation depends on discount_type.', |
| 76 |
), |
| 77 |
), |
| 78 |
|
| 79 |
array( |
| 80 |
'id' => 'discount_name', |
| 81 |
'type' => 'text', |
| 82 |
'title' => esc_html__( 'Discount name', 'merchant' ), |
| 83 |
'default' => esc_html__( 'Spending goal', 'merchant' ), |
| 84 |
'desc' => esc_html__( 'This will be the name of the applied discount on the cart page.', 'merchant' ), |
| 85 |
), |
| 86 |
|
| 87 |
array( |
| 88 |
'id' => 'inclusion', |
| 89 |
'type' => 'switcher', |
| 90 |
'title' => esc_html__( 'Product Inclusion', 'merchant' ), |
| 91 |
'desc' => esc_html__( 'Include only certain products or categories', 'merchant' ), |
| 92 |
'default' => 0, |
| 93 |
'ai_meta' => array( |
| 94 |
'toggle_for' => 'included_products', |
| 95 |
'semantic_group' => 'product_targeting', |
| 96 |
'usage_hint' => 'Enable this to count only specific products or categories toward the spending goal. Reveals included_products and included_categories.', |
| 97 |
), |
| 98 |
), |
| 99 |
|
| 100 |
array( |
| 101 |
'id' => 'included_products', |
| 102 |
'type' => 'products_selector', |
| 103 |
'title' => esc_html__( 'Include Products', 'merchant' ), |
| 104 |
'multiple' => true, |
| 105 |
'conditions' => array( |
| 106 |
'relation' => 'AND', |
| 107 |
'terms' => array( |
| 108 |
array( |
| 109 |
'field' => 'inclusion', |
| 110 |
'operator' => '===', |
| 111 |
'value' => true, |
| 112 |
), |
| 113 |
), |
| 114 |
), |
| 115 |
'ai_meta' => array( |
| 116 |
'entity' => 'product', |
| 117 |
'reference_type' => 'static', |
| 118 |
'value_format' => 'product_id', |
| 119 |
'semantic_group' => 'product_targeting', |
| 120 |
'abstraction_level' => 1, |
| 121 |
'toggled_by' => 'inclusion', |
| 122 |
'usage_hint' => 'Products counted toward the spending goal. Requires inclusion to be enabled.', |
| 123 |
), |
| 124 |
), |
| 125 |
|
| 126 |
array( |
| 127 |
'id' => 'included_categories', |
| 128 |
'type' => 'select_ajax', |
| 129 |
'title' => esc_html__( 'Include Categories', 'merchant' ), |
| 130 |
'source' => 'options', |
| 131 |
'multiple' => true, |
| 132 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 133 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 134 |
'conditions' => array( |
| 135 |
'relation' => 'AND', |
| 136 |
'terms' => array( |
| 137 |
array( |
| 138 |
'field' => 'inclusion', |
| 139 |
'operator' => '===', |
| 140 |
'value' => true, |
| 141 |
), |
| 142 |
), |
| 143 |
), |
| 144 |
'ai_meta' => array( |
| 145 |
'entity' => 'category', |
| 146 |
'reference_type' => 'dynamic', |
| 147 |
'taxonomy' => 'product_cat', |
| 148 |
'value_format' => 'slug', |
| 149 |
'semantic_group' => 'product_targeting', |
| 150 |
'abstraction_level' => 3, |
| 151 |
'toggled_by' => 'inclusion', |
| 152 |
'usage_hint' => 'Categories counted toward the spending goal. Requires inclusion to be enabled.', |
| 153 |
), |
| 154 |
), |
| 155 |
|
| 156 |
array( |
| 157 |
'id' => 'exclusion', |
| 158 |
'type' => 'switcher', |
| 159 |
'title' => esc_html__( 'Product Exclusion', 'merchant' ), |
| 160 |
'desc' => esc_html__( 'Exclude certain products or categories', 'merchant' ), |
| 161 |
'default' => 0, |
| 162 |
'ai_meta' => array( |
| 163 |
'toggle_for' => 'excluded_products', |
| 164 |
'semantic_group' => 'product_exclusion', |
| 165 |
'usage_hint' => 'Enable this to exclude specific products or categories from counting toward the spending goal. Reveals excluded_products and excluded_categories.', |
| 166 |
), |
| 167 |
), |
| 168 |
|
| 169 |
array( |
| 170 |
'id' => 'excluded_products', |
| 171 |
'type' => 'products_selector', |
| 172 |
'title' => esc_html__( 'Exclude Products', 'merchant' ), |
| 173 |
'multiple' => true, |
| 174 |
'conditions' => array( |
| 175 |
'relation' => 'AND', |
| 176 |
'terms' => array( |
| 177 |
array( |
| 178 |
'field' => 'exclusion', |
| 179 |
'operator' => '===', |
| 180 |
'value' => true, |
| 181 |
), |
| 182 |
), |
| 183 |
), |
| 184 |
'ai_meta' => array( |
| 185 |
'entity' => 'product', |
| 186 |
'reference_type' => 'static', |
| 187 |
'value_format' => 'product_id', |
| 188 |
'semantic_group' => 'product_exclusion', |
| 189 |
'abstraction_level' => 1, |
| 190 |
'toggled_by' => 'exclusion', |
| 191 |
'usage_hint' => 'Products excluded from counting toward the spending goal. Requires exclusion to be enabled.', |
| 192 |
), |
| 193 |
), |
| 194 |
|
| 195 |
array( |
| 196 |
'id' => 'excluded_categories', |
| 197 |
'type' => 'select_ajax', |
| 198 |
'title' => esc_html__( 'Exclude Categories', 'merchant' ), |
| 199 |
'source' => 'options', |
| 200 |
'multiple' => true, |
| 201 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 202 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 203 |
'conditions' => array( |
| 204 |
'relation' => 'AND', |
| 205 |
'terms' => array( |
| 206 |
array( |
| 207 |
'field' => 'exclusion', |
| 208 |
'operator' => '===', |
| 209 |
'value' => true, |
| 210 |
), |
| 211 |
), |
| 212 |
), |
| 213 |
'ai_meta' => array( |
| 214 |
'entity' => 'category', |
| 215 |
'reference_type' => 'dynamic', |
| 216 |
'taxonomy' => 'product_cat', |
| 217 |
'value_format' => 'slug', |
| 218 |
'semantic_group' => 'product_exclusion', |
| 219 |
'abstraction_level' => 3, |
| 220 |
'toggled_by' => 'exclusion', |
| 221 |
'usage_hint' => 'Categories excluded from counting toward the spending goal. Requires exclusion to be enabled.', |
| 222 |
), |
| 223 |
), |
| 224 |
|
| 225 |
array( |
| 226 |
'id' => 'include_subcategories', |
| 227 |
'type' => 'switcher', |
| 228 |
'title' => esc_html__( 'Include subcategories', 'merchant' ), |
| 229 |
'desc' => esc_html__( 'When enabled, selecting a parent category also applies to all of its child categories.', 'merchant' ), |
| 230 |
'default' => 0, |
| 231 |
'conditions' => array( |
| 232 |
'relation' => 'OR', |
| 233 |
'terms' => array( |
| 234 |
array( |
| 235 |
'field' => 'inclusion', |
| 236 |
'operator' => '===', |
| 237 |
'value' => true, |
| 238 |
), |
| 239 |
array( |
| 240 |
'field' => 'exclusion', |
| 241 |
'operator' => '===', |
| 242 |
'value' => true, |
| 243 |
), |
| 244 |
), |
| 245 |
), |
| 246 |
'ai_meta' => array( |
| 247 |
'semantic_group' => 'product_targeting', |
| 248 |
'usage_hint' => 'Enable so selected parent categories also cover their child categories, for both the include list and the exclude list. Off by default, which matches only the exact categories chosen.', |
| 249 |
), |
| 250 |
), |
| 251 |
|
| 252 |
array( |
| 253 |
'id' => 'user_condition', |
| 254 |
'type' => 'select', |
| 255 |
'title' => esc_html__( 'User Condition', 'merchant' ), |
| 256 |
'options' => array( |
| 257 |
'all' => esc_html__( 'All Users', 'merchant' ), |
| 258 |
'customers' => esc_html__( 'Selected Users', 'merchant' ), |
| 259 |
'roles' => esc_html__( 'Selected Roles', 'merchant' ), |
| 260 |
), |
| 261 |
'default' => 'all', |
| 262 |
'ai_meta' => array( |
| 263 |
'semantic_group' => 'user_targeting', |
| 264 |
'usage_hint' => 'Controls which users are eligible for this spending goal discount. Set this BEFORE setting user_condition_users or user_condition_roles.', |
| 265 |
), |
| 266 |
), |
| 267 |
|
| 268 |
array( |
| 269 |
'id' => 'user_condition_roles', |
| 270 |
'type' => 'select_ajax', |
| 271 |
'title' => esc_html__( 'User Roles', 'merchant' ), |
| 272 |
'desc' => esc_html__( 'This will limit the offer to users with these roles.', 'merchant' ), |
| 273 |
'source' => 'options', |
| 274 |
'multiple' => true, |
| 275 |
'classes' => array( 'flex-grow' ), |
| 276 |
'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), |
| 277 |
'condition' => array( 'user_condition', '==', 'roles' ), |
| 278 |
'ai_meta' => array( |
| 279 |
'entity' => 'role', |
| 280 |
'reference_type' => 'dynamic', |
| 281 |
'value_format' => 'role_slug', |
| 282 |
'semantic_group' => 'user_targeting', |
| 283 |
'abstraction_level' => 2, |
| 284 |
'usage_hint' => 'Roles eligible for the spending goal discount. Only used when user_condition is roles.', |
| 285 |
), |
| 286 |
), |
| 287 |
|
| 288 |
array( |
| 289 |
'id' => 'user_condition_users', |
| 290 |
'type' => 'select_ajax', |
| 291 |
'title' => esc_html__( 'Users', 'merchant' ), |
| 292 |
'desc' => esc_html__( 'This will limit the offer to the selected customers.', 'merchant' ), |
| 293 |
'source' => 'user', |
| 294 |
'multiple' => true, |
| 295 |
'classes' => array( 'flex-grow' ), |
| 296 |
'condition' => array( 'user_condition', '==', 'customers' ), |
| 297 |
'ai_meta' => array( |
| 298 |
'entity' => 'user', |
| 299 |
'reference_type' => 'static', |
| 300 |
'value_format' => 'user_id', |
| 301 |
'semantic_group' => 'user_targeting', |
| 302 |
'abstraction_level' => 1, |
| 303 |
'usage_hint' => 'Specific users eligible for the spending goal discount. Only used when user_condition is customers.', |
| 304 |
), |
| 305 |
), |
| 306 |
|
| 307 |
array( |
| 308 |
'id' => 'user_exclusion_enabled', |
| 309 |
'type' => 'switcher', |
| 310 |
'title' => esc_html__( 'Exclusion List', 'merchant' ), |
| 311 |
'desc' => esc_html__( 'Choose the users who will not see this offer.', 'merchant' ), |
| 312 |
'default' => 0, |
| 313 |
'conditions' => array( |
| 314 |
'relation' => 'AND', |
| 315 |
'terms' => array( |
| 316 |
array( |
| 317 |
'field' => 'user_condition', |
| 318 |
'operator' => 'in', |
| 319 |
'value' => array( 'all', 'roles' ), |
| 320 |
), |
| 321 |
), |
| 322 |
), |
| 323 |
'ai_meta' => array( |
| 324 |
'toggle_for' => 'exclude_roles', |
| 325 |
'semantic_group' => 'user_exclusion', |
| 326 |
'usage_hint' => 'Enable this to reveal exclude_users and exclude_roles fields.', |
| 327 |
), |
| 328 |
), |
| 329 |
|
| 330 |
array( |
| 331 |
'id' => 'exclude_users', |
| 332 |
'type' => 'select_ajax', |
| 333 |
'title' => esc_html__( 'Exclude Users', 'merchant' ), |
| 334 |
'desc' => esc_html__( 'This will exclude the offer for the selected customers.', 'merchant' ), |
| 335 |
'source' => 'user', |
| 336 |
'multiple' => true, |
| 337 |
'classes' => array( 'flex-grow' ), |
| 338 |
'conditions' => array( |
| 339 |
'relation' => 'AND', |
| 340 |
'terms' => array( |
| 341 |
array( |
| 342 |
'field' => 'user_condition', |
| 343 |
'operator' => 'in', |
| 344 |
'value' => array( 'all', 'roles' ), |
| 345 |
), |
| 346 |
array( |
| 347 |
'field' => 'user_exclusion_enabled', |
| 348 |
'operator' => '===', |
| 349 |
'value' => true, |
| 350 |
), |
| 351 |
), |
| 352 |
), |
| 353 |
'ai_meta' => array( |
| 354 |
'entity' => 'user', |
| 355 |
'reference_type' => 'static', |
| 356 |
'value_format' => 'user_id', |
| 357 |
'semantic_group' => 'user_exclusion', |
| 358 |
'abstraction_level' => 1, |
| 359 |
'toggled_by' => 'user_exclusion_enabled', |
| 360 |
'usage_hint' => 'Users excluded from the spending goal discount. Requires user_exclusion_enabled.', |
| 361 |
), |
| 362 |
), |
| 363 |
|
| 364 |
array( |
| 365 |
'id' => 'exclude_roles', |
| 366 |
'type' => 'select_ajax', |
| 367 |
'title' => esc_html__( 'Exclude Roles', 'merchant' ), |
| 368 |
'desc' => esc_html__( 'This will exclude the offer for users with these roles.', 'merchant' ), |
| 369 |
'source' => 'options', |
| 370 |
'multiple' => true, |
| 371 |
'classes' => array( 'flex-grow' ), |
| 372 |
'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), |
| 373 |
'conditions' => array( |
| 374 |
'relation' => 'AND', |
| 375 |
'terms' => array( |
| 376 |
array( |
| 377 |
'field' => 'user_condition', |
| 378 |
'operator' => 'in', |
| 379 |
'value' => array( 'all' ), |
| 380 |
), |
| 381 |
array( |
| 382 |
'field' => 'user_exclusion_enabled', |
| 383 |
'operator' => '===', |
| 384 |
'value' => true, |
| 385 |
), |
| 386 |
), |
| 387 |
), |
| 388 |
'ai_meta' => array( |
| 389 |
'entity' => 'role', |
| 390 |
'reference_type' => 'dynamic', |
| 391 |
'value_format' => 'role_slug', |
| 392 |
'semantic_group' => 'user_exclusion', |
| 393 |
'abstraction_level' => 2, |
| 394 |
'toggled_by' => 'user_exclusion_enabled', |
| 395 |
'usage_hint' => 'Roles excluded from the spending goal discount. Requires user_exclusion_enabled.', |
| 396 |
), |
| 397 |
), |
| 398 |
|
| 399 |
array( |
| 400 |
'id' => 'enable_auto_slide_in', |
| 401 |
'type' => 'switcher', |
| 402 |
'title' => esc_html__( 'Enable Auto Slide In', 'merchant' ), |
| 403 |
'desc' => esc_html__( 'This will make the widget slide in each time a product is added to the cart.', 'merchant' ), |
| 404 |
'default' => 1, |
| 405 |
), |
| 406 |
), |
| 407 |
), |
| 408 |
array( |
| 409 |
'title' => esc_html__( 'Text Formatting Settings', 'merchant' ), |
| 410 |
'module' => Merchant_Spending_Goal::MODULE_ID, |
| 411 |
'fields' => array( |
| 412 |
|
| 413 |
array( |
| 414 |
'id' => 'text_goal_zero', |
| 415 |
'type' => 'text', |
| 416 |
'title' => esc_html__( 'When the goal target is at 0%', 'merchant' ), |
| 417 |
'default' => esc_html__( 'Spend {spending_goal} to get a {discount_amount} discount!', 'merchant' ), |
| 418 |
'desc' => esc_html__( 'Default is: Spend {spending_goal} to get a {discount_amount} discount!', 'merchant' ), |
| 419 |
), |
| 420 |
|
| 421 |
array( |
| 422 |
'id' => 'text_goal_started', |
| 423 |
'type' => 'text', |
| 424 |
'title' => esc_html__( 'When the goal target is between 1-99%', 'merchant' ), |
| 425 |
'default' => esc_html__( 'Spend {spending_goal} more to get a {discount_amount} discount!', 'merchant' ), |
| 426 |
'desc' => esc_html__( 'Default is: Spend {spending_goal} more to get a {discount_amount} discount!', 'merchant' ), |
| 427 |
), |
| 428 |
|
| 429 |
array( |
| 430 |
'id' => 'text_goal_reached', |
| 431 |
'type' => 'text', |
| 432 |
'title' => esc_html__( 'When the goal target is at 100%', 'merchant' ), |
| 433 |
'default' => esc_html__( 'Congratulations! You got a discount of {discount_amount} on this order!', 'merchant' ), |
| 434 |
'desc' => esc_html__( 'Default: Congratulations! You got a discount of {discount_amount} on this order!', 'merchant' ), |
| 435 |
), |
| 436 |
), |
| 437 |
), |
| 438 |
array( |
| 439 |
'module' => Merchant_Spending_Goal::MODULE_ID, |
| 440 |
'title' => esc_html__( 'Style', 'merchant' ), |
| 441 |
'fields' => array( |
| 442 |
|
| 443 |
array( |
| 444 |
'id' => 'gradient_start', |
| 445 |
'type' => 'color', |
| 446 |
'title' => esc_html__( 'Gradient start', 'merchant' ), |
| 447 |
'default' => '#5e5e5e', |
| 448 |
), |
| 449 |
|
| 450 |
array( |
| 451 |
'id' => 'gradient_end', |
| 452 |
'type' => 'color', |
| 453 |
'title' => esc_html__( 'Gradient end', 'merchant' ), |
| 454 |
'default' => '#212121', |
| 455 |
), |
| 456 |
|
| 457 |
array( |
| 458 |
'id' => 'progress_bar', |
| 459 |
'type' => 'color', |
| 460 |
'title' => esc_html__( 'Progress bar color', 'merchant' ), |
| 461 |
'default' => '#d83a3b', |
| 462 |
), |
| 463 |
|
| 464 |
array( |
| 465 |
'id' => 'content_width', |
| 466 |
'type' => 'range', |
| 467 |
'title' => esc_html__( 'Content width', 'merchant' ), |
| 468 |
'min' => 0, |
| 469 |
'max' => 600, |
| 470 |
'step' => 1, |
| 471 |
'unit' => 'px', |
| 472 |
'default' => 300, |
| 473 |
), |
| 474 |
|
| 475 |
array( |
| 476 |
'id' => 'content_bg_color', |
| 477 |
'type' => 'color', |
| 478 |
'title' => esc_html__( 'Content background color', 'merchant' ), |
| 479 |
'default' => '#f9f9f9', |
| 480 |
), |
| 481 |
|
| 482 |
array( |
| 483 |
'id' => 'content_text_color', |
| 484 |
'type' => 'color', |
| 485 |
'title' => esc_html__( 'Content text color', 'merchant' ), |
| 486 |
'default' => '#3c434a', |
| 487 |
), |
| 488 |
), |
| 489 |
), |
| 490 |
); |
| 491 |
|