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

359 lines 12.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 /**
26 * Settings
27 */
28 Merchant_Admin_Options::create( array(
29 'title' => esc_html__( 'Settings', 'merchant' ),
30 'module' => Merchant_Product_Labels::MODULE_ID,
31 'fields' => array(
32 array(
33 'id' => 'labels',
34 'type' => 'flexible_content',
35 'sorting' => true,
36 'accordion' => true,
37 'duplicate' => true,
38 'style' => Merchant_Product_Labels::MODULE_ID . '-style default',
39 'button_label' => esc_html__( 'Add New Label', 'merchant' ),
40 'layouts' => array(
41 'single-label' => array(
42 'title' => esc_html__( 'Product label', 'merchant' ),
43 'title-field' => 'label-title',
44 'fields' => array(
45 array(
46 'id' => 'label-title',
47 'title' => esc_html__( 'Label name', 'merchant' ),
48 'desc' => esc_html__( 'Internal label name. This is not visible to customers.', 'merchant' ),
49 'type' => 'text',
50 'default' => esc_html__( 'Product label', 'merchant' ),
51 ),
52
53 array(
54 'id' => 'label_type',
55 'type' => 'buttons_content',
56 'title' => '',
57 'desc' => '',
58 'options' => array(
59 'text' => array(
60 'title' => esc_html__( 'Text', 'merchant' ),
61 'desc' => esc_html__( 'Add text label', 'merchant' ),
62 'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/text-icon.svg',
63 ),
64 'image' => array(
65 'title' => esc_html__( 'Image', 'merchant' ),
66 'desc' => esc_html__( 'Add image label', 'merchant' ),
67 'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/image-icon.svg',
68 ),
69 ),
70 'default' => 'text',
71 ),
72
73 array(
74 'id' => 'label',
75 'title' => esc_html__( 'Label content', 'merchant' ),
76 'type' => 'text',
77 'default' => esc_html__( 'SALE', 'merchant' ),
78 'desc' => __( 'You can use these codes in the content.', 'merchant' ),
79 'hidden_desc' => sprintf(
80 /* Translators: %1$s: Discount percentage, %2$s: Discount amount, %3$s: In Stock, %4$s: Total quantity */
81 __(
82 '<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',
83 'merchant'
84 ),
85 '{sale}',
86 '{sale_amount}',
87 '{inventory}',
88 '{inventory_quantity}'
89 ),
90 'condition' => array( 'label_type', '==', 'text' ),
91 ),
92
93 array(
94 'id' => 'label_text_shape',
95 'type' => 'choices',
96 'title' => esc_html__( 'Label shape', 'merchant' ),
97 'options' => $text_shapes,
98 'default' => 'text-shape-1',
99 'condition' => array( 'label_type', '==', 'text' ),
100 ),
101
102 array(
103 'id' => 'label_image_shape',
104 'type' => 'choices',
105 'title' => esc_html__( 'Image label', 'merchant' ),
106 'options' => $image_shapes,
107 'default' => 'image-shape-1',
108 'condition' => array( 'label_type', '==', 'image' ),
109 ),
110
111 array(
112 'id' => 'label_image_shape_custom',
113 'type' => 'upload',
114 'drag_drop' => true,
115 'title' => esc_html__( 'Upload custom image label', 'merchant' ),
116 'label' => esc_html__( 'Click to upload or drag and drop', 'merchant' ),
117 'condition' => array( 'label_type', '==', 'image' ),
118 ),
119
120 array(
121 'id' => 'label_position',
122 'type' => 'select',
123 'title' => esc_html__( 'Position', 'merchant' ),
124 'options' => array(
125 'top-left' => esc_html__( 'Top left', 'merchant' ),
126 'top-right' => esc_html__( 'Top right', 'merchant' ),
127 ),
128 'default' => 'top-left',
129 ),
130
131 array(
132 'id' => 'margin_y',
133 'type' => 'range',
134 'title' => $margin_y_label,
135 'min' => 0,
136 'max' => 250,
137 'step' => 1,
138 'default' => 10,
139 'unit' => 'px',
140 ),
141
142 array(
143 'id' => 'margin_x',
144 'type' => 'range',
145 'title' => $margin_x_label,
146 'min' => 0,
147 'max' => 250,
148 'step' => 1,
149 'default' => 10,
150 'unit' => 'px',
151 ),
152
153 array(
154 'id' => 'label_width',
155 'type' => 'range',
156 'title' => esc_html__( 'Label width', 'merchant' ),
157 'min' => 1,
158 'max' => 1000,
159 'step' => 1,
160 'default' => 100,
161 'unit' => 'px',
162 ),
163 array(
164 'id' => 'label_height',
165 'type' => 'range',
166 'title' => esc_html__( 'Label height', 'merchant' ),
167 'min' => 1,
168 'max' => 250,
169 'step' => 1,
170 'default' => 32,
171 'unit' => 'px',
172 ),
173
174 array(
175 'id' => 'background_color',
176 'type' => 'color',
177 'title' => esc_html__( 'Background color', 'merchant' ),
178 'default' => '#212121',
179 'condition' => array( 'label_type', '==', 'text' ),
180 ),
181
182 array(
183 'id' => 'shape_radius',
184 'type' => 'range',
185 'title' => esc_html__( 'Shape radius', 'merchant' ),
186 'min' => 0,
187 'max' => 250,
188 'step' => 1,
189 'unit' => 'px',
190 'default' => 5,
191 'condition' => array( 'label_type', '==', 'text' ),
192 ),
193
194 array(
195 'id' => 'font_size',
196 'type' => 'range',
197 'title' => esc_html__( 'Font size', 'merchant' ),
198 'min' => 0,
199 'max' => 250,
200 'step' => 1,
201 'unit' => 'px',
202 'default' => 14,
203 'condition' => array( 'label_type', '==', 'text' ),
204 ),
205
206 array(
207 'id' => 'font_style',
208 'type' => 'select',
209 'title' => esc_html__( 'Font style', 'merchant' ),
210 'options' => array(
211 'normal' => esc_html__( 'Normal', 'merchant' ),
212 'italic' => esc_html__( 'Italic', 'merchant' ),
213 'bold' => esc_html__( 'Bold', 'merchant' ),
214 'bold_italic' => esc_html__( 'Bold Italic', 'merchant' ),
215 ),
216 'default' => 'normal',
217 'condition' => array( 'label_type', '==', 'text' ),
218 ),
219
220 array(
221 'id' => 'text_color',
222 'type' => 'color',
223 'title' => esc_html__( 'Font color', 'merchant' ),
224 'default' => '#ffffff',
225 'condition' => array( 'label_type', '==', 'text' ),
226 ),
227
228 array(
229 'id' => 'display_rules',
230 'type' => 'select',
231 'title' => esc_html__( 'Product trigger', 'merchant' ),
232 'options' => array(
233 'featured_products' => esc_html__( 'Featured Products', 'merchant' ),
234 'products_on_sale' => esc_html__( 'Products on Sale', 'merchant' ),
235 'new_products' => esc_html__( 'New Products', 'merchant' ),
236 'out_of_stock' => esc_html__( 'Out of Stock Products', 'merchant' ),
237 'all_products' => esc_html__( 'All Products', 'merchant' ),
238 'specific_products' => esc_html__( 'Specific Products', 'merchant' ),
239 'by_category' => esc_html__( 'Specific Categories', 'merchant' ),
240 ),
241 'default' => 'products_on_sale',
242 ),
243
244 array(
245 'id' => 'new_products_days',
246 'type' => 'number',
247 'min' => 0,
248 'step' => 1,
249 'title' => esc_html__( 'How long counts as new', 'merchant' ),
250 'desc' => esc_html__( 'Set the number of days the product will be marked as ‘New’ after it has been created', 'merchant' ),
251 'default' => 3,
252 'condition' => array( 'display_rules', '==', 'new_products' ),
253 ),
254
255 array(
256 'id' => 'product_cats',
257 'type' => 'select_ajax',
258 'title' => esc_html__( 'Categories', 'merchant' ),
259 'source' => 'options',
260 'multiple' => true,
261 'options' => Merchant_Admin_Options::get_category_select2_choices(),
262 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
263 'desc' => esc_html__( 'Select the product categories that will show the label.', 'merchant' ),
264 'condition' => array( 'display_rules', '==', 'by_category' ),
265 ),
266
267 array(
268 'id' => 'product_ids',
269 'type' => 'products_selector',
270 'multiple' => true,
271 'desc' => esc_html__( 'Select the products that will show the layel.', 'merchant' ),
272 'allowed_types' => array( 'simple', 'variable' ),
273 'condition' => array( 'display_rules', '==', 'specific_products' ),
274 ),
275
276 array(
277 'id' => 'excluded_products',
278 'type' => 'products_selector',
279 'title' => esc_html__( 'Exclude Products', 'merchant' ),
280 'multiple' => true,
281 'desc' => esc_html__( 'Exclude products from this label.', 'merchant' ),
282 'condition' => array( 'display_rules', 'any', 'all_products|by_category|featured_products|new_products|products_on_sale|out_of_stock' ),
283 ),
284
285 array(
286 'id' => 'excluded_categories',
287 'type' => 'select_ajax',
288 'title' => esc_html__( 'Exclude Categories', 'merchant' ),
289 'source' => 'options',
290 'multiple' => true,
291 'options' => Merchant_Admin_Options::get_category_select2_choices(),
292 'placeholder' => esc_html__( 'Select categories', 'merchant' ),
293 'desc' => esc_html__( 'Exclude categories from this campaign.', 'merchant' ),
294 'condition' => array( 'display_rules', '==', 'all_products' ),
295 ),
296
297 array(
298 'id' => 'show_pages',
299 'type' => 'checkbox_multiple',
300 'title' => esc_html__( 'Show on pages', 'merchant' ),
301 'options' => array(
302 'homepage' => esc_html__( 'Homepage', 'merchant' ),
303 'single' => esc_html__( 'Product Single', 'merchant' ),
304 'archive' => esc_html__( 'Product Archive', 'merchant' ),
305 ),
306 'default' => array( 'homepage', 'single', 'archive' ),
307 ),
308
309 array(
310 'id' => 'show_devices',
311 'type' => 'checkbox_multiple',
312 'title' => esc_html__( 'Show on devices', 'merchant' ),
313 'options' => array(
314 'desktop' => esc_html__( 'Desktop', 'merchant' ),
315 'mobile' => esc_html__( 'Mobile', 'merchant' ),
316 ),
317 'default' => array( 'desktop', 'mobile' ),
318 ),
319 ),
320 ),
321 ),
322 'default' => array(
323 array(
324 'layout' => 'single-label',
325 'label' => esc_html__( 'SALE', 'merchant' ),
326 'display_rules' => 'featured_products',
327 ),
328 ),
329 ),
330 ),
331 ) );
332
333 // Shortcode
334 $merchant_module_id = Merchant_Product_Labels::MODULE_ID;
335 Merchant_Admin_Options::create( array(
336 'module' => $merchant_module_id,
337 'title' => esc_html__( 'Use shortcode', 'merchant' ),
338 'fields' => array(
339 array(
340 'id' => 'use_shortcode',
341 'type' => 'switcher',
342 'title' => __( 'Use shortcode', 'merchant' ),
343 'default' => 0,
344 ),
345 array(
346 'type' => 'info',
347 'id' => 'shortcode_info',
348 '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' ),
349 ),
350 array(
351 'id' => 'shortcode_text',
352 'type' => 'text_readonly',
353 'title' => esc_html__( 'Shortcode text', 'merchant' ),
354 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']',
355 'condition' => array( 'use_shortcode', '==', '1' ),
356 ),
357 ),
358 ) );
359