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_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.87, at includes/widgets/Woo_Checkout_Coupon/Woo_Checkout_Coupon.php

159 lines 3.7 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 * Script dependencies.
74 *
75 * @return array<int, string>
76 */
77 public function get_script_depends(): array
78 {
79 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-coupon-script'];
80 }
81
82 /**
83 * Register controls.
84 *
85 * @return void
86 */
87 protected function register_controls(): void
88 {
89 $this->start_controls_section(
90 'section_style',
91 [
92 'label' => esc_html__('Style', 'king-addons'),
93 'tab' => Controls_Manager::TAB_STYLE,
94 ]
95 );
96
97 $this->add_group_control(
98 Group_Control_Typography::get_type(),
99 [
100 'name' => 'text_typography',
101 'selector' => '{{WRAPPER}} .ka-woo-checkout-coupon',
102 ]
103 );
104
105 $this->add_control(
106 'text_color',
107 [
108 'label' => esc_html__('Text Color', 'king-addons'),
109 'type' => Controls_Manager::COLOR,
110 'selectors' => [
111 '{{WRAPPER}} .ka-woo-checkout-coupon, {{WRAPPER}} .ka-woo-checkout-coupon a, {{WRAPPER}} .ka-woo-checkout-coupon .woocommerce-form-coupon-toggle' => 'color: {{VALUE}};',
112 ],
113 ]
114 );
115
116 $this->end_controls_section();
117 }
118
119 /**
120 * Render widget output.
121 *
122 * @return void
123 */
124 protected function render(): void
125 {
126 if (!$this->should_render()) {
127 $this->render_missing_checkout_notice();
128 return;
129 }
130
131 // woocommerce_checkout_coupon_form() prints nothing when coupons are
132 // disabled in WooCommerce.
133 // An empty wrapper on the page - and a blank box in the editor -
134 // reads as a broken widget rather than a context that has nothing
135 // to show.
136 ob_start();
137 woocommerce_checkout_coupon_form();
138 $output = trim((string) ob_get_clean());
139
140 if ('' === $output) {
141 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
142 echo '<div class="king-addons-woo-builder-notice">'
143 . esc_html__('The coupon form appears when coupons are enabled in WooCommerce.', 'king-addons')
144 . '</div>';
145 }
146 return;
147 }
148
149 // WooCommerce's own markup, not user input.
150 echo '<div class="ka-woo-checkout-coupon">' . $output . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151 }
152 }
153
154
155
156
157
158
159