PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.2
ShopBuilder – WooCommerce Builder For Elementor v3.4.2
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 3.4.2, at app/Elementor/Widgets/Controls/AddToCartSettings.php

624 lines 19.7 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 * @param object $widget object.
39 * @return array
40 */
41 public static function widget_fields( $widget ) {
42 self::$widget = $widget;
43 self::$selectors = $widget->selectors;
44 return QuantityFields::quantity_fields( $widget ) +
45 self::add_to_cart_fields() +
46 self::add_to_cart_style() +
47 self::product_price_style_fields() +
48 QuantityFields::quantity_style_fields( $widget ) +
49 self::variation_style_fields();
50 }
51
52 /**
53 * Widget Field
54 *
55 * @return array
56 */
57 public static function add_to_cart_fields() {
58 $fields = [
59 'sec_add_to_cart' => [
60 'mode' => 'section_start',
61 'label' => esc_html__( 'Add to cart', 'shopbuilder' ),
62 ],
63
64 'cart_icon' => [
65 'label' => esc_html__( 'Cart Icon', 'shopbuilder' ),
66 'type' => 'icons',
67 'separator' => 'default',
68 ],
69 'cart_icon_align' => [
70 'mode' => 'responsive',
71 'label' => esc_html__( 'Icon Alignment', 'shopbuilder' ),
72 'type' => 'choose',
73 'options' => [
74 '0' => [
75 'title' => esc_html__( 'Left', 'shopbuilder' ),
76 'icon' => 'fas fa-arrow-left',
77 ],
78 '1' => [
79 'title' => esc_html__( 'Right', 'shopbuilder' ),
80 'icon' => 'fas fa-arrow-right',
81 ],
82 ],
83 'default' => '0',
84 'condition' => [
85 'quantity_style!' => 'default',
86 ],
87 'selectors' => [
88 self::$selectors['cart_icon_align']['icon'] => 'order: {{VALUE}};',
89 self::$selectors['cart_icon_align']['svg'] => 'order: {{VALUE}};',
90 ],
91 ],
92 'cart_icon_gap' => [
93 'label' => esc_html__( 'Gap', 'shopbuilder' ),
94 'type' => 'slider',
95 'mode' => 'responsive',
96 'range' => [
97 'px' => [
98 'min' => 0,
99 'max' => 100,
100 ],
101 ],
102 'selectors' => [
103 self::$selectors['cart_icon_gap'] => 'gap: {{SIZE}}{{UNIT}};',
104 ],
105 ],
106 'add_to_cart_end' => [
107 'mode' => 'section_end',
108 ],
109 ];
110 return $fields;
111 }
112 /**
113 * Widget Field
114 *
115 * @return array
116 */
117 public static function add_to_cart_style() {
118 $fields = ButtonSettings::style_settings( self::$widget );
119 $insert_array = [
120 'cart_icon_size' => [
121 'label' => esc_html__( 'Icon size', 'shopbuilder' ),
122 'type' => 'slider',
123 'separator' => 'default',
124 'range' => [
125 'px' => [
126 'min' => 10,
127 'max' => 50,
128 ],
129 ],
130 'selectors' => [
131 self::$selectors['cart_icon_size']['icon'] => 'font-size: {{SIZE}}{{UNIT}};',
132 self::$selectors['cart_icon_size']['svg'] => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
133 ],
134 ],
135 ];
136 $fields = Fns::insert_controls( 'button_padding', $fields, $insert_array );
137 return $fields;
138 }
139
140 /**
141 * Widget Field
142 *
143 * @return array
144 */
145 public static function quantity_style_fields() {
146 $fields = [
147 'quantity_section' => [
148 'mode' => 'section_start',
149 'tab' => 'style',
150 'label' => esc_html__( 'Quantity', 'shopbuilder' ),
151 ],
152 'quantity_style_heading' => [
153 'type' => 'html',
154 'raw' => sprintf(
155 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
156 esc_html__( 'Quantity Style', 'shopbuilder' )
157 ),
158 'content_classes' => 'elementor-panel-heading-title',
159 'condition' => [
160 'quantity_style' => [ 'style-1', 'style-2' ],
161 ],
162 ],
163 'icon_size' => [
164 'label' => esc_html__( 'Icon size', 'shopbuilder' ),
165 'type' => 'slider',
166 'separator' => 'default',
167 'range' => [
168 'px' => [
169 'min' => 10,
170 'max' => 50,
171 ],
172 ],
173 'default' => [
174 'size' => 10,
175 ],
176 'selectors' => [
177 self::$selectors['icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
178 ],
179 ],
180 'quantitybox_border_color' => [
181 'label' => esc_html__( 'Border Color', 'shopbuilder' ),
182 'type' => 'color',
183 'selectors' => [
184 self::$selectors['quantitybox_border_color'] => 'border-color: {{VALUE}}',
185 ],
186 ],
187 'quantity_icon_tabs_start' => [
188 'mode' => 'tabs_start',
189 ],
190 // Tab For normal view.
191 'quantity_icon_normal' => [
192 'mode' => 'tab_start',
193 'label' => esc_html__( 'Normal', 'shopbuilder' ),
194 ],
195 'quantity_icon_color' => [
196 'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
197 'type' => 'color',
198 'separator' => 'default',
199 'selectors' => [
200 self::$selectors['quantity_icon_color'] => 'color: {{VALUE}}',
201 ],
202 ],
203 'quantity_icon_normal_end' => [
204 'mode' => 'tab_end',
205 ],
206 'quantity_icon_hover' => [
207 'mode' => 'tab_start',
208 'label' => esc_html__( 'Hover', 'shopbuilder' ),
209 ],
210 'quantity_icon_hover_color' => [
211 'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
212 'type' => 'color',
213 'separator' => 'default',
214 'selectors' => [
215 self::$selectors['quantity_icon_hover_color'] => 'color: {{VALUE}}',
216 ],
217 ],
218 'quantity_icon_hover_end' => [
219 'mode' => 'tab_end',
220 ],
221 'quantity_icon_tabs_end' => [
222 'mode' => 'tabs_end',
223 ],
224
225 'text_typography' => [
226 'type' => 'typography',
227 'separator' => 'before',
228 'mode' => 'group',
229 'label' => esc_html__( 'Typography', 'shopbuilder' ),
230 'description' => esc_html__( 'Only for Quantity Label.', 'shopbuilder' ),
231 'selector' => self::$selectors['text_typography'],
232 ],
233 'quantity_number_color' => [
234 'label' => esc_html__( 'Quantity Number', 'shopbuilder' ),
235 'type' => 'color',
236 'selectors' => [
237 self::$selectors['quantity_number_color'] => 'color: {{VALUE}}',
238 ],
239 ],
240 'quantity_background_color' => [
241 'label' => esc_html__( 'Quantity Backgeound', 'shopbuilder' ),
242 'type' => 'color',
243 'selectors' => [
244 self::$selectors['quantity_background_color'] => 'background: {{VALUE}}',
245 ],
246 ],
247 'quantity_border' => [
248 'mode' => 'group',
249 'type' => 'border',
250 'label' => esc_html__( 'Quantity Border', 'shopbuilder' ),
251 'selector' => self::$selectors['quantity_border'],
252 ],
253 'quantity_radius' => [
254 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
255 'size_units' => [ 'px', '%' ],
256 'type' => 'dimensions',
257 'selectors' => [
258 self::$selectors['quantity_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
259 ],
260 ],
261 'qunatity_padding' => [
262 'label' => esc_html__( 'Padding', 'shopbuilder' ),
263 'type' => 'dimensions',
264 'mode' => 'responsive',
265 'size_units' => [ 'px', '%', 'em' ],
266 'selectors' => [
267 self::$selectors['qunatity_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
268 ],
269 ],
270 'quantity_style_wrapper_heading' => [
271 'type' => 'html',
272 'raw' => sprintf(
273 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
274 esc_html__( 'Quantity Wrapper Style', 'shopbuilder' )
275 ),
276 'content_classes' => 'elementor-panel-heading-title',
277 'condition' => [
278 'quantity_style' => [ 'style-1', 'style-2' ],
279 ],
280 ],
281 'quantity_wrapper_background_color' => [
282 'label' => esc_html__( 'Background', 'shopbuilder' ),
283 'type' => 'color',
284 'selectors' => [
285 self::$selectors['quantity_wrapper_background_color'] => 'background: {{VALUE}}',
286 ],
287 'condition' => [
288 'quantity_style' => [ 'style-1', 'style-2' ],
289 ],
290 ],
291 'quantity_wrapper_radius' => [
292 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
293 'size_units' => [ 'px', '%' ],
294 'type' => 'dimensions',
295 'selectors' => [
296 self::$selectors['quantity_wrapper_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
297 ],
298 'condition' => [
299 'quantity_style' => [ 'style-1', 'style-2' ],
300 ],
301 ],
302 'qunatity_wrapper_padding' => [
303 'label' => esc_html__( 'Padding', 'shopbuilder' ),
304 'type' => 'dimensions',
305 'mode' => 'responsive',
306 'size_units' => [ 'px', '%', 'em' ],
307 'selectors' => [
308 self::$selectors['qunatity_wrapper_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
309 ],
310 ],
311 'quantity_section_end' => [
312 'mode' => 'section_end',
313 ],
314 ];
315 return $fields;
316 }
317
318 /**
319 * Widget Field
320 *
321 * @return array
322 */
323 public static function variation_style_fields() {
324 $fields = [
325 'variation_section' => [
326 'mode' => 'section_start',
327 'tab' => 'style',
328 'label' => esc_html__( 'Variations', 'shopbuilder' ),
329 ],
330 'variation_label_heading' => [
331 'type' => 'html',
332 'raw' => sprintf(
333 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
334 esc_html__( 'Label', 'shopbuilder' )
335 ),
336 'content_classes' => 'elementor-panel-heading-title',
337 ],
338 'variation_label_typography' => [
339 'type' => 'typography',
340 'mode' => 'group',
341 'label' => esc_html__( 'Label Typography', 'shopbuilder' ),
342 'description' => esc_html__( 'Only for Variation Label.', 'shopbuilder' ),
343 'selector' => self::$selectors['variation_label_typography'],
344 ],
345 'variation_label_color' => [
346 'label' => esc_html__( 'Label Color', 'shopbuilder' ),
347 'type' => 'color',
348 'selectors' => [
349 self::$selectors['variation_label_color'] => 'color: {{VALUE}}',
350 ],
351 ],
352 'variation_label_margin' => [
353 'label' => esc_html__( 'Label Margin', 'shopbuilder' ),
354 'type' => 'dimensions',
355 'size_units' => [ 'px', '%', 'em' ],
356 'selectors' => [
357 self::$selectors['variation_label_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
358 ],
359 ],
360 'variation_stock_heading' => [
361 'type' => 'html',
362 'raw' => sprintf(
363 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
364 esc_html__( 'Stock', 'shopbuilder' )
365 ),
366 'content_classes' => 'elementor-panel-heading-title',
367 'separator' => 'before',
368 ],
369 'variation_stock_typography' => [
370 'type' => 'typography',
371 'mode' => 'group',
372 'label' => esc_html__( 'Stock Typography', 'shopbuilder' ),
373 'description' => esc_html__( 'Only for variation stock.', 'shopbuilder' ),
374 'selector' => self::$selectors['variation_stock_typography'],
375 ],
376 'variation_stock_color' => [
377 'label' => esc_html__( 'Stock Color', 'shopbuilder' ),
378 'type' => 'color',
379 'selectors' => [
380 self::$selectors['variation_stock_color'] => 'color: {{VALUE}}',
381 ],
382 ],
383 'variation_outofstock_color' => [
384 'label' => esc_html__( 'Out of Stock Color', 'shopbuilder' ),
385 'type' => 'color',
386 'selectors' => [
387 self::$selectors['variation_outofstock_color'] => 'color: {{VALUE}}',
388 ],
389 ],
390 'variation_swatch_heading' => [
391 'type' => 'html',
392 'raw' => sprintf(
393 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
394 esc_html__( 'Variation Items', 'shopbuilder' )
395 ),
396 'content_classes' => 'elementor-panel-heading-title',
397 'separator' => 'before',
398 ],
399 'variation_height' => [
400 'label' => esc_html__( 'Height', 'shopbuilder' ),
401 'type' => 'slider',
402 'range' => [
403 'px' => [
404 'min' => 10,
405 'max' => 200,
406 ],
407 ],
408 // 40px gives the label room to sit on its own line-height. The old 30px
409 // was fine on its own, but this widget also applies variation_padding to
410 // the same elements, and with border-box that left ~10px of content
411 // height — enough to squash/clip the term and select labels.
412 'default' => [
413 'unit' => 'px',
414 'size' => '40',
415 ],
416 'selectors' => [
417 self::$selectors['variation_height'] => 'height: {{SIZE}}{{UNIT}};',
418 ':root' => '--details-page-attr-height:{{SIZE}}{{UNIT}};',
419 ],
420 ],
421 'variation_width' => [
422 'label' => esc_html__( 'Min Width', 'shopbuilder' ),
423 'size_units' => [ 'px', '%' ],
424 'type' => 'slider',
425 'range' => [
426 'px' => [
427 'min' => 10,
428 'max' => 900,
429 ],
430 '%' => [
431 'min' => 0,
432 'max' => 100,
433 ],
434 ],
435 // Matches the height so single-character terms (S, M, L) stay square.
436 'default' => [
437 'unit' => 'px',
438 'size' => '40',
439 ],
440 'selectors' => [
441 self::$selectors['variation_width'] => 'min-width: {{SIZE}}{{UNIT}};',
442 ':root' => '--details-page-attr-width:{{SIZE}}{{UNIT}};',
443 ],
444 ],
445 'variation_padding' => [
446 'label' => esc_html__( 'Padding ', 'shopbuilder' ),
447 'description' => sprintf( '<span style="color:#e01e1e;">%s</span>', esc_html__( 'Note: Only for Select And Button Field.', 'shopbuilder' ) ),
448 'type' => 'dimensions',
449 'size_units' => [ 'px' ],
450 // Horizontal only. These elements already have a fixed height, so vertical
451 // padding fights it rather than adding breathing room — the label ends up
452 // squashed against the top/bottom edge (or clipped) instead of centred.
453 'default' => [
454 'top' => '0',
455 'right' => '10',
456 'bottom' => '0',
457 'left' => '10',
458 'unit' => 'px',
459 'isLinked' => false,
460 ],
461 'separator' => 'default',
462 'selectors' => [
463 self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
464 ':root' => '--variation-padding:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
465 ],
466 ],
467 'variation_border' => [
468 'mode' => 'group',
469 'type' => 'border',
470 'label' => esc_html__( 'Border', 'shopbuilder' ),
471 'selector' => self::$selectors['variation_border'],
472 ],
473 'variation_border_radius' => [
474 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
475 'size_units' => [ 'px', '%' ],
476 'type' => 'slider',
477 'selectors' => [
478 self::$selectors['variation_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
479 ':root' => '--variation-attr-border-radius:{{SIZE}}{{UNIT}};',
480 ],
481 ],
482 'variation_swatch_border_color' => [
483 'label' => esc_html__( 'Swatch Border Color', 'shopbuilder' ),
484 'type' => 'color',
485 'description' => esc_html__( 'Border color of the swatch items (Variation Swatches module).', 'shopbuilder' ),
486 'selectors' => [
487 self::$selectors['variation_swatch_border_color'] => '--attribute-border-color: {{VALUE}};',
488 ],
489 ],
490 'variation_swatch_selected_color' => [
491 'label' => esc_html__( 'Selected Swatch Border Color', 'shopbuilder' ),
492 'type' => 'color',
493 'description' => esc_html__( 'Border color of the hovered/selected swatch item.', 'shopbuilder' ),
494 'selectors' => [
495 self::$selectors['variation_swatch_selected_color'] => '--attribute-border-color-hover: {{VALUE}};',
496 ],
497 ],
498 'variation_item_margin' => [
499 'label' => esc_html__( 'Variation Item Margin', 'shopbuilder' ),
500 'type' => 'dimensions',
501 'size_units' => [ 'px', '%', 'em' ],
502 'selectors' => [
503 self::$selectors['variation_item_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
504 ],
505 ],
506 'variation_checkmark_heading' => [
507 'type' => 'html',
508 'raw' => sprintf(
509 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
510 esc_html__( 'Checkmark', 'shopbuilder' )
511 ),
512 'content_classes' => 'elementor-panel-heading-title',
513 'separator' => 'before',
514 ],
515 'variation_checkmark_bg_color' => [
516 'label' => esc_html__( 'Background Color', 'shopbuilder' ),
517 'type' => 'color',
518 'selectors' => [
519 self::$selectors['variation_checkmark_bg_color'] => '--checkmark-bg-color: {{VALUE}};',
520 ],
521 ],
522 'variation_checkmark_size' => [
523 'label' => esc_html__( 'Size', 'shopbuilder' ),
524 'type' => 'slider',
525 'size_units' => [ 'px' ],
526 'range' => [
527 'px' => [
528 'min' => 8,
529 'max' => 50,
530 ],
531 ],
532 'selectors' => [
533 self::$selectors['variation_checkmark_size'] => '--checkmark-width: {{SIZE}}{{UNIT}}; --checkmark-height: {{SIZE}}{{UNIT}};',
534 ],
535 ],
536 'variation_checkmark_icon_size' => [
537 'label' => esc_html__( 'Icon Size', 'shopbuilder' ),
538 'type' => 'slider',
539 'size_units' => [ 'px' ],
540 'range' => [
541 'px' => [
542 'min' => 6,
543 'max' => 40,
544 ],
545 ],
546 'selectors' => [
547 self::$selectors['variation_checkmark_icon_size'] => '--checkmark-font-size: {{SIZE}}{{UNIT}};',
548 ],
549 ],
550 'variation_clear_heading' => [
551 'type' => 'html',
552 'raw' => sprintf(
553 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
554 esc_html__( 'Clear Button', 'shopbuilder' )
555 ),
556 'content_classes' => 'elementor-panel-heading-title',
557 'separator' => 'before',
558 ],
559 'variation_clear_margin' => [
560 'label' => esc_html__( 'Margin', 'shopbuilder' ),
561 'type' => 'dimensions',
562 'size_units' => [ 'px', '%', 'em' ],
563 'selectors' => [
564 self::$selectors['variation_clear_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
565 ],
566 ],
567 'variation_clear_padding' => [
568 'label' => esc_html__( 'Padding', 'shopbuilder' ),
569 'type' => 'dimensions',
570 'size_units' => [ 'px', '%', 'em' ],
571 'selectors' => [
572 self::$selectors['variation_clear_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
573 ],
574 ],
575 'variation_section_end' => [
576 'mode' => 'section_end',
577 ],
578 ];
579 return $fields;
580 }
581
582 /**
583 * Widget Field
584 *
585 * @return array
586 */
587 public static function product_price_style_fields() {
588 return [
589 'price_section_style_start' => [
590 'mode' => 'section_start',
591 'tab' => 'style',
592 'label' => esc_html__( 'Price', 'shopbuilder' ),
593 ],
594 'price_typography' => [
595 'type' => 'typography',
596 'separator' => 'before',
597 'mode' => 'group',
598 'label' => esc_html__( 'Typography', 'shopbuilder' ),
599 'description' => esc_html__( 'Only for Variation Price', 'shopbuilder' ),
600 'selector' => self::$selectors['price_typography'],
601 ],
602 'price_color' => [
603 'label' => esc_html__( 'Color', 'shopbuilder' ),
604 'type' => 'color',
605 'selectors' => [
606 self::$selectors['price_color'] => 'color: {{VALUE}}',
607 ],
608 ],
609 'price_margin' => [
610 'label' => esc_html__( 'Margin', 'shopbuilder' ),
611 'type' => 'dimensions',
612 'size_units' => [ 'px' ],
613 'separator' => 'default',
614 'selectors' => [
615 self::$selectors['price_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
616 ],
617 ],
618 'price_section_style_end' => [
619 'mode' => 'section_end',
620 ],
621 ];
622 }
623 }
624