PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.10.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.10.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
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 1.10.2, at inc/modules/volume-discounts/admin/options.php

600 lines 23.7 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 Options.
5 *
6 * @package Merchant
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 Merchant_Admin_Options::create( array(
14 'title' => esc_html__( 'Offers', 'merchant' ),
15 'module' => Merchant_Volume_Discounts::MODULE_ID,
16 'fields' => array(
17 array(
18 'id' => 'offers',
19 'type' => 'flexible_content',
20 'button_label' => esc_html__( 'Add New Offer', 'merchant' ),
21 'style' => Merchant_Volume_Discounts::MODULE_ID . '-style default',
22 'sorting' => true,
23 'accordion' => true,
24 'duplicate' => true,
25 'layouts' => array(
26 'offer-details' => array(
27 'title' => esc_html__( 'Create Discount Tiers', 'merchant' ),
28 'title-field' => 'offer-title', // text field ID to use as title for the layout
29 'fields' => array(
30 array(
31 'id' => 'offer-title',
32 'type' => 'text',
33 'title' => esc_html__( 'Offer name', 'merchant' ),
34 'default' => esc_html__( 'Campaign', 'merchant' ),
35 ),
36 array(
37 'id' => 'rules_to_display',
38 'type' => 'select',
39 'title' => esc_html__( 'Offered product(s)', 'merchant' ),
40 'options' => array(
41 'all' => esc_html__( 'All Products', 'merchant' ),
42 'products' => esc_html__( 'Specific Products', 'merchant' ),
43 'categories' => esc_html__( 'Specific Categories', 'merchant' ),
44 'tags' => esc_html__( 'Specific Tags', 'merchant' ),
45 ),
46 'default' => 'products',
47 ),
48 array(
49 'id' => 'include_all_cart_products',
50 'type' => 'switcher',
51 'title' => esc_html__( 'Include all cart products', 'merchant' ),
52 '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' ),
53 'default' => false,
54 'condition' => array( 'rules_to_display', '==', 'all' ),
55 ),
56 array(
57 'id' => 'product_id',
58 'type' => 'products_selector',
59 //'title' => esc_html__( 'Select product', 'merchant' ),
60 'multiple' => true,
61 'desc' => esc_html__( 'Select the product that the customer will get a discount on when they purchase the minimum required quantity.',
62 'merchant' ),
63 'allowed_types' => array( 'simple', 'variable' ),
64 'condition' => array( 'rules_to_display', '==', 'products' ),
65 ),
66 array(
67 'id' => 'category_slugs',
68 'type' => 'select_ajax',
69 'title' => esc_html__( 'Categories', 'merchant' ),
70 'source' => 'options',
71 'multiple' => true,
72 'options' => Merchant_Admin_Options::get_category_select2_choices(),
73 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
74 'desc' => esc_html__( 'Select the product categories that will show the offer.', 'merchant' ),
75 'condition' => array( 'rules_to_display', '==', 'categories' ),
76 ),
77 array(
78 'id' => 'include_all_category_products',
79 'type' => 'switcher',
80 'title' => esc_html__( 'Include all category products', 'merchant' ),
81 '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' ),
82 'default' => false,
83 'condition' => array( 'rules_to_display', '==', 'categories' ),
84 ),
85 array(
86 'id' => 'include_all_products_info',
87 'type' => 'info',
88 '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.',
89 'merchant' ),
90 'conditions' => array(
91 'relation' => 'OR', // AND/OR, If not provided, only first term will be considered
92 'terms' => array(
93 array(
94 'relation' => 'AND', // AND/OR, If not provided, only first term will be considered
95 'terms' => array(
96 array(
97 'field' => 'rules_to_display', // field ID
98 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
99 'value' => 'categories', // can be a single value or an array of string/number/int
100 ),
101 array(
102 'field' => 'include_all_category_products', // field ID
103 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
104 'value' => true, // can be a single value or an array of string/number/int
105 ),
106 ),
107 ),
108 array(
109 'relation' => 'AND', // AND/OR, If not provided, only first term will be considered
110 'terms' => array(
111 array(
112 'field' => 'rules_to_display', // field ID
113 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
114 'value' => 'all', // can be a single value or an array of string/number/int
115 ),
116 array(
117 'field' => 'include_all_cart_products', // field ID
118 'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains
119 'value' => true, // can be a single value or an array of string/number/int
120 ),
121 ),
122 ),
123 ),
124 ),
125 ),
126 array(
127 'id' => 'tag_slugs',
128 'type' => 'select_ajax',
129 'title' => esc_html__( 'Tags', 'merchant' ),
130 'source' => 'options',
131 'multiple' => true,
132 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
133 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
134 'desc' => esc_html__( 'Select the product tags that will show the offer.', 'merchant' ),
135 'condition' => array( 'rules_to_display', '==', 'tags' ),
136 ),
137 array(
138 'id' => 'excluded_products',
139 'type' => 'products_selector',
140 'title' => esc_html__( 'Exclude Products', 'merchant' ),
141 'multiple' => true,
142 'desc' => esc_html__( 'Exclude products from this campaign.', 'merchant' ),
143 'condition' => array( 'rules_to_display', 'any', 'all|categories|tags' ),
144 ),
145 array(
146 'id' => 'excluded_categories',
147 'type' => 'select_ajax',
148 'title' => esc_html__( 'Exclude Categories', 'merchant' ),
149 'source' => 'options',
150 'multiple' => true,
151 'options' => Merchant_Admin_Options::get_category_select2_choices(),
152 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
153 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ),
154 'condition' => array( 'rules_to_display', '==', 'all' ),
155 ),
156 array(
157 'id' => 'quantity',
158 'type' => 'number',
159 'title' => esc_html__( 'Quantity', 'merchant' ),
160 'default' => 2,
161 ),
162
163 array(
164 'id' => 'discount_type',
165 'type' => 'radio',
166 'title' => esc_html__( 'Discount', 'merchant' ),
167 'options' => array(
168 'percentage_discount' => esc_html__( 'Percentage', 'merchant' ),
169 'fixed_discount' => esc_html__( 'Fixed', 'merchant' ),
170 ),
171 'default' => 'percentage_discount',
172 ),
173 array(
174 'id' => 'discount',
175 'type' => 'number',
176 'step' => 0.01,
177 'default' => 10,
178 ),
179
180 array(
181 'id' => 'exclude_coupon',
182 'type' => 'switcher',
183 'title' => esc_html__( 'Exclude coupons', 'merchant' ),
184 'desc' => esc_html__( 'Coupon codes will not be applicable on top of this offer campaign.', 'merchant' ),
185 'default' => false,
186 ),
187
188 array(
189 'id' => 'user_condition',
190 'type' => 'select',
191 'title' => esc_html__( 'User Condition', 'merchant' ),
192 'options' => array(
193 'all' => esc_html__( 'All Users', 'merchant' ),
194 'customers' => esc_html__( 'Selected Users', 'merchant' ),
195 'roles' => esc_html__( 'Selected Roles', 'merchant' ),
196 ),
197 'default' => 'all',
198 ),
199
200 array(
201 'id' => 'user_condition_roles',
202 'type' => 'select_ajax',
203 'title' => esc_html__( 'User Roles', 'merchant' ),
204 'desc' => esc_html__( 'This will limit the offer to users with these roles.', 'merchant' ),
205 'source' => 'options',
206 'multiple' => true,
207 'classes' => array( 'flex-grow' ),
208 'options' => Merchant_Admin_Options::get_user_roles_select2_choices(),
209 'condition' => array( 'user_condition', '==', 'roles' ),
210 ),
211
212 array(
213 'id' => 'user_condition_users',
214 'type' => 'select_ajax',
215 'title' => esc_html__( 'Users', 'merchant' ),
216 'desc' => esc_html__( 'This will limit the offer to the selected customers.', 'merchant' ),
217 'source' => 'user',
218 'multiple' => true,
219 'classes' => array( 'flex-grow' ),
220 'condition' => array( 'user_condition', '==', 'customers' ),
221 ),
222
223 array(
224 'id' => 'product_single_page',
225 'type' => 'fields_group',
226 'title' => esc_html__( 'Product Single Page', 'merchant' ),
227 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on product pages.', 'merchant' ),
228 'state' => 'open',
229 'accordion' => true,
230 'display_status' => true,
231 'default' => 'active',
232 'fields' => array(
233 array(
234 'id' => 'single_product_placement',
235 'type' => 'radio',
236 'title' => esc_html__( 'Placement on product page', 'merchant' ),
237 'options' => array(
238 'before-cart-form' => esc_html__( 'Before add to cart', 'merchant' ),
239 'after-cart-form' => esc_html__( 'After add to cart', 'merchant' ),
240 ),
241 'default' => 'before-cart-form',
242 ),
243
244 // text formatting
245 array(
246 'id' => 'table_title',
247 'type' => 'text',
248 'title' => esc_html__( 'Offer title', 'merchant' ),
249 'default' => __( 'Buy more, save more!', 'merchant' ),
250 ),
251
252 // `hidden_desc` depends on `desc`
253 array(
254 'id' => 'save_label',
255 'type' => 'text',
256 'title' => esc_html__( 'Save label', 'merchant' ),
257 'default' => esc_html__( 'Save {amount}', 'merchant' ),
258 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
259 'hidden_desc' => sprintf(
260 /* Translators: %1$s: Discount amount, %2$s: Discount percentage */
261 __( '<strong>%1$s:</strong> to show discount amount<br><strong>%2$s:</strong> to show discount percentage', 'merchant' ),
262 '{amount}',
263 '{percent}'
264 ),
265 ),
266
267 array(
268 'id' => 'buy_text',
269 'type' => 'text',
270 'title' => esc_html__( 'Tier format text', 'merchant' ),
271 'default' => esc_html__( 'Buy {quantity}, get {discount} off each', 'merchant' ),
272 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
273 'hidden_desc' => sprintf(
274 /* Translators: %1$s: Discount percentage, %2$s: Quantity, %3$s: Discount amount */
275 __( '<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',
276 'merchant' ),
277 '{percent}',
278 '{quantity}',
279 '{discount}'
280 ),
281 ),
282
283 array(
284 'id' => 'item_text',
285 'type' => 'text',
286 'title' => esc_html__( 'Item text', 'merchant' ),
287 'default' => esc_html__( 'Per item:', 'merchant' ),
288 ),
289
290 array(
291 'id' => 'total_text',
292 'type' => 'text',
293 'title' => esc_html__( 'Total text', 'merchant' ),
294 'default' => esc_html__( 'Total price:', 'merchant' ),
295 ),
296
297 array(
298 'id' => 'cart_title_text',
299 'type' => 'text',
300 'title' => esc_html__( 'Cart item discount title', 'merchant' ),
301 'default' => esc_html__( 'Discount', 'merchant' ),
302 'desc' => esc_html__( 'This is displayed on the cart page.', 'merchant' ),
303 ),
304
305 array(
306 'id' => 'cart_description_text',
307 'type' => 'text',
308 'title' => esc_html__( 'Cart item discount description', 'merchant' ),
309 'default' => esc_html__( 'A discount of {amount} has been applied.', 'merchant' ),
310 'desc' => __( 'This is displayed on the cart page. You can use these codes in the content.', 'merchant' ),
311 'hidden_desc' => sprintf(
312 /* Translators: %1$s: Discount amount, %2$s: Discount percentage */
313 __( '<strong>%1$s:</strong> to show discount amount<br><strong>%2$s:</strong> to show discount percentage', 'merchant' ),
314 '{amount}',
315 '{percent}'
316 ),
317 ),
318
319 // style settings
320 array(
321 'id' => 'title_font_size',
322 'type' => 'range',
323 'title' => esc_html__( 'Title font size', 'merchant' ),
324 'min' => 0,
325 'max' => 100,
326 'step' => 1,
327 'unit' => 'px',
328 'default' => 16,
329 ),
330
331 array(
332 'id' => 'title_font_weight',
333 'type' => 'select',
334 'title' => esc_html__( 'Title font weight', 'merchant' ),
335 'options' => array(
336 'lighter' => esc_html__( 'Light', 'merchant' ),
337 'normal' => esc_html__( 'Normal', 'merchant' ),
338 'bold' => esc_html__( 'Bold', 'merchant' ),
339 ),
340 'default' => 'normal',
341 ),
342
343 array(
344 'id' => 'title_text_color',
345 'type' => 'color',
346 'title' => esc_html__( 'Title text color', 'merchant' ),
347 'default' => '#212121',
348 ),
349
350 array(
351 'id' => 'table_item_bg_color',
352 'type' => 'color',
353 'title' => esc_html__( 'Choose background color', 'merchant' ),
354 'default' => '#fcf0f1',
355 ),
356
357 array(
358 'id' => 'table_item_border_color',
359 'type' => 'color',
360 'title' => esc_html__( 'Choose border color', 'merchant' ),
361 'default' => '#d83b3b',
362 ),
363
364 array(
365 'id' => 'table_item_text_color',
366 'type' => 'color',
367 'title' => esc_html__( 'Choose text color', 'merchant' ),
368 'default' => '#3c434a',
369 ),
370
371 array(
372 'id' => 'table_label_bg_color',
373 'type' => 'color',
374 'title' => esc_html__( 'Choose label background color', 'merchant' ),
375 'default' => '#d83b3b',
376 ),
377
378 array(
379 'id' => 'table_label_text_color',
380 'type' => 'color',
381 'title' => esc_html__( 'Choose label text color', 'merchant' ),
382 'default' => '#ffffff',
383 ),
384 ),
385 ),
386 array(
387 'id' => 'cart_page',
388 'type' => 'fields_group',
389 'title' => esc_html__( 'Cart Page', 'merchant' ),
390 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the cart page.', 'merchant' ),
391 'state' => 'closed',
392 'accordion' => true,
393 'display_status' => true,
394 'default' => 'inactive',
395 'fields' => array(
396 // Text Formatting Settings
397 array(
398 'id' => 'title',
399 'type' => 'text',
400 'title' => esc_html__( 'Offer title', 'merchant' ),
401 'default' => esc_html__( 'Add {quantity} more to get a {discount} discount off each', 'merchant' ),
402 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
403 'hidden_desc' => sprintf(
404 /* Translators: %1$s: offer quantity, %2$s: discount amount */
405 __(
406 '<strong>%1$s:</strong> to show offer quantity<br><strong>%2$s:</strong> to show discount amount',
407 'merchant'
408 ),
409 '{quantity}',
410 '{discount}'
411 ),
412 ),
413
414 array(
415 'id' => 'button_text',
416 'type' => 'text',
417 'title' => esc_html__( 'Button text', 'merchant' ),
418 'default' => esc_html__( 'Add To Cart', 'merchant' ),
419 ),
420 ),
421 ),
422 array(
423 'id' => 'checkout_page',
424 'type' => 'fields_group',
425 'title' => esc_html__( 'Checkout Page', 'merchant' ),
426 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the checkout page.', 'merchant' ),
427 'state' => 'closed',
428 'default' => 'inactive',
429 'accordion' => true,
430 'display_status' => true,
431 'fields' => array(
432 array(
433 'id' => 'placement',
434 'type' => 'select',
435 'title' => esc_html__( 'Placement', 'merchant' ),
436 'options' => array(
437 'before_billing_details' => esc_html__( 'Before Billing Details', 'merchant' ),
438 'after_billing_details' => esc_html__( 'After Billing Details', 'merchant' ),
439 'before_order_details' => esc_html__( 'Before Order Details', 'merchant' ),
440 'before_payment_options' => esc_html__( 'Before Payment Gateways', 'merchant' ),
441 'before_order_placement_btn' => esc_html__( 'Before Order Placement Button', 'merchant' ),
442 'after_order_placement_btn' => esc_html__( 'After Order Placement Button', 'merchant' ),
443 ),
444 'default' => 'before_billing_details',
445 ),
446 array(
447 'id' => 'title',
448 'type' => 'text',
449 'title' => esc_html__( 'Offer title', 'merchant' ),
450 'default' => esc_html__( 'Add {quantity} more to get {discount} off', 'merchant' ),
451 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
452 'hidden_desc' => sprintf(
453 /* Translators: %1$s: offer quantity, %2$s: discount amount */
454 __(
455 '<strong>%1$s:</strong> to show offer quantity<br><strong>%2$s:</strong> to show discount amount',
456 'merchant'
457 ),
458 '{quantity}',
459 '{discount}'
460 ),
461 ),
462 array(
463 'id' => 'discount_text',
464 'type' => 'text',
465 'title' => esc_html__( 'Discount text', 'merchant' ),
466 'default' => esc_html__( '{product_price}', 'merchant' ),
467 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
468 'hidden_desc' => sprintf(
469 /* Translators: %1$s: product price */
470 __(
471 '<strong>%1$s:</strong> to show product price<br><strong>%2$s:</strong> to show offer discount amount',
472 'merchant'
473 ),
474 '{product_price}',
475 '{discount}'
476 ),
477 ),
478 array(
479 'id' => 'button_text',
480 'type' => 'text',
481 'title' => esc_html__( 'Button text', 'merchant' ),
482 'default' => esc_html__( 'Add To Cart', 'merchant' ),
483 ),
484 ),
485 ),
486 array(
487 'id' => 'thank_you_page',
488 'type' => 'fields_group',
489 'title' => esc_html__( 'Thank You Page', 'merchant' ),
490 'sub-desc' => esc_html__( 'Use these settings to control how bulk discount offers appear on the thank you page.', 'merchant' ),
491 'state' => 'closed',
492 'accordion' => true,
493 'display_status' => true,
494 'default' => 'inactive',
495 'fields' => array(
496 // Text Formatting Settings
497 array(
498 'id' => 'title',
499 'type' => 'text',
500 'title' => esc_html__( 'Offer title', 'merchant' ),
501 'default' => esc_html__( 'Add {quantity} more to get {discount} off', 'merchant' ),
502 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
503 'hidden_desc' => sprintf(
504 /* Translators: %1$s: quantity, %2$s: post purchase discount, %3$s: In Stock, %4$s: Total quantity */
505 __(
506 '<strong>%1$s:</strong> to show product quantity<br><strong>%2$s:</strong> to show the discount amount',
507 'merchant'
508 ),
509 '{quantity}',
510 '{discount}'
511 ),
512 ),
513
514 array(
515 'id' => 'placement',
516 'type' => 'select',
517 'title' => esc_html__( 'Placement', 'merchant' ),
518 'options' => array(
519 'on_top' => esc_html__( 'On Top', 'merchant' ),
520 'before_order_details' => esc_html__( 'Before Order details', 'merchant' ),
521 'after_order_details' => esc_html__( 'After Order details', 'merchant' ),
522 ),
523 'default' => 'before_order_details',
524 ),
525
526 array(
527 'id' => 'discount_text',
528 'type' => 'text',
529 'title' => esc_html__( 'Discount text', 'merchant' ),
530 'default' => esc_html__( '{product_price}', 'merchant' ),
531 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
532 'hidden_desc' => sprintf(
533 /* Translators: %1$s: Discount amount, %2$s: product price */
534 __(
535 '<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',
536 'merchant'
537 ),
538 '{discount}',
539 '{product_price}'
540 ),
541 ),
542
543 array(
544 'id' => 'bonus_tip_text',
545 'type' => 'text',
546 'title' => esc_html__( 'Bonus tip text', 'merchant' ),
547 'default' => esc_html__( 'Bonus: You will also receive this discount off each item you just purchased as part of this bulk discount offer.', 'merchant' ),
548 ),
549
550 array(
551 'id' => 'button_text',
552 'type' => 'text',
553 'title' => esc_html__( 'Button text', 'merchant' ),
554 'default' => esc_html__( 'Add To Cart', 'merchant' ),
555 ),
556 ),
557 ),
558 ),
559 ),
560 ),
561 'default' => array(
562 array(
563 'layout' => 'offer-details',
564 'min_quantity' => 2,
565 'discount' => 10,
566 'discount_type' => 'fixed_discount',
567 ),
568 ),
569 ),
570 ),
571 ) );
572
573 // Shortcode
574 $merchant_module_id = Merchant_Volume_Discounts::MODULE_ID;
575 Merchant_Admin_Options::create( array(
576 'module' => $merchant_module_id,
577 'title' => esc_html__( 'Use shortcode', 'merchant' ),
578 'fields' => array(
579 array(
580 'id' => 'use_shortcode',
581 'type' => 'switcher',
582 'title' => __( 'Use shortcode', 'merchant' ),
583 'default' => 0,
584 ),
585 array(
586 'type' => 'info',
587 'id' => 'shortcode_info',
588 '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.',
589 'merchant' ),
590 ),
591 array(
592 'id' => 'shortcode_text',
593 'type' => 'text_readonly',
594 'title' => esc_html__( 'Shortcode text', 'merchant' ),
595 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']',
596 'condition' => array( 'use_shortcode', '==', '1' ),
597 ),
598 ),
599 ) );
600