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 / product-labels / 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/product-labels/admin/options.php

381 lines 13.4 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 layel.', 'merchant' ),
294 'allowed_types' => array( 'simple', 'variable' ),
295 'condition' => array( 'display_rules', '==', 'specific_products' ),
296 ),
297
298 array(
299 'id' => 'excluded_products',
300 'type' => 'products_selector',
301 'title' => esc_html__( 'Exclude Products', 'merchant' ),
302 'multiple' => true,
303 'desc' => esc_html__( 'Exclude products from this label.', 'merchant' ),
304 'condition' => array( 'display_rules', 'any', 'all_products|by_category|by_tags|featured_products|new_products|products_on_sale|out_of_stock|pre-order' ),
305 ),
306
307 array(
308 'id' => 'excluded_categories',
309 'type' => 'select_ajax',
310 'title' => esc_html__( 'Exclude Categories', 'merchant' ),
311 'source' => 'options',
312 'multiple' => true,
313 'options' => Merchant_Admin_Options::get_category_select2_choices(),
314 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
315 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ),
316 'condition' => array( 'display_rules', '==', 'all_products' ),
317 ),
318
319 array(
320 'id' => 'show_pages',
321 'type' => 'checkbox_multiple',
322 'title' => esc_html__( 'Show on pages', 'merchant' ),
323 'options' => array(
324 'homepage' => esc_html__( 'Homepage', 'merchant' ),
325 'single' => esc_html__( 'Product Single', 'merchant' ),
326 'archive' => esc_html__( 'Product Archive', 'merchant' ),
327 ),
328 'default' => array( 'homepage', 'single', 'archive' ),
329 ),
330
331 array(
332 'id' => 'show_devices',
333 'type' => 'checkbox_multiple',
334 'title' => esc_html__( 'Show on devices', 'merchant' ),
335 'options' => array(
336 'desktop' => esc_html__( 'Desktop', 'merchant' ),
337 'mobile' => esc_html__( 'Mobile', 'merchant' ),
338 ),
339 'default' => array( 'desktop', 'mobile' ),
340 ),
341 ),
342 ),
343 ),
344 'default' => array(
345 array(
346 'layout' => 'single-label',
347 'label' => esc_html__( 'SALE', 'merchant' ),
348 'display_rules' => 'featured_products',
349 ),
350 ),
351 ),
352 ),
353 ) );
354
355 // Shortcode
356 $merchant_module_id = Merchant_Product_Labels::MODULE_ID;
357 Merchant_Admin_Options::create( array(
358 'module' => $merchant_module_id,
359 'title' => esc_html__( 'Use shortcode', 'merchant' ),
360 'fields' => array(
361 array(
362 'id' => 'use_shortcode',
363 'type' => 'switcher',
364 'title' => __( 'Use shortcode', 'merchant' ),
365 'default' => 0,
366 ),
367 array(
368 'type' => 'info',
369 'id' => 'shortcode_info',
370 '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' ),
371 ),
372 array(
373 'id' => 'shortcode_text',
374 'type' => 'text_readonly',
375 'title' => esc_html__( 'Shortcode text', 'merchant' ),
376 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']',
377 'condition' => array( 'use_shortcode', '==', '1' ),
378 ),
379 ),
380 ) );
381