PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.5.0
ShopBuilder – WooCommerce Builder For Elementor v2.5.0
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Elementor / Widgets / Controls / AddToCartSettings.php

AddToCartSettings.php in ShopBuilder – WooCommerce Builder For Elementor 2.5.0, at app/Elementor/Widgets/Controls/AddToCartSettings.php

497 lines 14.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductDescription class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Controls;
9
10 use Elementor\Controls_Manager;
11 use RadiusTheme\SB\Elementor\Widgets\Controls\ButtonSettings;
12 use RadiusTheme\SB\Helpers\Fns;
13
14 // Do not allow directly accessing this file.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 'This script cannot be accessed directly.' );
17 }
18
19 /**
20 * Product Description class
21 */
22 class AddToCartSettings {
23 /**
24 * Widget Control Selectors
25 *
26 * @var object
27 */
28 private static $widget = [];
29 /**
30 * Widget Control Selectors
31 *
32 * @var array
33 */
34 private static $selectors = [];
35 /**
36 * Widget Field
37 *
38 * @return array
39 */
40 public static function widget_fields( $widget ) {
41 self::$widget = $widget;
42 self::$selectors = $widget->selectors;
43 return QuantityFields::quantity_fields( $widget ) +
44 self::add_to_cart_fields() +
45 self::add_to_cart_style() +
46 self::product_price_style_fields() +
47 QuantityFields::quantity_style_fields( $widget ) +
48 self::variation_style_fields();
49 }
50
51 /**
52 * Widget Field
53 *
54 * @return array
55 */
56 public static function add_to_cart_fields() {
57 $fields = [
58 'sec_add_to_cart' => [
59 'mode' => 'section_start',
60 'label' => esc_html__( 'Add to cart', 'shopbuilder' ),
61 ],
62
63 'cart_icon' => [
64 'label' => esc_html__( 'Cart Icon', 'shopbuilder' ),
65 'type' => 'icons',
66 'separator' => 'default',
67 ],
68 'cart_icon_align' => [
69 'mode' => 'responsive',
70 'label' => esc_html__( 'Icon Alignment', 'shopbuilder' ),
71 'type' => 'choose',
72 'options' => [
73 '0' => [
74 'title' => esc_html__( 'Left', 'shopbuilder' ),
75 'icon' => 'fas fa-arrow-left',
76 ],
77 '1' => [
78 'title' => esc_html__( 'Right', 'shopbuilder' ),
79 'icon' => 'fas fa-arrow-right',
80 ],
81 ],
82 'default' => '0',
83 'condition' => [
84 'quantity_style!' => 'default',
85 ],
86 'selectors' => [
87 self::$selectors['cart_icon_align'] => 'order: {{VALUE}};',
88 ],
89 ],
90 'cart_icon_gap' => [
91 'label' => esc_html__( 'Gap', 'shopbuilder' ),
92 'type' => 'slider',
93 'mode' => 'responsive',
94 'range' => [
95 'px' => [
96 'min' => 0,
97 'max' => 100,
98 ],
99 ],
100 'selectors' => [
101 self::$selectors['cart_icon_gap'] => 'gap: {{SIZE}}{{UNIT}};',
102 ],
103 ],
104 'add_to_cart_end' => [
105 'mode' => 'section_end',
106 ],
107 ];
108 return $fields;
109 }
110 /**
111 * Widget Field
112 *
113 * @return array
114 */
115 public static function add_to_cart_style() {
116 $fields = ButtonSettings::style_settings( self::$widget );
117 $insert_array = [
118 'cart_icon_size' => [
119 'label' => esc_html__( 'Icon size', 'shopbuilder' ),
120 'type' => 'slider',
121 'separator' => 'default',
122 'range' => [
123 'px' => [
124 'min' => 10,
125 'max' => 50,
126 ],
127 ],
128 'selectors' => [
129 self::$selectors['cart_icon_size']['icon'] => 'font-size: {{SIZE}}{{UNIT}};',
130 self::$selectors['cart_icon_size']['svg'] => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
131 ],
132 ],
133 ];
134 $fields = Fns::insert_controls( 'button_padding', $fields, $insert_array );
135 return $fields;
136 }
137
138 /**
139 * Widget Field
140 *
141 * @return array
142 */
143 public static function quantity_style_fields() {
144 $fields = [
145 'quantity_section' => [
146 'mode' => 'section_start',
147 'tab' => 'style',
148 'label' => esc_html__( 'Quantity', 'shopbuilder' ),
149 ],
150 'quantity_style_heading' => [
151 'type' => 'html',
152 'raw' => sprintf(
153 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
154 esc_html__( 'Quantity Style', 'shopbuilder' )
155 ),
156 'content_classes' => 'elementor-panel-heading-title',
157 'condition' => [
158 'quantity_style' => [ 'style-1', 'style-2' ],
159 ],
160 ],
161 'icon_size' => [
162 'label' => esc_html__( 'Icon size', 'shopbuilder' ),
163 'type' => 'slider',
164 'separator' => 'default',
165 'range' => [
166 'px' => [
167 'min' => 10,
168 'max' => 50,
169 ],
170 ],
171 'default' => [
172 'size' => 15,
173 ],
174 'selectors' => [
175 self::$selectors['icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
176 ],
177 ],
178 'quantitybox_border_color' => [
179 'label' => esc_html__( 'Border Color', 'shopbuilder' ),
180 'type' => 'color',
181 'selectors' => [
182 self::$selectors['quantitybox_border_color'] => 'border-color: {{VALUE}}',
183 ],
184 ],
185 'quantity_icon_tabs_start' => [
186 'mode' => 'tabs_start',
187 ],
188 // Tab For normal view.
189 'quantity_icon_normal' => [
190 'mode' => 'tab_start',
191 'label' => esc_html__( 'Normal', 'shopbuilder' ),
192 ],
193 'quantity_icon_color' => [
194 'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
195 'type' => 'color',
196 'separator' => 'default',
197 'selectors' => [
198 self::$selectors['quantity_icon_color'] => 'color: {{VALUE}}',
199 ],
200 ],
201 'quantity_icon_normal_end' => [
202 'mode' => 'tab_end',
203 ],
204 'quantity_icon_hover' => [
205 'mode' => 'tab_start',
206 'label' => esc_html__( 'Hover', 'shopbuilder' ),
207 ],
208 'quantity_icon_hover_color' => [
209 'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
210 'type' => 'color',
211 'separator' => 'default',
212 'selectors' => [
213 self::$selectors['quantity_icon_hover_color'] => 'color: {{VALUE}}',
214 ],
215 ],
216 'quantity_icon_hover_end' => [
217 'mode' => 'tab_end',
218 ],
219 'quantity_icon_tabs_end' => [
220 'mode' => 'tabs_end',
221 ],
222
223 'text_typography' => [
224 'type' => 'typography',
225 'separator' => 'before',
226 'mode' => 'group',
227 'label' => esc_html__( 'Typography', 'shopbuilder' ),
228 'description' => esc_html__( 'Only for Quantity Label.', 'shopbuilder' ),
229 'selector' => self::$selectors['text_typography'],
230 ],
231 'quantity_number_color' => [
232 'label' => esc_html__( 'Quantity Number', 'shopbuilder' ),
233 'type' => 'color',
234 'selectors' => [
235 self::$selectors['quantity_number_color'] => 'color: {{VALUE}}',
236 ],
237 ],
238 'quantity_background_color' => [
239 'label' => esc_html__( 'Quantity Backgeound', 'shopbuilder' ),
240 'type' => 'color',
241 'selectors' => [
242 self::$selectors['quantity_background_color'] => 'background: {{VALUE}}',
243 ],
244 ],
245 'quantity_border' => [
246 'mode' => 'group',
247 'type' => 'border',
248 'label' => esc_html__( 'Quantity Border', 'shopbuilder' ),
249 'selector' => self::$selectors['quantity_border'],
250 ],
251 'quantity_radius' => [
252 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
253 'size_units' => [ 'px', '%' ],
254 'type' => 'dimensions',
255 'selectors' => [
256 self::$selectors['quantity_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
257 ],
258 ],
259 'qunatity_padding' => [
260 'label' => esc_html__( 'Padding', 'shopbuilder' ),
261 'type' => 'dimensions',
262 'mode' => 'responsive',
263 'size_units' => [ 'px', '%', 'em' ],
264 'selectors' => [
265 self::$selectors['qunatity_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
266 ],
267 ],
268 'quantity_style_wrapper_heading' => [
269 'type' => 'html',
270 'raw' => sprintf(
271 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
272 esc_html__( 'Quantity Wrapper Style', 'shopbuilder' )
273 ),
274 'content_classes' => 'elementor-panel-heading-title',
275 'condition' => [
276 'quantity_style' => [ 'style-1', 'style-2' ],
277 ],
278 ],
279 'quantity_wrapper_background_color' => [
280 'label' => esc_html__( 'Background', 'shopbuilder' ),
281 'type' => 'color',
282 'selectors' => [
283 self::$selectors['quantity_wrapper_background_color'] => 'background: {{VALUE}}',
284 ],
285 'condition' => [
286 'quantity_style' => [ 'style-1', 'style-2' ],
287 ],
288 ],
289 'quantity_wrapper_radius' => [
290 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
291 'size_units' => [ 'px', '%' ],
292 'type' => 'dimensions',
293 'selectors' => [
294 self::$selectors['quantity_wrapper_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
295 ],
296 'condition' => [
297 'quantity_style' => [ 'style-1', 'style-2' ],
298 ],
299 ],
300 'qunatity_wrapper_padding' => [
301 'label' => esc_html__( 'Padding', 'shopbuilder' ),
302 'type' => 'dimensions',
303 'mode' => 'responsive',
304 'size_units' => [ 'px', '%', 'em' ],
305 'selectors' => [
306 self::$selectors['qunatity_wrapper_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
307 ],
308 ],
309 'quantity_section_end' => [
310 'mode' => 'section_end',
311 ],
312 ];
313 return $fields;
314 }
315
316 /**
317 * Widget Field
318 *
319 * @return array
320 */
321 public static function variation_style_fields() {
322 $fields = [
323 'variation_section' => [
324 'mode' => 'section_start',
325 'tab' => 'style',
326 'label' => esc_html__( 'Variations', 'shopbuilder' ),
327 ],
328 'variation_label_typography' => [
329 'type' => 'typography',
330 'separator' => 'before',
331 'mode' => 'group',
332 'label' => esc_html__( 'Label Typography', 'shopbuilder' ),
333 'description' => esc_html__( 'Only for Variation Label.', 'shopbuilder' ),
334 'selector' => self::$selectors['variation_label_typography'],
335 ],
336 'variation_stock_typography' => [
337 'type' => 'typography',
338 'separator' => 'before',
339 'mode' => 'group',
340 'label' => esc_html__( 'Stock Typography', 'shopbuilder' ),
341 'description' => esc_html__( 'Only for variation stock.', 'shopbuilder' ),
342 'selector' => self::$selectors['variation_stock_typography'],
343 ],
344 'variation_label_color' => [
345 'label' => esc_html__( 'Label Color', 'shopbuilder' ),
346 'type' => 'color',
347 'selectors' => [
348 self::$selectors['variation_label_color'] => 'color: {{VALUE}}',
349 ],
350 ],
351 'variation_stock_color' => [
352 'label' => esc_html__( 'Stock Color', 'shopbuilder' ),
353 'type' => 'color',
354 'selectors' => [
355 self::$selectors['variation_stock_color'] => 'color: {{VALUE}}',
356 ],
357 ],
358 'variation_outofstock_color' => [
359 'label' => esc_html__( 'Out of Stock Color', 'shopbuilder' ),
360 'type' => 'color',
361 'selectors' => [
362 self::$selectors['variation_outofstock_color'] => 'color: {{VALUE}}',
363 ],
364 ],
365 'variation_height' => [
366 'label' => esc_html__( 'Height', 'shopbuilder' ),
367 'type' => 'slider',
368 'range' => [
369 'px' => [
370 'min' => 10,
371 'max' => 200,
372 ],
373 ],
374 'default' => [
375 'unit' => 'px',
376 'size' => '50',
377 ],
378 'selectors' => [
379 self::$selectors['variation_height'] => 'height: {{SIZE}}{{UNIT}};',
380 ],
381 ],
382 'variation_width' => [
383 'label' => esc_html__( 'Min Width', 'shopbuilder' ),
384 'size_units' => [ 'px', '%' ],
385 'type' => 'slider',
386 'range' => [
387 'px' => [
388 'min' => 10,
389 'max' => 900,
390 ],
391 '%' => [
392 'min' => 0,
393 'max' => 100,
394 ],
395 ],
396 'selectors' => [
397 self::$selectors['variation_width'] => 'min-width: {{SIZE}}{{UNIT}};',
398 ],
399 ],
400 'variation_border' => [
401 'mode' => 'group',
402 'type' => 'border',
403 'label' => esc_html__( 'Quantity Border', 'shopbuilder' ),
404 'selector' => self::$selectors['variation_border'],
405 ],
406 'variation_border_radius' => [
407 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
408 'size_units' => [ 'px', '%' ],
409 'type' => 'slider',
410 'selectors' => [
411 self::$selectors['variation_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
412 ],
413 ],
414 'variation_padding' => [
415 'label' => esc_html__( 'Padding ', 'shopbuilder' ),
416 'description' => esc_html__( 'Note: Only for Select And Button Field.', 'shopbuilder' ),
417 'type' => 'dimensions',
418 'size_units' => [ 'px' ],
419 'default' => [
420 'top' => '10',
421 'right' => '10',
422 'bottom' => '10',
423 'left' => '10',
424 'unit' => 'px',
425 'isLinked' => true,
426 ],
427 'separator' => 'default',
428 'selectors' => [
429 self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
430 ],
431 ],
432 'variation_label_margin' => [
433 'label' => esc_html__( 'Label Margin', 'shopbuilder' ),
434 'type' => 'dimensions',
435 'size_units' => [ 'px', '%', 'em' ],
436 'selectors' => [
437 self::$selectors['variation_label_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
438 ],
439 ],
440 'variation_item_margin' => [
441 'label' => esc_html__( 'Variation Item Margin', 'shopbuilder' ),
442 'type' => 'dimensions',
443 'size_units' => [ 'px', '%', 'em' ],
444 'selectors' => [
445 self::$selectors['variation_item_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
446 ],
447 ],
448 'variation_section_end' => [
449 'mode' => 'section_end',
450 ],
451 ];
452 return $fields;
453 }
454
455 /**
456 * Widget Field
457 *
458 * @return array
459 */
460 public static function product_price_style_fields() {
461 return [
462 'price_section_style_start' => [
463 'mode' => 'section_start',
464 'tab' => 'style',
465 'label' => esc_html__( 'Price', 'shopbuilder' ),
466 ],
467 'price_typography' => [
468 'type' => 'typography',
469 'separator' => 'before',
470 'mode' => 'group',
471 'label' => esc_html__( 'Typography', 'shopbuilder' ),
472 'description' => esc_html__( 'Only for Variation Price', 'shopbuilder' ),
473 'selector' => self::$selectors['price_typography'],
474 ],
475 'price_color' => [
476 'label' => esc_html__( 'Color', 'shopbuilder' ),
477 'type' => 'color',
478 'selectors' => [
479 self::$selectors['price_color'] => 'color: {{VALUE}}',
480 ],
481 ],
482 'price_margin' => [
483 'label' => esc_html__( 'Margin', 'shopbuilder' ),
484 'type' => 'dimensions',
485 'size_units' => [ 'px' ],
486 'separator' => 'default',
487 'selectors' => [
488 self::$selectors['price_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
489 ],
490 ],
491 'price_section_style_end' => [
492 'mode' => 'section_end',
493 ],
494 ];
495 }
496 }
497