PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.85
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.85
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_Checkout_Coupon / Woo_Checkout_Coupon.php

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

149 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Checkout Coupon widget.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Displays checkout coupon form.
19 */
20 class Woo_Checkout_Coupon extends Abstract_Checkout_Widget
21 {
22 /**
23 * Widget slug.
24 *
25 * @return string
26 */
27 public function get_name(): string
28 {
29 return 'woo_checkout_coupon';
30 }
31
32 /**
33 * Widget title.
34 *
35 * @return string
36 */
37 public function get_title(): string
38 {
39 return esc_html__('Checkout Coupon', 'king-addons');
40 }
41
42 /**
43 * Widget icon.
44 *
45 * @return string
46 */
47 public function get_icon(): string
48 {
49 return 'king-addons-icon king-addons-woo-checkout-coupon';
50 }
51
52 /**
53 * Categories.
54 *
55 * @return array<int, string>
56 */
57 public function get_categories(): array
58 {
59 return ['king-addons-woo-builder'];
60 }
61
62 /**
63 * Style dependencies.
64 *
65 * @return array<int, string>
66 */
67 public function get_style_depends(): array
68 {
69 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-coupon-style'];
70 }
71
72 /**
73 * Register controls.
74 *
75 * @return void
76 */
77 protected function register_controls(): void
78 {
79 $this->start_controls_section(
80 'section_style',
81 [
82 'label' => esc_html__('Style', 'king-addons'),
83 'tab' => Controls_Manager::TAB_STYLE,
84 ]
85 );
86
87 $this->add_group_control(
88 Group_Control_Typography::get_type(),
89 [
90 'name' => 'text_typography',
91 'selector' => '{{WRAPPER}} .ka-woo-checkout-coupon',
92 ]
93 );
94
95 $this->add_control(
96 'text_color',
97 [
98 'label' => esc_html__('Text Color', 'king-addons'),
99 'type' => Controls_Manager::COLOR,
100 'selectors' => [
101 '{{WRAPPER}} .ka-woo-checkout-coupon, {{WRAPPER}} .ka-woo-checkout-coupon a, {{WRAPPER}} .ka-woo-checkout-coupon .woocommerce-form-coupon-toggle' => 'color: {{VALUE}};',
102 ],
103 ]
104 );
105
106 $this->end_controls_section();
107 }
108
109 /**
110 * Render widget output.
111 *
112 * @return void
113 */
114 protected function render(): void
115 {
116 if (!$this->should_render()) {
117 $this->render_missing_checkout_notice();
118 return;
119 }
120
121 // woocommerce_checkout_coupon_form() prints nothing when coupons are
122 // disabled in WooCommerce.
123 // An empty wrapper on the page - and a blank box in the editor -
124 // reads as a broken widget rather than a context that has nothing
125 // to show.
126 ob_start();
127 woocommerce_checkout_coupon_form();
128 $output = trim((string) ob_get_clean());
129
130 if ('' === $output) {
131 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
132 echo '<div class="king-addons-woo-builder-notice">'
133 . esc_html__('The coupon form appears when coupons are enabled in WooCommerce.', 'king-addons')
134 . '</div>';
135 }
136 return;
137 }
138
139 // WooCommerce's own markup, not user input.
140 echo '<div class="ka-woo-checkout-coupon">' . $output . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
141 }
142 }
143
144
145
146
147
148
149