PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.87
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.87
51.1.87 51.1.86 51.1.84 51.1.85 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 All 41 releases
king-addons / includes / widgets / Woo_Shortcode_Cart / Woo_Shortcode_Cart.php

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

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