PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.49
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.49
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_Checkout_Steps / Woo_Checkout_Steps.php

Woo_Checkout_Steps.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.49, at includes/widgets/Woo_Checkout_Steps/Woo_Checkout_Steps.php

253 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Checkout Steps widget (multi-step).
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Widget_Base;
12 use King_Addons\Woo_Builder\Context as Woo_Context;
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 /**
19 * Placeholder multi-step checkout (Free shows notice, Pro overrides).
20 */
21 class Woo_Checkout_Steps extends Widget_Base
22 {
23 /**
24 * Register Pro-only controls (placeholder).
25 *
26 * Pro overrides this method to add premium controls without using parent::register_controls().
27 *
28 * @return void
29 */
30 public function register_pro_controls(): void
31 {
32 // Intentionally empty in Free.
33 }
34
35 /**
36 * Widget slug.
37 *
38 * @return string
39 */
40 public function get_name(): string
41 {
42 return 'woo_checkout_steps';
43 }
44
45 /**
46 * Widget title.
47 *
48 * @return string
49 */
50 public function get_title(): string
51 {
52 return esc_html__('Checkout Steps (Multi-step)', 'king-addons');
53 }
54
55 /**
56 * Widget icon.
57 *
58 * @return string
59 */
60 public function get_icon(): string
61 {
62 return 'eicon-editor-list-ol';
63 }
64
65 /**
66 * Widget categories.
67 *
68 * @return array<int,string>
69 */
70 public function get_categories(): array
71 {
72 return ['king-addons-woo-builder'];
73 }
74
75 /**
76 * Styles.
77 *
78 * @return array<int, string>
79 */
80 public function get_style_depends(): array
81 {
82 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-steps-style'];
83 }
84
85 /**
86 * Scripts.
87 *
88 * @return array<int, string>
89 */
90 public function get_script_depends(): array
91 {
92 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-checkout-steps-script'];
93 }
94
95 /**
96 * Register controls.
97 *
98 * @return void
99 */
100 protected function register_controls(): void
101 {
102 $this->start_controls_section(
103 'section_content',
104 [
105 'label' => esc_html__('Content', 'king-addons'),
106 'tab' => Controls_Manager::TAB_CONTENT,
107 ]
108 );
109
110 $this->add_control(
111 'steps',
112 [
113 'label' => esc_html__('Steps', 'king-addons'),
114 'type' => Controls_Manager::REPEATER,
115 'fields' => [
116 [
117 'name' => 'label',
118 'label' => esc_html__('Label', 'king-addons'),
119 'type' => Controls_Manager::TEXT,
120 'default' => esc_html__('Step', 'king-addons'),
121 ],
122 [
123 'name' => 'target',
124 'label' => sprintf(__('Target selector (Pro) %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
125 'type' => Controls_Manager::TEXT,
126 'placeholder' => '#customer_details',
127 ],
128 ],
129 'default' => [
130 ['label' => esc_html__('Billing', 'king-addons')],
131 ['label' => esc_html__('Shipping', 'king-addons')],
132 ['label' => esc_html__('Payment', 'king-addons')],
133 ['label' => esc_html__('Review', 'king-addons')],
134 ],
135 ]
136 );
137
138 $this->add_control(
139 'scroll_to_section',
140 [
141 'label' => sprintf(__('Scroll to section (Pro) %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
142 'type' => Controls_Manager::SWITCHER,
143 'return_value' => 'yes',
144 ]
145 );
146
147 $this->add_control(
148 'show_nav',
149 [
150 'label' => sprintf(__('Show Next/Previous (Pro) %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
151 'type' => Controls_Manager::SWITCHER,
152 'return_value' => 'yes',
153 ]
154 );
155
156 $this->add_control(
157 'auto_scroll',
158 [
159 'label' => esc_html__('Scroll on step change (Pro)', 'king-addons'),
160 'type' => Controls_Manager::SWITCHER,
161 'return_value' => 'yes',
162 ]
163 );
164
165 $this->add_control(
166 'prev_text',
167 [
168 'label' => esc_html__('Previous text', 'king-addons'),
169 'type' => Controls_Manager::TEXT,
170 'default' => esc_html__('Previous', 'king-addons'),
171 'condition' => [
172 'show_nav' => 'yes',
173 ],
174 ]
175 );
176
177 $this->add_control(
178 'next_text',
179 [
180 'label' => esc_html__('Next text', 'king-addons'),
181 'type' => Controls_Manager::TEXT,
182 'default' => esc_html__('Next', 'king-addons'),
183 'condition' => [
184 'show_nav' => 'yes',
185 ],
186 ]
187 );
188
189 $this->end_controls_section();
190
191 // Allow Pro to add additional controls without using parent::register_controls().
192 $this->register_pro_controls();
193 }
194
195 /**
196 * Render widget output (free shows upgrade notice).
197 *
198 * @return void
199 */
200 protected function render(): void
201 {
202 if (!Woo_Context::maybe_render_context_notice('checkout')) {
203 return;
204 }
205 if (!king_addons_can_use_pro()) {
206 if (Woo_Context::is_editor()) {
207 echo '<div class="king-addons-woo-builder-notice">';
208 echo esc_html__('Multi-step checkout is available in Pro.', 'king-addons');
209 echo '</div>';
210 }
211 return;
212 }
213
214 $settings = $this->get_settings_for_display();
215 $steps = $settings['steps'] ?? [];
216 if (empty($steps)) {
217 return;
218 }
219
220 $scroll = (!empty($settings['scroll_to_section']) && 'yes' === $settings['scroll_to_section']) ? 'yes' : 'no';
221 $auto_scroll = (!empty($settings['auto_scroll']) && 'yes' === $settings['auto_scroll']) ? 'yes' : 'no';
222 $show_nav = (!empty($settings['show_nav']) && 'yes' === $settings['show_nav']);
223 $prev_text = $settings['prev_text'] ?? esc_html__('Previous', 'king-addons');
224 $next_text = $settings['next_text'] ?? esc_html__('Next', 'king-addons');
225
226 echo '<div class="ka-woo-checkout-steps-wrapper" data-enable-nav="' . ($show_nav ? 'true' : 'false') . '" data-auto-scroll="' . esc_attr($auto_scroll) . '">';
227 echo '<ol class="ka-woo-checkout-steps ka-woo-checkout-steps--pro" role="list" data-scroll-top="' . esc_attr($scroll) . '" data-prev-text="' . esc_attr($prev_text) . '" data-next-text="' . esc_attr($next_text) . '">';
228 foreach ($steps as $index => $step) {
229 $label = $step['label'] ?? '';
230 $target = $step['target'] ?? '';
231 echo '<li class="ka-woo-checkout-step" data-step="' . esc_attr((string) ($index + 1)) . '" data-target="' . esc_attr($target) . '">';
232 echo '<span class="ka-woo-checkout-step__number">' . esc_html((string) ($index + 1)) . '</span>';
233 echo '<span class="ka-woo-checkout-step__label">' . esc_html($label) . '</span>';
234 echo '</li>';
235 }
236 echo '</ol>';
237 if ($show_nav) {
238 echo '<div class="ka-woo-checkout-steps__nav">';
239 echo '<button type="button" class="button ka-woo-checkout-steps__prev" data-nav="prev">' . esc_html($prev_text) . '</button>';
240 echo '<button type="button" class="button button-primary ka-woo-checkout-steps__next" data-nav="next">' . esc_html($next_text) . '</button>';
241 echo '</div>';
242 }
243 echo '</div>';
244 }
245 }
246
247
248
249
250
251
252
253