PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.65
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.65
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Woo_Shortcode_Cart / Woo_Shortcode_Cart.php

Woo_Shortcode_Cart.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.65, at includes/widgets/Woo_Shortcode_Cart/Woo_Shortcode_Cart.php

1,068 lines 35.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Shortcode Cart widget.
4 * Renders the standard WooCommerce [woocommerce_cart] shortcode.
5 *
6 * @package King_Addons
7 */
8
9 namespace King_Addons;
10
11 use Elementor\Controls_Manager;
12 use Elementor\Group_Control_Typography;
13 use Elementor\Group_Control_Border;
14 use Elementor\Group_Control_Box_Shadow;
15 use Elementor\Widget_Base;
16
17 if (!defined('ABSPATH')) {
18 exit;
19 }
20
21 /**
22 * Displays WooCommerce cart using the standard shortcode.
23 */
24 class Woo_Shortcode_Cart extends Widget_Base
25 {
26 /**
27 * Get widget name.
28 *
29 * @return string
30 */
31 public function get_name(): string
32 {
33 return 'woo_shortcode_cart';
34 }
35
36 /**
37 * Get widget title.
38 *
39 * @return string
40 */
41 public function get_title(): string
42 {
43 return esc_html__('WC Cart', 'king-addons');
44 }
45
46 /**
47 * Get widget icon.
48 *
49 * @return string
50 */
51 public function get_icon(): string
52 {
53 return 'eicon-cart';
54 }
55
56 /**
57 * Get widget categories.
58 *
59 * @return array<int,string>
60 */
61 public function get_categories(): array
62 {
63 return ['king-addons-woo-builder'];
64 }
65
66 /**
67 * Get widget keywords.
68 *
69 * @return array<int,string>
70 */
71 public function get_keywords(): array
72 {
73 return ['woocommerce', 'cart', 'shortcode', 'shop', 'basket'];
74 }
75
76 /**
77 * Register controls.
78 *
79 * @return void
80 */
81 public function get_custom_help_url()
82 {
83 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
84 }
85
86 protected function register_controls(): void
87 {
88 $this->start_controls_section(
89 'section_info',
90 [
91 'label' => esc_html__('Info', 'king-addons'),
92 'tab' => Controls_Manager::TAB_CONTENT,
93 ]
94 );
95
96 $this->add_control(
97 'info_notice',
98 [
99 'type' => Controls_Manager::RAW_HTML,
100 'raw' => sprintf(
101 '<div style="padding: 15px; background: #f0f6fc; border-left: 4px solid #2271b1; border-radius: 4px; color: #1d4ed8;">
102 <strong>%s</strong><br><br>%s
103 </div>',
104 esc_html__('WooCommerce Cart Shortcode', 'king-addons'),
105 esc_html__('This widget renders the standard WooCommerce cart page using the [woocommerce_cart] shortcode. It displays the full cart with all default WooCommerce styles and functionality.', 'king-addons')
106 ),
107 'content_classes' => 'elementor-panel-alert',
108 ]
109 );
110
111 $this->end_controls_section();
112
113 // =============================================
114 // STYLE TAB
115 // =============================================
116
117 // Cart Table Style
118 $this->start_controls_section(
119 'section_style_table',
120 [
121 'label' => esc_html__('Cart Table', 'king-addons'),
122 'tab' => Controls_Manager::TAB_STYLE,
123 ]
124 );
125
126 $this->add_control(
127 'table_bg_color',
128 [
129 'label' => esc_html__('Background Color', 'king-addons'),
130 'type' => Controls_Manager::COLOR,
131 'selectors' => [
132 '{{WRAPPER}} .woocommerce-cart-form table.shop_table' => 'background-color: {{VALUE}};',
133 ],
134 ]
135 );
136
137 $this->add_group_control(
138 Group_Control_Border::get_type(),
139 [
140 'name' => 'table_border',
141 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table',
142 ]
143 );
144
145 $this->add_responsive_control(
146 'table_border_radius',
147 [
148 'label' => esc_html__('Border Radius', 'king-addons'),
149 'type' => Controls_Manager::DIMENSIONS,
150 'size_units' => ['px', '%'],
151 'selectors' => [
152 '{{WRAPPER}} .woocommerce-cart-form table.shop_table' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
153 ],
154 ]
155 );
156
157 $this->end_controls_section();
158
159 // Table Header Style
160 $this->start_controls_section(
161 'section_style_header',
162 [
163 'label' => esc_html__('Table Header', 'king-addons'),
164 'tab' => Controls_Manager::TAB_STYLE,
165 ]
166 );
167
168 $this->add_control(
169 'header_bg_color',
170 [
171 'label' => esc_html__('Background Color', 'king-addons'),
172 'type' => Controls_Manager::COLOR,
173 'selectors' => [
174 '{{WRAPPER}} .woocommerce-cart-form table.shop_table thead th' => 'background-color: {{VALUE}};',
175 ],
176 ]
177 );
178
179 $this->add_control(
180 'header_text_color',
181 [
182 'label' => esc_html__('Text Color', 'king-addons'),
183 'type' => Controls_Manager::COLOR,
184 'selectors' => [
185 '{{WRAPPER}} .woocommerce-cart-form table.shop_table thead th' => 'color: {{VALUE}};',
186 ],
187 ]
188 );
189
190 $this->add_group_control(
191 Group_Control_Typography::get_type(),
192 [
193 'name' => 'header_typography',
194 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table thead th',
195 ]
196 );
197
198 $this->add_responsive_control(
199 'header_padding',
200 [
201 'label' => esc_html__('Padding', 'king-addons'),
202 'type' => Controls_Manager::DIMENSIONS,
203 'size_units' => ['px', 'em'],
204 'selectors' => [
205 '{{WRAPPER}} .woocommerce-cart-form table.shop_table thead th' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
206 ],
207 ]
208 );
209
210 $this->add_group_control(
211 Group_Control_Border::get_type(),
212 [
213 'name' => 'header_border',
214 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table thead th',
215 ]
216 );
217
218 $this->end_controls_section();
219
220 // Table Cells Style
221 $this->start_controls_section(
222 'section_style_cells',
223 [
224 'label' => esc_html__('Table Cells', 'king-addons'),
225 'tab' => Controls_Manager::TAB_STYLE,
226 ]
227 );
228
229 $this->add_control(
230 'cell_bg_color',
231 [
232 'label' => esc_html__('Background Color', 'king-addons'),
233 'type' => Controls_Manager::COLOR,
234 'selectors' => [
235 '{{WRAPPER}} .woocommerce-cart-form table.shop_table tbody td' => 'background-color: {{VALUE}};',
236 ],
237 ]
238 );
239
240 $this->add_control(
241 'cell_text_color',
242 [
243 'label' => esc_html__('Text Color', 'king-addons'),
244 'type' => Controls_Manager::COLOR,
245 'selectors' => [
246 '{{WRAPPER}} .woocommerce-cart-form table.shop_table tbody td' => 'color: {{VALUE}};',
247 ],
248 ]
249 );
250
251 $this->add_responsive_control(
252 'cell_padding',
253 [
254 'label' => esc_html__('Padding', 'king-addons'),
255 'type' => Controls_Manager::DIMENSIONS,
256 'size_units' => ['px', 'em'],
257 'selectors' => [
258 '{{WRAPPER}} .woocommerce-cart-form table.shop_table tbody td' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
259 ],
260 ]
261 );
262
263 $this->add_group_control(
264 Group_Control_Border::get_type(),
265 [
266 'name' => 'cell_border',
267 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table tbody td',
268 ]
269 );
270
271 $this->end_controls_section();
272
273 // Product Thumbnail Style
274 $this->start_controls_section(
275 'section_style_thumbnail',
276 [
277 'label' => esc_html__('Product Thumbnail', 'king-addons'),
278 'tab' => Controls_Manager::TAB_STYLE,
279 ]
280 );
281
282 $this->add_responsive_control(
283 'thumbnail_width',
284 [
285 'label' => esc_html__('Width', 'king-addons'),
286 'type' => Controls_Manager::SLIDER,
287 'size_units' => ['px'],
288 'range' => [
289 'px' => [
290 'min' => 30,
291 'max' => 200,
292 ],
293 ],
294 'selectors' => [
295 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-thumbnail img' => 'width: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}};',
296 ],
297 ]
298 );
299
300 $this->add_responsive_control(
301 'thumbnail_border_radius',
302 [
303 'label' => esc_html__('Border Radius', 'king-addons'),
304 'type' => Controls_Manager::DIMENSIONS,
305 'size_units' => ['px', '%'],
306 'selectors' => [
307 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-thumbnail img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
308 ],
309 ]
310 );
311
312 $this->end_controls_section();
313
314 // Remove Button Style
315 $this->start_controls_section(
316 'section_style_remove',
317 [
318 'label' => esc_html__('Remove Button', 'king-addons'),
319 'tab' => Controls_Manager::TAB_STYLE,
320 ]
321 );
322
323 $this->add_control(
324 'remove_color',
325 [
326 'label' => esc_html__('Color', 'king-addons'),
327 'type' => Controls_Manager::COLOR,
328 'selectors' => [
329 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-remove a.remove' => 'color: {{VALUE}} !important;',
330 ],
331 ]
332 );
333
334 $this->add_control(
335 'remove_hover_color',
336 [
337 'label' => esc_html__('Hover Color', 'king-addons'),
338 'type' => Controls_Manager::COLOR,
339 'selectors' => [
340 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-remove a.remove:hover' => 'color: {{VALUE}} !important;',
341 ],
342 ]
343 );
344
345 $this->add_control(
346 'remove_bg_color',
347 [
348 'label' => esc_html__('Background Color', 'king-addons'),
349 'type' => Controls_Manager::COLOR,
350 'selectors' => [
351 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-remove a.remove' => 'background-color: {{VALUE}};',
352 ],
353 ]
354 );
355
356 $this->add_control(
357 'remove_hover_bg_color',
358 [
359 'label' => esc_html__('Hover Background Color', 'king-addons'),
360 'type' => Controls_Manager::COLOR,
361 'selectors' => [
362 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-remove a.remove:hover' => 'background-color: {{VALUE}};',
363 ],
364 ]
365 );
366
367 $this->add_responsive_control(
368 'remove_size',
369 [
370 'label' => esc_html__('Size', 'king-addons'),
371 'type' => Controls_Manager::SLIDER,
372 'size_units' => ['px'],
373 'range' => [
374 'px' => [
375 'min' => 16,
376 'max' => 50,
377 ],
378 ],
379 'selectors' => [
380 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-remove a.remove' => 'font-size: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
381 ],
382 ]
383 );
384
385 $this->end_controls_section();
386
387 // Product Name Style
388 $this->start_controls_section(
389 'section_style_product_name',
390 [
391 'label' => esc_html__('Product Name', 'king-addons'),
392 'tab' => Controls_Manager::TAB_STYLE,
393 ]
394 );
395
396 $this->add_control(
397 'product_name_color',
398 [
399 'label' => esc_html__('Color', 'king-addons'),
400 'type' => Controls_Manager::COLOR,
401 'selectors' => [
402 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-name a' => 'color: {{VALUE}};',
403 ],
404 ]
405 );
406
407 $this->add_control(
408 'product_name_hover_color',
409 [
410 'label' => esc_html__('Hover Color', 'king-addons'),
411 'type' => Controls_Manager::COLOR,
412 'selectors' => [
413 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-name a:hover' => 'color: {{VALUE}};',
414 ],
415 ]
416 );
417
418 $this->add_group_control(
419 Group_Control_Typography::get_type(),
420 [
421 'name' => 'product_name_typography',
422 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-name a',
423 ]
424 );
425
426 $this->end_controls_section();
427
428 // Price Style
429 $this->start_controls_section(
430 'section_style_price',
431 [
432 'label' => esc_html__('Price', 'king-addons'),
433 'tab' => Controls_Manager::TAB_STYLE,
434 ]
435 );
436
437 $this->add_control(
438 'price_color',
439 [
440 'label' => esc_html__('Color', 'king-addons'),
441 'type' => Controls_Manager::COLOR,
442 'selectors' => [
443 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-price' => 'color: {{VALUE}};',
444 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-subtotal' => 'color: {{VALUE}};',
445 ],
446 ]
447 );
448
449 $this->add_group_control(
450 Group_Control_Typography::get_type(),
451 [
452 'name' => 'price_typography',
453 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-price, {{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-subtotal',
454 ]
455 );
456
457 $this->end_controls_section();
458
459 // Quantity Input Style
460 $this->start_controls_section(
461 'section_style_quantity',
462 [
463 'label' => esc_html__('Quantity Input', 'king-addons'),
464 'tab' => Controls_Manager::TAB_STYLE,
465 ]
466 );
467
468 $this->add_control(
469 'quantity_bg_color',
470 [
471 'label' => esc_html__('Background Color', 'king-addons'),
472 'type' => Controls_Manager::COLOR,
473 'selectors' => [
474 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty' => 'background-color: {{VALUE}};',
475 ],
476 ]
477 );
478
479 $this->add_control(
480 'quantity_text_color',
481 [
482 'label' => esc_html__('Text Color', 'king-addons'),
483 'type' => Controls_Manager::COLOR,
484 'selectors' => [
485 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty' => 'color: {{VALUE}};',
486 ],
487 ]
488 );
489
490 $this->add_group_control(
491 Group_Control_Border::get_type(),
492 [
493 'name' => 'quantity_border',
494 'selector' => '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty',
495 ]
496 );
497
498 $this->add_responsive_control(
499 'quantity_border_radius',
500 [
501 'label' => esc_html__('Border Radius', 'king-addons'),
502 'type' => Controls_Manager::DIMENSIONS,
503 'size_units' => ['px', '%'],
504 'selectors' => [
505 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
506 ],
507 ]
508 );
509
510 $this->add_responsive_control(
511 'quantity_padding',
512 [
513 'label' => esc_html__('Padding', 'king-addons'),
514 'type' => Controls_Manager::DIMENSIONS,
515 'size_units' => ['px', 'em'],
516 'selectors' => [
517 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
518 ],
519 ]
520 );
521
522 $this->add_responsive_control(
523 'quantity_width',
524 [
525 'label' => esc_html__('Width', 'king-addons'),
526 'type' => Controls_Manager::SLIDER,
527 'size_units' => ['px'],
528 'range' => [
529 'px' => [
530 'min' => 40,
531 'max' => 150,
532 ],
533 ],
534 'selectors' => [
535 '{{WRAPPER}} .woocommerce-cart-form table.shop_table td.product-quantity .quantity .qty' => 'width: {{SIZE}}{{UNIT}};',
536 ],
537 ]
538 );
539
540 $this->end_controls_section();
541
542 // Update Cart Button Style
543 $this->start_controls_section(
544 'section_style_update_button',
545 [
546 'label' => esc_html__('Update Cart Button', 'king-addons'),
547 'tab' => Controls_Manager::TAB_STYLE,
548 ]
549 );
550
551 $this->start_controls_tabs('update_button_tabs');
552
553 $this->start_controls_tab(
554 'update_button_normal',
555 [
556 'label' => esc_html__('Normal', 'king-addons'),
557 ]
558 );
559
560 $this->add_control(
561 'update_button_text_color',
562 [
563 'label' => esc_html__('Text Color', 'king-addons'),
564 'type' => Controls_Manager::COLOR,
565 'selectors' => [
566 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]' => 'color: {{VALUE}};',
567 ],
568 ]
569 );
570
571 $this->add_control(
572 'update_button_bg_color',
573 [
574 'label' => esc_html__('Background Color', 'king-addons'),
575 'type' => Controls_Manager::COLOR,
576 'selectors' => [
577 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]' => 'background-color: {{VALUE}};',
578 ],
579 ]
580 );
581
582 $this->end_controls_tab();
583
584 $this->start_controls_tab(
585 'update_button_hover',
586 [
587 'label' => esc_html__('Hover', 'king-addons'),
588 ]
589 );
590
591 $this->add_control(
592 'update_button_hover_text_color',
593 [
594 'label' => esc_html__('Text Color', 'king-addons'),
595 'type' => Controls_Manager::COLOR,
596 'selectors' => [
597 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]:hover' => 'color: {{VALUE}};',
598 ],
599 ]
600 );
601
602 $this->add_control(
603 'update_button_hover_bg_color',
604 [
605 'label' => esc_html__('Background Color', 'king-addons'),
606 'type' => Controls_Manager::COLOR,
607 'selectors' => [
608 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]:hover' => 'background-color: {{VALUE}};',
609 ],
610 ]
611 );
612
613 $this->end_controls_tab();
614
615 $this->end_controls_tabs();
616
617 $this->add_group_control(
618 Group_Control_Typography::get_type(),
619 [
620 'name' => 'update_button_typography',
621 'selector' => '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]',
622 'separator' => 'before',
623 ]
624 );
625
626 $this->add_responsive_control(
627 'update_button_padding',
628 [
629 'label' => esc_html__('Padding', 'king-addons'),
630 'type' => Controls_Manager::DIMENSIONS,
631 'size_units' => ['px', 'em'],
632 'selectors' => [
633 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
634 ],
635 ]
636 );
637
638 $this->add_responsive_control(
639 'update_button_border_radius',
640 [
641 'label' => esc_html__('Border Radius', 'king-addons'),
642 'type' => Controls_Manager::DIMENSIONS,
643 'size_units' => ['px', '%'],
644 'selectors' => [
645 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
646 ],
647 ]
648 );
649
650 $this->add_group_control(
651 Group_Control_Border::get_type(),
652 [
653 'name' => 'update_button_border',
654 'selector' => '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]',
655 ]
656 );
657
658 $this->add_responsive_control(
659 'update_button_margin',
660 [
661 'label' => esc_html__('Margin', 'king-addons'),
662 'type' => Controls_Manager::DIMENSIONS,
663 'size_units' => ['px', 'em'],
664 'selectors' => [
665 '{{WRAPPER}} .woocommerce-cart-form button[name="update_cart"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
666 ],
667 ]
668 );
669
670 $this->end_controls_section();
671
672 // Coupon Field Style
673 $this->start_controls_section(
674 'section_style_coupon',
675 [
676 'label' => esc_html__('Coupon Field', 'king-addons'),
677 'tab' => Controls_Manager::TAB_STYLE,
678 ]
679 );
680
681 $this->add_control(
682 'coupon_field_bg_color',
683 [
684 'label' => esc_html__('Input Background', 'king-addons'),
685 'type' => Controls_Manager::COLOR,
686 'selectors' => [
687 '{{WRAPPER}} .woocommerce-cart-form .coupon input.input-text' => 'background-color: {{VALUE}};',
688 ],
689 ]
690 );
691
692 $this->add_control(
693 'coupon_field_text_color',
694 [
695 'label' => esc_html__('Input Text Color', 'king-addons'),
696 'type' => Controls_Manager::COLOR,
697 'selectors' => [
698 '{{WRAPPER}} .woocommerce-cart-form .coupon input.input-text' => 'color: {{VALUE}};',
699 ],
700 ]
701 );
702
703 $this->add_group_control(
704 Group_Control_Border::get_type(),
705 [
706 'name' => 'coupon_field_border',
707 'selector' => '{{WRAPPER}} .woocommerce-cart-form .coupon input.input-text',
708 ]
709 );
710
711 $this->add_control(
712 'coupon_button_heading',
713 [
714 'label' => esc_html__('Apply Coupon Button', 'king-addons'),
715 'type' => Controls_Manager::HEADING,
716 'separator' => 'before',
717 ]
718 );
719
720 $this->add_control(
721 'coupon_button_text_color',
722 [
723 'label' => esc_html__('Text Color', 'king-addons'),
724 'type' => Controls_Manager::COLOR,
725 'selectors' => [
726 '{{WRAPPER}} .woocommerce-cart-form .coupon button[name="apply_coupon"]' => 'color: {{VALUE}};',
727 ],
728 ]
729 );
730
731 $this->add_control(
732 'coupon_button_bg_color',
733 [
734 'label' => esc_html__('Background Color', 'king-addons'),
735 'type' => Controls_Manager::COLOR,
736 'selectors' => [
737 '{{WRAPPER}} .woocommerce-cart-form .coupon button[name="apply_coupon"]' => 'background-color: {{VALUE}};',
738 ],
739 ]
740 );
741
742 $this->add_group_control(
743 Group_Control_Typography::get_type(),
744 [
745 'name' => 'coupon_button_typography',
746 'selector' => '{{WRAPPER}} .woocommerce-cart-form .coupon button[name="apply_coupon"]',
747 ]
748 );
749
750 $this->add_responsive_control(
751 'coupon_button_padding',
752 [
753 'label' => esc_html__('Button Padding', 'king-addons'),
754 'type' => Controls_Manager::DIMENSIONS,
755 'size_units' => ['px', 'em'],
756 'selectors' => [
757 '{{WRAPPER}} .woocommerce-cart-form .coupon button[name="apply_coupon"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
758 ],
759 ]
760 );
761
762 $this->add_responsive_control(
763 'coupon_button_border_radius',
764 [
765 'label' => esc_html__('Button Border Radius', 'king-addons'),
766 'type' => Controls_Manager::DIMENSIONS,
767 'size_units' => ['px', '%'],
768 'selectors' => [
769 '{{WRAPPER}} .woocommerce-cart-form .coupon button[name="apply_coupon"]' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
770 ],
771 ]
772 );
773
774 $this->add_responsive_control(
775 'coupon_input_padding',
776 [
777 'label' => esc_html__('Input Padding', 'king-addons'),
778 'type' => Controls_Manager::DIMENSIONS,
779 'size_units' => ['px', 'em'],
780 'separator' => 'before',
781 'selectors' => [
782 '{{WRAPPER}} .woocommerce-cart-form .coupon input.input-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
783 ],
784 ]
785 );
786
787 $this->add_responsive_control(
788 'coupon_input_border_radius',
789 [
790 'label' => esc_html__('Input Border Radius', 'king-addons'),
791 'type' => Controls_Manager::DIMENSIONS,
792 'size_units' => ['px', '%'],
793 'selectors' => [
794 '{{WRAPPER}} .woocommerce-cart-form .coupon input.input-text' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
795 ],
796 ]
797 );
798
799 $this->end_controls_section();
800
801 // Cart Totals Style
802 $this->start_controls_section(
803 'section_style_totals',
804 [
805 'label' => esc_html__('Cart Totals', 'king-addons'),
806 'tab' => Controls_Manager::TAB_STYLE,
807 ]
808 );
809
810 $this->add_control(
811 'totals_bg_color',
812 [
813 'label' => esc_html__('Background Color', 'king-addons'),
814 'type' => Controls_Manager::COLOR,
815 'selectors' => [
816 '{{WRAPPER}} .cart_totals' => 'background-color: {{VALUE}};',
817 ],
818 ]
819 );
820
821 $this->add_responsive_control(
822 'totals_padding',
823 [
824 'label' => esc_html__('Padding', 'king-addons'),
825 'type' => Controls_Manager::DIMENSIONS,
826 'size_units' => ['px', 'em'],
827 'selectors' => [
828 '{{WRAPPER}} .cart_totals' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
829 ],
830 ]
831 );
832
833 $this->add_group_control(
834 Group_Control_Border::get_type(),
835 [
836 'name' => 'totals_border',
837 'selector' => '{{WRAPPER}} .cart_totals',
838 ]
839 );
840
841 $this->add_responsive_control(
842 'totals_border_radius',
843 [
844 'label' => esc_html__('Border Radius', 'king-addons'),
845 'type' => Controls_Manager::DIMENSIONS,
846 'size_units' => ['px', '%'],
847 'selectors' => [
848 '{{WRAPPER}} .cart_totals' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
849 ],
850 ]
851 );
852
853 $this->add_control(
854 'totals_heading_color',
855 [
856 'label' => esc_html__('Heading Color', 'king-addons'),
857 'type' => Controls_Manager::COLOR,
858 'selectors' => [
859 '{{WRAPPER}} .cart_totals h2' => 'color: {{VALUE}};',
860 ],
861 'separator' => 'before',
862 ]
863 );
864
865 $this->add_group_control(
866 Group_Control_Typography::get_type(),
867 [
868 'name' => 'totals_heading_typography',
869 'label' => esc_html__('Heading Typography', 'king-addons'),
870 'selector' => '{{WRAPPER}} .cart_totals h2',
871 ]
872 );
873
874 $this->add_control(
875 'totals_label_color',
876 [
877 'label' => esc_html__('Label Color', 'king-addons'),
878 'type' => Controls_Manager::COLOR,
879 'selectors' => [
880 '{{WRAPPER}} .cart_totals table th' => 'color: {{VALUE}};',
881 ],
882 'separator' => 'before',
883 ]
884 );
885
886 $this->add_control(
887 'totals_value_color',
888 [
889 'label' => esc_html__('Value Color', 'king-addons'),
890 'type' => Controls_Manager::COLOR,
891 'selectors' => [
892 '{{WRAPPER}} .cart_totals table td' => 'color: {{VALUE}};',
893 '{{WRAPPER}} .cart_totals table td .woocommerce-Price-amount' => 'color: {{VALUE}};',
894 ],
895 ]
896 );
897
898 $this->end_controls_section();
899
900 // Checkout Button Style
901 $this->start_controls_section(
902 'section_style_checkout_button',
903 [
904 'label' => esc_html__('Proceed to Checkout Button', 'king-addons'),
905 'tab' => Controls_Manager::TAB_STYLE,
906 ]
907 );
908
909 $this->start_controls_tabs('checkout_button_tabs');
910
911 $this->start_controls_tab(
912 'checkout_button_normal',
913 [
914 'label' => esc_html__('Normal', 'king-addons'),
915 ]
916 );
917
918 $this->add_control(
919 'checkout_button_text_color',
920 [
921 'label' => esc_html__('Text Color', 'king-addons'),
922 'type' => Controls_Manager::COLOR,
923 'selectors' => [
924 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'color: {{VALUE}};',
925 ],
926 ]
927 );
928
929 $this->add_control(
930 'checkout_button_bg_color',
931 [
932 'label' => esc_html__('Background Color', 'king-addons'),
933 'type' => Controls_Manager::COLOR,
934 'selectors' => [
935 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'background-color: {{VALUE}};',
936 ],
937 ]
938 );
939
940 $this->end_controls_tab();
941
942 $this->start_controls_tab(
943 'checkout_button_hover',
944 [
945 'label' => esc_html__('Hover', 'king-addons'),
946 ]
947 );
948
949 $this->add_control(
950 'checkout_button_hover_text_color',
951 [
952 'label' => esc_html__('Text Color', 'king-addons'),
953 'type' => Controls_Manager::COLOR,
954 'selectors' => [
955 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button:hover' => 'color: {{VALUE}};',
956 ],
957 ]
958 );
959
960 $this->add_control(
961 'checkout_button_hover_bg_color',
962 [
963 'label' => esc_html__('Background Color', 'king-addons'),
964 'type' => Controls_Manager::COLOR,
965 'selectors' => [
966 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button:hover' => 'background-color: {{VALUE}};',
967 ],
968 ]
969 );
970
971 $this->end_controls_tab();
972
973 $this->end_controls_tabs();
974
975 $this->add_group_control(
976 Group_Control_Typography::get_type(),
977 [
978 'name' => 'checkout_button_typography',
979 'selector' => '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button',
980 'separator' => 'before',
981 ]
982 );
983
984 $this->add_responsive_control(
985 'checkout_button_padding',
986 [
987 'label' => esc_html__('Padding', 'king-addons'),
988 'type' => Controls_Manager::DIMENSIONS,
989 'size_units' => ['px', 'em'],
990 'selectors' => [
991 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
992 ],
993 ]
994 );
995
996 $this->add_responsive_control(
997 'checkout_button_border_radius',
998 [
999 'label' => esc_html__('Border Radius', 'king-addons'),
1000 'type' => Controls_Manager::DIMENSIONS,
1001 'size_units' => ['px', '%'],
1002 'selectors' => [
1003 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1004 ],
1005 ]
1006 );
1007
1008 $this->add_group_control(
1009 Group_Control_Border::get_type(),
1010 [
1011 'name' => 'checkout_button_border',
1012 'selector' => '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button',
1013 ]
1014 );
1015
1016 $this->add_responsive_control(
1017 'checkout_button_margin',
1018 [
1019 'label' => esc_html__('Margin', 'king-addons'),
1020 'type' => Controls_Manager::DIMENSIONS,
1021 'size_units' => ['px', 'em'],
1022 'selectors' => [
1023 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1024 ],
1025 ]
1026 );
1027
1028 $this->add_control(
1029 'checkout_button_full_width',
1030 [
1031 'label' => esc_html__('Full Width', 'king-addons'),
1032 'type' => Controls_Manager::SWITCHER,
1033 'selectors' => [
1034 '{{WRAPPER}} .wc-proceed-to-checkout a.checkout-button' => 'width: 100%; display: block; text-align: center;',
1035 ],
1036 ]
1037 );
1038
1039 $this->end_controls_section();
1040 }
1041
1042 /**
1043 * Render widget output.
1044 *
1045 * @return void
1046 */
1047 protected function render(): void
1048 {
1049 if (!class_exists('WooCommerce')) {
1050 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
1051 echo '<div class="king-addons-woo-builder-notice">' . esc_html__('WooCommerce is required for this widget.', 'king-addons') . '</div>';
1052 }
1053 return;
1054 }
1055
1056 // In editor mode, add some context
1057 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
1058 // Ensure WC session and cart are available
1059 if (is_null(WC()->cart)) {
1060 wc_load_cart();
1061 }
1062 }
1063
1064 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1065 echo do_shortcode('[woocommerce_cart]');
1066 }
1067 }
1068