PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.11.0
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.11.0
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 / product-labels / admin / options.php

options.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 1.11.0, at inc/modules/product-labels/admin/options.php

454 lines 15.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Merchant - Product Labels
4 */
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 $position = Merchant_Admin_Options::get( Merchant_Product_Labels::MODULE_ID, 'label_position', 'top-left' );
11 $margin_y_label = ( $position === 'top-left' || $position === 'top-right' ) ? esc_html__( 'Margin Top', 'merchant' ) : esc_html__( 'Margin Bottom', 'merchant' );
12 $margin_x_label = ( $position === 'top-left' || $position === 'bottom-left' ) ? esc_html__( 'Margin Left', 'merchant' ) : esc_html__( 'Margin Right', 'merchant' );
13
14 $text_shapes = array();
15 $image_shapes = array();
16
17 for ( $i = 1; $i <= 24; $i++ ) {
18 if ( $i <= 8 ) {
19 $text_shapes[ 'text-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/text-shape-' . $i . '.svg';
20 }
21
22 $image_shapes[ 'image-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/image-shape-' . $i . '.svg';
23 }
24
25 $display_rules = array(
26 'featured_products' => esc_html__( 'Featured Products', 'merchant' ),
27 'products_on_sale' => esc_html__( 'Products on Sale', 'merchant' ),
28 'new_products' => esc_html__( 'New Products', 'merchant' ),
29 'out_of_stock' => esc_html__( 'Out of Stock Products', 'merchant' ),
30 'all_products' => esc_html__( 'All Products', 'merchant' ),
31 'specific_products' => esc_html__( 'Specific Products', 'merchant' ),
32 'by_category' => esc_html__( 'Specific Categories', 'merchant' ),
33 'by_tags' => esc_html__( 'Specific Tags', 'merchant' ),
34 );
35
36 /**
37 * `merchant_product_labels_display_rules`
38 *
39 * @since 1.10.1
40 */
41 $display_rules = apply_filters( 'merchant_product_labels_display_rules', $display_rules, Merchant_Product_Labels::MODULE_ID );
42
43 /**
44 * Settings
45 */
46 Merchant_Admin_Options::create( array(
47 'title' => esc_html__( 'Settings', 'merchant' ),
48 'module' => Merchant_Product_Labels::MODULE_ID,
49 'fields' => array(
50 array(
51 'id' => 'labels',
52 'type' => 'flexible_content',
53 'sorting' => true,
54 'accordion' => true,
55 'duplicate' => true,
56 'style' => Merchant_Product_Labels::MODULE_ID . '-style default',
57 'button_label' => esc_html__( 'Add New Label', 'merchant' ),
58 'layouts' => array(
59 'single-label' => array(
60 'title' => esc_html__( 'Product label', 'merchant' ),
61 'title-field' => 'label-title',
62 'fields' => array(
63 array(
64 'id' => 'label-title',
65 'title' => esc_html__( 'Label name', 'merchant' ),
66 'desc' => esc_html__( 'Internal label name. This is not visible to customers.', 'merchant' ),
67 'type' => 'text',
68 'default' => esc_html__( 'Product label', 'merchant' ),
69 ),
70
71 array(
72 'id' => 'label_type',
73 'type' => 'buttons_content',
74 'title' => '',
75 'desc' => '',
76 'options' => array(
77 'text' => array(
78 'title' => esc_html__( 'Text', 'merchant' ),
79 'desc' => esc_html__( 'Add text label', 'merchant' ),
80 'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/text-icon.svg',
81 ),
82 'image' => array(
83 'title' => esc_html__( 'Image', 'merchant' ),
84 'desc' => esc_html__( 'Add image label', 'merchant' ),
85 'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/image-icon.svg',
86 ),
87 ),
88 'default' => 'text',
89 ),
90
91 array(
92 'id' => 'label',
93 'title' => esc_html__( 'Label content', 'merchant' ),
94 'type' => 'text',
95 'default' => esc_html__( 'SALE', 'merchant' ),
96 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
97 'hidden_desc' => sprintf(
98 /* Translators: %1$s: Discount percentage, %2$s: Discount amount, %3$s: In Stock, %4$s: Total quantity */
99 __(
100 '<strong>%1$s:</strong> to show discount percentage<br><strong>%2$s:</strong> to show discount amount<br><strong>%3$s:</strong> to show In Stock, Sold Out<br><strong>%4$s:</strong> to show total quantity in inventory',
101 'merchant'
102 ),
103 '{sale}',
104 '{sale_amount}',
105 '{inventory}',
106 '{inventory_quantity}'
107 ),
108 'condition' => array( 'label_type', '==', 'text' ),
109 ),
110
111 array(
112 'id' => 'label_text_shape',
113 'type' => 'choices',
114 'title' => esc_html__( 'Label shape', 'merchant' ),
115 'options' => $text_shapes,
116 'default' => 'text-shape-1',
117 'condition' => array( 'label_type', '==', 'text' ),
118 ),
119
120 array(
121 'id' => 'label_image_shape',
122 'type' => 'choices',
123 'title' => esc_html__( 'Image label', 'merchant' ),
124 'options' => $image_shapes,
125 'default' => 'image-shape-1',
126 'condition' => array( 'label_type', '==', 'image' ),
127 ),
128
129 array(
130 'id' => 'label_image_shape_custom',
131 'type' => 'upload',
132 'drag_drop' => true,
133 'title' => esc_html__( 'Upload custom image label', 'merchant' ),
134 'label' => esc_html__( 'Click to upload or drag and drop', 'merchant' ),
135 'condition' => array( 'label_type', '==', 'image' ),
136 ),
137
138 array(
139 'id' => 'label_position',
140 'type' => 'select',
141 'title' => esc_html__( 'Position', 'merchant' ),
142 'options' => array(
143 'top-left' => esc_html__( 'Top left', 'merchant' ),
144 'top-right' => esc_html__( 'Top right', 'merchant' ),
145 ),
146 'default' => 'top-left',
147 ),
148
149 array(
150 'id' => 'margin_y',
151 'type' => 'range',
152 'title' => $margin_y_label,
153 'min' => 0,
154 'max' => 250,
155 'step' => 1,
156 'default' => 10,
157 'unit' => 'px',
158 ),
159
160 array(
161 'id' => 'margin_x',
162 'type' => 'range',
163 'title' => $margin_x_label,
164 'min' => 0,
165 'max' => 250,
166 'step' => 1,
167 'default' => 10,
168 'unit' => 'px',
169 ),
170
171 array(
172 'id' => 'label_width',
173 'type' => 'range',
174 'title' => esc_html__( 'Label width', 'merchant' ),
175 'min' => 1,
176 'max' => 1000,
177 'step' => 1,
178 'default' => 100,
179 'unit' => 'px',
180 ),
181 array(
182 'id' => 'label_height',
183 'type' => 'range',
184 'title' => esc_html__( 'Label height', 'merchant' ),
185 'min' => 1,
186 'max' => 250,
187 'step' => 1,
188 'default' => 32,
189 'unit' => 'px',
190 ),
191
192 array(
193 'id' => 'background_color',
194 'type' => 'color',
195 'title' => esc_html__( 'Background color', 'merchant' ),
196 'default' => '#212121',
197 'condition' => array( 'label_type', '==', 'text' ),
198 ),
199
200 array(
201 'id' => 'shape_radius',
202 'type' => 'range',
203 'title' => esc_html__( 'Shape radius', 'merchant' ),
204 'min' => 0,
205 'max' => 250,
206 'step' => 1,
207 'unit' => 'px',
208 'default' => 5,
209 'condition' => array( 'label_type', '==', 'text' ),
210 ),
211
212 array(
213 'id' => 'font_size',
214 'type' => 'range',
215 'title' => esc_html__( 'Font size', 'merchant' ),
216 'min' => 0,
217 'max' => 250,
218 'step' => 1,
219 'unit' => 'px',
220 'default' => 14,
221 'condition' => array( 'label_type', '==', 'text' ),
222 ),
223
224 array(
225 'id' => 'font_style',
226 'type' => 'select',
227 'title' => esc_html__( 'Font style', 'merchant' ),
228 'options' => array(
229 'normal' => esc_html__( 'Normal', 'merchant' ),
230 'italic' => esc_html__( 'Italic', 'merchant' ),
231 'bold' => esc_html__( 'Bold', 'merchant' ),
232 'bold_italic' => esc_html__( 'Bold Italic', 'merchant' ),
233 ),
234 'default' => 'normal',
235 'condition' => array( 'label_type', '==', 'text' ),
236 ),
237
238 array(
239 'id' => 'text_color',
240 'type' => 'color',
241 'title' => esc_html__( 'Font color', 'merchant' ),
242 'default' => '#ffffff',
243 'condition' => array( 'label_type', '==', 'text' ),
244 ),
245
246 array(
247 'id' => 'display_rules',
248 'type' => 'select',
249 'title' => esc_html__( 'Product trigger', 'merchant' ),
250 'options' => $display_rules,
251 'default' => 'products_on_sale',
252 ),
253
254 array(
255 'id' => 'new_products_days',
256 'type' => 'number',
257 'min' => 0,
258 'step' => 1,
259 'title' => esc_html__( 'How long counts as new', 'merchant' ),
260 'desc' => esc_html__( 'Set the number of days the product will be marked as ‘New’ after it has been created', 'merchant' ),
261 'default' => 3,
262 'condition' => array( 'display_rules', '==', 'new_products' ),
263 ),
264
265 array(
266 'id' => 'product_cats',
267 'type' => 'select_ajax',
268 'title' => esc_html__( 'Categories', 'merchant' ),
269 'source' => 'options',
270 'multiple' => true,
271 'options' => Merchant_Admin_Options::get_category_select2_choices(),
272 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
273 'desc' => esc_html__( 'Select the product categories that will show the label.', 'merchant' ),
274 'condition' => array( 'display_rules', '==', 'by_category' ),
275 ),
276
277 array(
278 'id' => 'product_tags',
279 'type' => 'select_ajax',
280 'title' => esc_html__( 'Tags', 'merchant' ),
281 'source' => 'options',
282 'multiple' => true,
283 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
284 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
285 'desc' => esc_html__( 'Select the product tags that will show the label.', 'merchant' ),
286 'condition' => array( 'display_rules', '==', 'by_tags' ),
287 ),
288
289 array(
290 'id' => 'product_ids',
291 'type' => 'products_selector',
292 'multiple' => true,
293 'desc' => esc_html__( 'Select the products that will show the label.', 'merchant' ),
294 'allowed_types' => array( 'simple', 'variable' ),
295 'condition' => array( 'display_rules', '==', 'specific_products' ),
296 ),
297
298 array(
299 'id' => 'exclusion_enabled',
300 'type' => 'switcher',
301 'title' => esc_html__( 'Exclusion List', 'merchant' ),
302 'desc' => esc_html__( 'Select the products that will not show the label.', 'merchant' ),
303 'default' => 0,
304 'conditions' => array(
305 'relation' => 'AND',
306 'terms' => array(
307 array(
308 'field' => 'display_rules',
309 'operator' => 'in',
310 'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ),
311 ),
312 ),
313 ),
314 ),
315
316 array(
317 'id' => 'excluded_products',
318 'type' => 'products_selector',
319 'title' => esc_html__( 'Exclude Products', 'merchant' ),
320 'desc' => esc_html__( 'Exclude products from this label.', 'merchant' ),
321 'multiple' => true,
322 'allowed_types' => array( 'simple', 'variable' ),
323 'conditions' => array(
324 'relation' => 'AND',
325 'terms' => array(
326 array(
327 'field' => 'display_rules',
328 'operator' => 'in',
329 'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ),
330 ),
331 array(
332 'field' => 'exclusion_enabled',
333 'operator' => '===',
334 'value' => true,
335 ),
336 ),
337 ),
338 ),
339
340 array(
341 'id' => 'excluded_categories',
342 'type' => 'select_ajax',
343 'title' => esc_html__( 'Exclude Categories', 'merchant' ),
344 'source' => 'options',
345 'multiple' => true,
346 'options' => Merchant_Admin_Options::get_category_select2_choices(),
347 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
348 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ),
349 'conditions' => array(
350 'relation' => 'AND',
351 'terms' => array(
352 array(
353 'field' => 'display_rules',
354 'operator' => 'in',
355 'value' => array( 'all_products' ),
356 ),
357 array(
358 'field' => 'exclusion_enabled',
359 'operator' => '===',
360 'value' => true,
361 ),
362 ),
363 ),
364 ),
365
366 array(
367 'id' => 'excluded_tags',
368 'type' => 'select_ajax',
369 'title' => esc_html__( 'Exclude Tags', 'merchant' ),
370 'source' => 'options',
371 'multiple' => true,
372 'options' => Merchant_Admin_Options::get_tag_select2_choices(),
373 'placeholder' => esc_html__( 'Select tags', 'merchant' ),
374 'desc' => esc_html__( 'Exclude tags from this campaign.', 'merchant' ),
375 'conditions' => array(
376 'relation' => 'AND',
377 'terms' => array(
378 array(
379 'field' => 'display_rules',
380 'operator' => 'in',
381 'value' => array( 'all_products' ),
382 ),
383 array(
384 'field' => 'exclusion_enabled',
385 'operator' => '===',
386 'value' => true,
387 ),
388 ),
389 ),
390 ),
391
392 array(
393 'id' => 'show_pages',
394 'type' => 'checkbox_multiple',
395 'title' => esc_html__( 'Show on pages', 'merchant' ),
396 'options' => array(
397 'homepage' => esc_html__( 'Homepage', 'merchant' ),
398 'single' => esc_html__( 'Product Single', 'merchant' ),
399 'archive' => esc_html__( 'Product Archive', 'merchant' ),
400 ),
401 'default' => array( 'homepage', 'single', 'archive' ),
402 ),
403
404 array(
405 'id' => 'show_devices',
406 'type' => 'checkbox_multiple',
407 'title' => esc_html__( 'Show on devices', 'merchant' ),
408 'options' => array(
409 'desktop' => esc_html__( 'Desktop', 'merchant' ),
410 'mobile' => esc_html__( 'Mobile', 'merchant' ),
411 ),
412 'default' => array( 'desktop', 'mobile' ),
413 ),
414 ),
415 ),
416 ),
417 'default' => array(
418 array(
419 'layout' => 'single-label',
420 'label' => esc_html__( 'SALE', 'merchant' ),
421 'display_rules' => 'featured_products',
422 ),
423 ),
424 ),
425 ),
426 ) );
427
428 // Shortcode
429 $merchant_module_id = Merchant_Product_Labels::MODULE_ID;
430 Merchant_Admin_Options::create( array(
431 'module' => $merchant_module_id,
432 'title' => esc_html__( 'Use shortcode', 'merchant' ),
433 'fields' => array(
434 array(
435 'id' => 'use_shortcode',
436 'type' => 'switcher',
437 'title' => __( 'Use shortcode', 'merchant' ),
438 'default' => 0,
439 ),
440 array(
441 'type' => 'info',
442 'id' => 'shortcode_info',
443 '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.', 'merchant' ),
444 ),
445 array(
446 'id' => 'shortcode_text',
447 'type' => 'text_readonly',
448 'title' => esc_html__( 'Shortcode text', 'merchant' ),
449 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']',
450 'condition' => array( 'use_shortcode', '==', '1' ),
451 ),
452 ),
453 ) );
454