PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.2.0
ShopBuilder – WooCommerce Builder For Elementor v2.2.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.2.0, at app/Elementor/Widgets/Controls/AddToCartSettings.php

492 lines 14.3 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 'selectors' => [
375 self::$selectors['variation_height'] => 'height: {{SIZE}}{{UNIT}};',
376 ],
377 ],
378 'variation_width' => [
379 'label' => esc_html__( 'Width', 'shopbuilder' ),
380 'size_units' => [ 'px', '%' ],
381 'type' => 'slider',
382 'range' => [
383 'px' => [
384 'min' => 10,
385 'max' => 900,
386 ],
387 '%' => [
388 'min' => 0,
389 'max' => 100,
390 ],
391 ],
392 'selectors' => [
393 self::$selectors['variation_width'] => 'width: {{SIZE}}{{UNIT}};',
394 ],
395 ],
396 'variation_border' => [
397 'mode' => 'group',
398 'type' => 'border',
399 'label' => esc_html__( 'Quantity Border', 'shopbuilder' ),
400 'selector' => self::$selectors['variation_border'],
401 ],
402 'variation_border_radius' => [
403 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
404 'size_units' => [ 'px', '%' ],
405 'type' => 'slider',
406 'selectors' => [
407 self::$selectors['variation_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
408 ],
409 ],
410 'variation_padding' => [
411 'label' => esc_html__( 'Padding', 'shopbuilder' ),
412 'type' => 'dimensions',
413 'size_units' => [ 'px' ],
414 'default' => [
415 'top' => '10',
416 'right' => '10',
417 'bottom' => '10',
418 'left' => '10',
419 'unit' => 'px',
420 'isLinked' => true,
421 ],
422 'separator' => 'default',
423 'selectors' => [
424 self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
425 ],
426 ],
427 'variation_label_margin' => [
428 'label' => esc_html__( 'Label Margin', 'shopbuilder' ),
429 'type' => 'dimensions',
430 'size_units' => [ 'px', '%', 'em' ],
431 'selectors' => [
432 self::$selectors['variation_label_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
433 ],
434 ],
435 'variation_item_margin' => [
436 'label' => esc_html__( 'Variation Item Margin', 'shopbuilder' ),
437 'type' => 'dimensions',
438 'size_units' => [ 'px', '%', 'em' ],
439 'selectors' => [
440 self::$selectors['variation_item_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
441 ],
442 ],
443 'variation_section_end' => [
444 'mode' => 'section_end',
445 ],
446 ];
447 return $fields;
448 }
449
450 /**
451 * Widget Field
452 *
453 * @return array
454 */
455 public static function product_price_style_fields() {
456 return [
457 'price_section_style_start' => [
458 'mode' => 'section_start',
459 'tab' => 'style',
460 'label' => esc_html__( 'Price', 'shopbuilder' ),
461 ],
462 'price_typography' => [
463 'type' => 'typography',
464 'separator' => 'before',
465 'mode' => 'group',
466 'label' => esc_html__( 'Typography', 'shopbuilder' ),
467 'description' => esc_html__( 'Only for Variation Price', 'shopbuilder' ),
468 'selector' => self::$selectors['price_typography'],
469 ],
470 'price_color' => [
471 'label' => esc_html__( 'Color', 'shopbuilder' ),
472 'type' => 'color',
473 'selectors' => [
474 self::$selectors['price_color'] => 'color: {{VALUE}}',
475 ],
476 ],
477 'price_margin' => [
478 'label' => esc_html__( 'Margin', 'shopbuilder' ),
479 'type' => 'dimensions',
480 'size_units' => [ 'px' ],
481 'separator' => 'default',
482 'selectors' => [
483 self::$selectors['price_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
484 ],
485 ],
486 'price_section_style_end' => [
487 'mode' => 'section_end',
488 ],
489 ];
490 }
491 }
492