PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.86
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.86
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 51.1.45 All 40 releases
king-addons / includes / widgets / Woo_Checkout_Place_Order / Woo_Checkout_Place_Order.php

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

240 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Checkout Place Order Button widget.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Border;
12 use Elementor\Group_Control_Box_Shadow;
13 use Elementor\Group_Control_Typography;
14
15 if (!defined('ABSPATH')) {
16 exit;
17 }
18
19 /**
20 * Renders standalone place order button.
21 */
22 class Woo_Checkout_Place_Order extends Abstract_Checkout_Widget
23 {
24 /**
25 * Widget slug.
26 *
27 * @return string
28 */
29 public function get_name(): string
30 {
31 return 'woo_checkout_place_order';
32 }
33
34 /**
35 * Widget title.
36 *
37 * @return string
38 */
39 public function get_title(): string
40 {
41 return esc_html__('Checkout Place Order Button', 'king-addons');
42 }
43
44 /**
45 * Widget icon.
46 *
47 * @return string
48 */
49 public function get_icon(): string
50 {
51 return 'king-addons-icon king-addons-woo-checkout-place-order';
52 }
53
54 /**
55 * Widget categories.
56 *
57 * @return array<int, string>
58 */
59 public function get_categories(): array
60 {
61 return ['king-addons-woo-builder'];
62 }
63
64 /**
65 * Styles.
66 *
67 * @return array<int, string>
68 */
69 /**
70 * Script handles.
71 *
72 * @return array<int,string>
73 */
74 public function get_script_depends(): array
75 {
76 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-place-order-script'];
77 }
78
79 public function get_style_depends(): array
80 {
81 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-place-order-style'];
82 }
83
84 /**
85 * Register controls.
86 *
87 * @return void
88 */
89 protected function register_controls(): void
90 {
91 $this->start_controls_section(
92 'section_content',
93 [
94 'label' => esc_html__('Button', 'king-addons'),
95 'tab' => Controls_Manager::TAB_CONTENT,
96 ]
97 );
98
99 $this->add_control(
100 'text',
101 [
102 'label' => esc_html__('Text', 'king-addons'),
103 'type' => Controls_Manager::TEXT,
104 'dynamic' => ['active' => true],
105 'default' => __('Place order', 'king-addons'),
106 ]
107 );
108
109 $this->add_control(
110 'full_width',
111 [
112 'label' => esc_html__('Full width', 'king-addons'),
113 'type' => Controls_Manager::SWITCHER,
114 'return_value' => 'yes',
115 'default' => 'yes',
116 ]
117 );
118
119 $this->end_controls_section();
120
121 $this->start_controls_section(
122 'section_style',
123 [
124 'label' => esc_html__('Style', 'king-addons'),
125 'tab' => Controls_Manager::TAB_STYLE,
126 ]
127 );
128
129 $this->add_group_control(
130 Group_Control_Typography::get_type(),
131 [
132 'name' => 'typography',
133 'selector' => '{{WRAPPER}} .ka-woo-checkout-place-order__btn',
134 ]
135 );
136
137 $this->add_control(
138 'text_color',
139 [
140 'label' => esc_html__('Text Color', 'king-addons'),
141 'type' => Controls_Manager::COLOR,
142 'selectors' => [
143 '{{WRAPPER}} .ka-woo-checkout-place-order__btn' => 'color: {{VALUE}};',
144 ],
145 ]
146 );
147
148 $this->add_control(
149 'bg_color',
150 [
151 'label' => esc_html__('Background', 'king-addons'),
152 'type' => Controls_Manager::COLOR,
153 'selectors' => [
154 '{{WRAPPER}} .ka-woo-checkout-place-order__btn' => 'background: {{VALUE}};',
155 ],
156 ]
157 );
158
159 $this->add_control(
160 'text_color_hover',
161 [
162 'label' => esc_html__('Text Color Hover', 'king-addons'),
163 'type' => Controls_Manager::COLOR,
164 'selectors' => [
165 '{{WRAPPER}} .ka-woo-checkout-place-order__btn:hover' => 'color: {{VALUE}};',
166 ],
167 ]
168 );
169
170 $this->add_control(
171 'bg_color_hover',
172 [
173 'label' => esc_html__('Background Hover', 'king-addons'),
174 'type' => Controls_Manager::COLOR,
175 'selectors' => [
176 '{{WRAPPER}} .ka-woo-checkout-place-order__btn:hover' => 'background: {{VALUE}};',
177 ],
178 ]
179 );
180
181 $this->add_group_control(
182 Group_Control_Border::get_type(),
183 [
184 'name' => 'border',
185 'selector' => '{{WRAPPER}} .ka-woo-checkout-place-order__btn',
186 ]
187 );
188
189 $this->add_group_control(
190 Group_Control_Box_Shadow::get_type(),
191 [
192 'name' => 'shadow',
193 'selector' => '{{WRAPPER}} .ka-woo-checkout-place-order__btn',
194 ]
195 );
196
197 $this->add_control(
198 'padding',
199 [
200 'label' => esc_html__('Padding', 'king-addons'),
201 'type' => Controls_Manager::DIMENSIONS,
202 'size_units' => ['px', 'em', '%'],
203 'selectors' => [
204 '{{WRAPPER}} .ka-woo-checkout-place-order__btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
205 ],
206 ]
207 );
208
209 $this->end_controls_section();
210 }
211
212 /**
213 * Render widget output.
214 *
215 * @return void
216 */
217 protected function render(): void
218 {
219 if (!$this->should_render()) {
220 $this->render_missing_checkout_notice();
221 return;
222 }
223
224 $settings = $this->get_settings_for_display();
225 // ?: not ??: a cleared field is '' rather than null, which produced a
226 // submit button with no label at all.
227 $text = ($settings['text'] ?? null) ?: __('Place order', 'king-addons');
228 $classes = ['ka-woo-checkout-place-order__btn', 'button', 'alt'];
229 if (!empty($settings['full_width'])) {
230 $classes[] = 'ka-woo-checkout-place-order__btn--full';
231 }
232
233 echo '<button type="submit" class="' . esc_attr(implode(' ', $classes)) . '" form="checkout">' . esc_html($text) . '</button>';
234 }
235 }
236
237
238
239
240