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

507 lines 15.0 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_typography' => [
331 'type' => 'typography',
332 'separator' => 'before',
333 'mode' => 'group',
334 'label' => esc_html__( 'Label Typography', 'shopbuilder' ),
335 'description' => esc_html__( 'Only for Variation Label.', 'shopbuilder' ),
336 'selector' => self::$selectors['variation_label_typography'],
337 ],
338 'variation_stock_typography' => [
339 'type' => 'typography',
340 'separator' => 'before',
341 'mode' => 'group',
342 'label' => esc_html__( 'Stock Typography', 'shopbuilder' ),
343 'description' => esc_html__( 'Only for variation stock.', 'shopbuilder' ),
344 'selector' => self::$selectors['variation_stock_typography'],
345 ],
346 'variation_label_color' => [
347 'label' => esc_html__( 'Label Color', 'shopbuilder' ),
348 'type' => 'color',
349 'selectors' => [
350 self::$selectors['variation_label_color'] => 'color: {{VALUE}}',
351 ],
352 ],
353 'variation_stock_color' => [
354 'label' => esc_html__( 'Stock Color', 'shopbuilder' ),
355 'type' => 'color',
356 'selectors' => [
357 self::$selectors['variation_stock_color'] => 'color: {{VALUE}}',
358 ],
359 ],
360 'variation_outofstock_color' => [
361 'label' => esc_html__( 'Out of Stock Color', 'shopbuilder' ),
362 'type' => 'color',
363 'selectors' => [
364 self::$selectors['variation_outofstock_color'] => 'color: {{VALUE}}',
365 ],
366 ],
367 'variation_height' => [
368 'label' => esc_html__( 'Height', 'shopbuilder' ),
369 'type' => 'slider',
370 'range' => [
371 'px' => [
372 'min' => 10,
373 'max' => 200,
374 ],
375 ],
376 'default' => [
377 'unit' => 'px',
378 'size' => '30',
379 ],
380 'selectors' => [
381 self::$selectors['variation_height'] => 'height: {{SIZE}}{{UNIT}};',
382 ':root' => '--details-page-attr-height:{{SIZE}}{{UNIT}};',
383 ],
384 ],
385 'variation_width' => [
386 'label' => esc_html__( 'Min Width', 'shopbuilder' ),
387 'size_units' => [ 'px', '%' ],
388 'type' => 'slider',
389 'range' => [
390 'px' => [
391 'min' => 10,
392 'max' => 900,
393 ],
394 '%' => [
395 'min' => 0,
396 'max' => 100,
397 ],
398 ],
399 'default' => [
400 'unit' => 'px',
401 'size' => '30',
402 ],
403 'selectors' => [
404 self::$selectors['variation_width'] => 'min-width: {{SIZE}}{{UNIT}};',
405 ':root' => '--details-page-attr-width:{{SIZE}}{{UNIT}};',
406 ],
407 ],
408 'variation_border' => [
409 'mode' => 'group',
410 'type' => 'border',
411 'label' => esc_html__( 'Quantity Border', 'shopbuilder' ),
412 'selector' => self::$selectors['variation_border'],
413 ],
414 'variation_border_radius' => [
415 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
416 'size_units' => [ 'px', '%' ],
417 'type' => 'slider',
418 'selectors' => [
419 self::$selectors['variation_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
420 ':root' => '--variation-attr-border-radius:{{SIZE}}{{UNIT}};',
421 ],
422 ],
423 'variation_padding' => [
424 'label' => esc_html__( 'Padding ', 'shopbuilder' ),
425 'description' => esc_html__( 'Note: Only for Select And Button Field.', 'shopbuilder' ),
426 'type' => 'dimensions',
427 'size_units' => [ 'px' ],
428 'default' => [
429 'top' => '10',
430 'right' => '10',
431 'bottom' => '10',
432 'left' => '10',
433 'unit' => 'px',
434 'isLinked' => true,
435 ],
436 'separator' => 'default',
437 'selectors' => [
438 self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
439 ':root' => '--variation-padding:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
440 ],
441 ],
442 'variation_label_margin' => [
443 'label' => esc_html__( 'Label Margin', 'shopbuilder' ),
444 'type' => 'dimensions',
445 'size_units' => [ 'px', '%', 'em' ],
446 'selectors' => [
447 self::$selectors['variation_label_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
448 ],
449 ],
450 'variation_item_margin' => [
451 'label' => esc_html__( 'Variation Item Margin', 'shopbuilder' ),
452 'type' => 'dimensions',
453 'size_units' => [ 'px', '%', 'em' ],
454 'selectors' => [
455 self::$selectors['variation_item_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
456 ],
457 ],
458 'variation_section_end' => [
459 'mode' => 'section_end',
460 ],
461 ];
462 return $fields;
463 }
464
465 /**
466 * Widget Field
467 *
468 * @return array
469 */
470 public static function product_price_style_fields() {
471 return [
472 'price_section_style_start' => [
473 'mode' => 'section_start',
474 'tab' => 'style',
475 'label' => esc_html__( 'Price', 'shopbuilder' ),
476 ],
477 'price_typography' => [
478 'type' => 'typography',
479 'separator' => 'before',
480 'mode' => 'group',
481 'label' => esc_html__( 'Typography', 'shopbuilder' ),
482 'description' => esc_html__( 'Only for Variation Price', 'shopbuilder' ),
483 'selector' => self::$selectors['price_typography'],
484 ],
485 'price_color' => [
486 'label' => esc_html__( 'Color', 'shopbuilder' ),
487 'type' => 'color',
488 'selectors' => [
489 self::$selectors['price_color'] => 'color: {{VALUE}}',
490 ],
491 ],
492 'price_margin' => [
493 'label' => esc_html__( 'Margin', 'shopbuilder' ),
494 'type' => 'dimensions',
495 'size_units' => [ 'px' ],
496 'separator' => 'default',
497 'selectors' => [
498 self::$selectors['price_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
499 ],
500 ],
501 'price_section_style_end' => [
502 'mode' => 'section_end',
503 ],
504 ];
505 }
506 }
507