PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.83
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.83
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.83, at includes/widgets/Woo_Shortcode_Cart/Woo_Shortcode_Cart.php

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