PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / trunk
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster vtrunk
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / elementor / modules / checkout / classes / multi-step.php

multi-step.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster trunk, at includes/elementor/modules/checkout/classes/multi-step.php

404 lines 15.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Elementor\Modules\Checkout\Classes;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use \Elementor\Plugin as Elementor;
8
9 /**
10 * Multistep class.
11 * handle multi step mode for checkout widget.
12 *
13 * @since 1.1.0
14 */
15 class Multi_Step {
16 /**
17 * Checkout widget settings.
18 *
19 * @since 1.8.6
20 * @var array
21 */
22 public $settings;
23
24 /**
25 * Class construct.
26 *
27 * @param array $settings widget settings.
28 */
29 public function __construct( $settings ) {
30 // Widget settings.
31 $this->settings = $settings;
32
33 /* Step 1 wrap. */
34 add_action( 'sellkit-checkout-step-a-begins', [ $this, 'first_step_begin' ], 10 );
35 add_action( 'sellkit-checkout-step-a-ends', [ $this, 'first_step_ends' ] );
36
37 /* Step 2 wrap. */
38 add_action( 'sellkit-checkout-step-b-begins', [ $this, 'second_step_begin' ] );
39 add_action( 'sellkit-checkout-step-b-ends', [ $this, 'second_step_ends' ] );
40 // Step 2 preview box.
41 if ( 'yes' === $this->settings['show_preview_box'] ) {
42 add_action( 'sellkit-checkout-widget-step-two-header', [ $this, 'step_two_preview_box' ] );
43 }
44
45 /* Step 3 wrap. */
46 add_action( 'sellkit-checkout-step-c-begins', [ $this, 'third_step_begin' ], 5 );
47 add_action( 'sellkit-checkout-multistep-third-step-back-btn', [ $this, 'third_step_back_btn' ] );
48 add_action( 'sellkit-checkout-step-c-ends', [ $this, 'third_step_ends' ] );
49 // Step 3 preview box.
50 if ( 'yes' === $this->settings['show_preview_box'] ) {
51 add_action( 'sellkit-checkout-widget-step-three-header', [ $this, 'step_three_preview_box' ] );
52 }
53
54 // Remove payment method from order review & attach it to step 3.
55 remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
56 add_action( 'sellkit-checkout-step-c-begins', 'woocommerce_checkout_payment', 20 );
57
58 $shipping_destination = get_option( 'woocommerce_ship_to_destination', true );
59
60 if ( 'billing_only' !== $shipping_destination ) {
61 remove_action( 'woocommerce_checkout_billing', [ WC()->checkout(), 'checkout_form_billing' ] );
62 add_action( 'sellkit-checkout-step-c-begins', [ WC()->checkout(), 'checkout_form_billing' ], 10 );
63 }
64
65 // Sidebar order-review wrap.
66 add_action( 'sellkit-checkout-multistep-sidebar-begins', [ $this, 'sidebar_starts' ], 10 );
67 add_action( 'sellkit-checkout-multistep-sidebar-ends', [ $this, 'sidebar_ends' ] );
68
69 // Attach Breadcrumbs.
70 if ( 'yes' === $settings['show_breadcrumb'] ) {
71 // We added this custom hook @sellkit-local-hooks class, before form.
72 add_action( 'sellkit-checkout-widget-breadcrumb-desktop', [ $this, 'checkout_breadcrumb_desktop' ] );
73 add_action( 'sellkit-checkout-widget-breadcrumb-mobile', [ $this, 'checkout_breadcrumb_mobile' ] );
74 }
75 }
76
77 /**
78 * Inner wrapper begins.
79 * Left columns begins.
80 * First Step Begins.
81 *
82 * @return void
83 * @since 1.1.0
84 */
85 public function first_step_begin() {
86 echo sprintf(
87 '<div class="inner_wrapper" id="sellkit-checkout-multistep-inner-wrap">
88 <div class="sellkit-checkout-left-column">
89 <div class="sellkit-multistep-checkout sellkit-multistep-checkout-first">'
90 );
91 }
92
93 /**
94 * First step ends.
95 * close first step wrapper and also adds buttons that link to second step & cart page.
96 *
97 * @return void
98 * @since 1.1.0
99 */
100 public function first_step_ends() {
101 if ( WC()->cart->needs_shipping() ) : ?>
102 <div class="sellkit-multistep-checkout-first-footer">
103 <span class="go-to-shipping sellkit-checkout-widget-primary-button">
104 <?php
105 $text = esc_html__( 'Continue to shipping', 'sellkit' );
106
107 if ( 'yes' !== $this->settings['show_shipping_method'] ) {
108 $text = esc_html__( 'Continue to payment', 'sellkit' );
109 }
110
111 echo esc_html( $text );
112 ?>
113 </span>
114 </div>
115 <?php endif; ?>
116 </div> <?php /* Closed step 1 wrapper */ ?>
117 <?php
118 }
119
120 /**
121 * Second step begins.
122 * add a wrapper around second step. also adds header elements to second step.
123 *
124 * @return void
125 * @since 1.1.0
126 */
127 public function second_step_begin() {
128 ?>
129 <div class="sellkit-multistep-checkout sellkit-multistep-checkout-second">
130 <?php do_action( 'sellkit-checkout-widget-step-two-header' ); ?>
131 <?php
132 }
133
134 /**
135 * Second step ends.
136 * close second step by closing wrapper. also adds button to first step & third step.
137 *
138 * @return void
139 * @since 1.1.0
140 */
141 public function second_step_ends() {
142 ?>
143 <section class="sellkit-multistep-checkout-second-footer">
144 <span class="go-to-first sellkit-checkout-widget-return-button">
145 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/></svg>
146 <span><?php echo esc_html__( 'Return to previous step', 'sellkit' ); ?></span>
147 </span>
148 <span class="go-to-payment sellkit-checkout-widget-primary-button">
149 <?php echo esc_html__( 'Continue to Payment', 'sellkit' ); ?>
150 </span>
151 </section>
152 <?php /* Closed step wrapper */ ?>
153 </div>
154 <?php
155 }
156
157 /**
158 * Third step begins.
159 * adds third step wrapper & also header section.
160 *
161 * @return void
162 * @since 1.1.0
163 */
164 public function third_step_begin() {
165 ?>
166 <div class="sellkit-multistep-checkout sellkit-multistep-checkout-third">
167 <?php do_action( 'sellkit-checkout-widget-step-three-header' ); ?>
168 <?php
169 }
170
171 /**
172 * Back button for third step.
173 *
174 * @return void
175 * @since 1.1.0
176 */
177 public function third_step_back_btn() {
178 if ( ! WC()->cart->needs_shipping() ) {
179 return;
180 }
181
182 ?>
183 <span class="go-to-second sellkit-checkout-widget-return-button">
184 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/></svg>
185 <span><?php echo esc_html__( 'Return to previous step', 'sellkit' ); ?></span>
186 </span>
187 <?php
188 }
189
190 /**
191 * Third step ends.
192 * Left columns ends.
193 *
194 * @return void
195 * @since 1.1.0
196 */
197 public function third_step_ends() {
198 ?>
199 <?php /* Closed step wrapper */ ?>
200 </div>
201 <?php /* Closed left column */ ?>
202 </div>
203 <?php
204 }
205
206 /**
207 * Right columns starts.
208 * Side bar starts.
209 *
210 * @return void
211 * @since 1.1.0
212 */
213 public function sidebar_starts() {
214 $class = 'sellkit-multistep-checkout sellkit-multistep-checkout-sidebar';
215 // In multi step make sidebar sticky.
216 if ( 'yes' === $this->settings['show_sticky_cart_details'] && 'multi-step' === $this->settings['layout-type'] ) {
217 $class .= ' sellkit-multistep-checkout-sidebar-sticky';
218 }
219 ?>
220 <div class="sellkit-checkout-right-column">
221 <div id="sellkit-checkout-widget-sidebar" class="<?php echo esc_attr( $class ); ?>">
222 <div class="summary_toggle">
223 <span class="summery_toggle_link_wrapper">
224 <span class="icon sellkit-checkout-summary-toggle-shop-icon">
225 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 576 512">
226 <path d="M0 24C0 10.7 10.7 0 24 0H69.5c22 0 41.5 12.8 50.6 32h411c26.3 0 45.5 25 38.6 50.4l-41 152.3c-8.5 31.4-37 53.3-69.5 53.3H170.7l5.4 28.5c2.2 11.3 12.1 19.5 23.6 19.5H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H199.7c-34.6 0-64.3-24.6-70.7-58.5L77.4 54.5c-.7-3.8-4-6.5-7.9-6.5H24C10.7 48 0 37.3 0 24zM128 464a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm336-48a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/>
227 </svg>
228 </span>
229 <span class="title sellkit-checkout-widget-links"><?php echo esc_html__( 'Hide order summary', 'sellkit' ); ?></span>
230 <span class="sellkit-checkout-widget-links sellkit-checkout-summary-toggle-up">
231 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
232 <path d="M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"/>
233 </svg>
234 </span>
235 <span class="sellkit-checkout-widget-links sellkit-checkout-summary-toggle-down">
236 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
237 <path d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"/>
238 </svg>
239 </span>
240 </span>
241 <span class="price"><?php wc_cart_totals_order_total_html(); ?></span>
242 </div>
243 <?php
244 }
245
246 /**
247 * Side bar ends.
248 *
249 * @return void
250 * @since 1.1.0
251 */
252 public function sidebar_ends() {
253 echo '</div>'; // sidebar!
254 do_action( 'sellkit-checkout-widget-breadcrumb-mobile' );
255 echo '</div>'; // right column!
256 echo '</div>'; // inner wrapper!
257 }
258
259 /**
260 * Breadcrumb for desktop mode.
261 *
262 * @return void
263 * @since 1.1.0
264 */
265 public function checkout_breadcrumb_desktop() {
266 if ( ! WC()->cart->needs_shipping() ) {
267 return;
268 }
269
270 ?>
271 <section id="checkout-widget-breadcrumb" class="sellkit-checkout-widget-breadcrumb-desktop sellkit-checkout-widget-breadcrumb">
272 <span class="cart blue-line">
273 <a href="<?php echo esc_url( wc_get_cart_url() ); ?>" >
274 <?php echo esc_html__( 'Cart', 'sellkit' ); ?>
275 </a>
276 </span>
277
278 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
279 <span class="information current"><?php echo esc_html__( 'Information', 'sellkit' ); ?></span>
280
281 <?php if ( 'yes' === $this->settings['show_shipping_method'] ) : ?>
282 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
283 <span class="shipping inactive"><?php echo esc_html__( 'Shipping', 'sellkit' ); ?></span>
284 <?php endif; ?>
285
286 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
287 <span class="payment inactive"><?php echo esc_html__( 'Payment', 'sellkit' ); ?></span>
288 </section>
289 <?php
290 }
291
292 /**
293 * Breadcrumb for mobile mode.
294 *
295 * @return void
296 * @since 1.1.0
297 */
298 public function checkout_breadcrumb_mobile() {
299 if ( ! WC()->cart->needs_shipping() ) {
300 return;
301 }
302
303 ?>
304 <section id="checkout-widget-breadcrumb" class="sellkit-checkout-widget-breadcrumb-mobile sellkit-checkout-widget-breadcrumb">
305
306 <span class="cart">
307 <a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="blue-line" >
308 <?php echo esc_html__( 'Cart', 'sellkit' ); ?>
309 </a>
310 </span>
311
312 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
313 <span class="information current"><?php echo esc_html__( 'Information', 'sellkit' ); ?></span>
314
315 <?php if ( 'yes' === $this->settings['show_shipping_method'] ) : ?>
316 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
317 <span class="shipping inactive"><?php echo esc_html__( 'Shipping', 'sellkit' ); ?></span>
318 <?php endif; ?>
319
320 <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>
321 <span class="payment inactive"><?php echo esc_html__( 'Payment', 'sellkit' ); ?></span>
322 </section>
323 <?php
324 }
325
326 /**
327 * Step two preview box.
328 *
329 * @return void
330 * @since 1.1.0
331 */
332 public static function step_two_preview_box() {
333 ?>
334 <section class="sellkit-multistep-checkout-second-header multistep-headers sellkit-checkout-widget-divider">
335 <div class="info-a" >
336 <div>
337 <span class="title"><?php echo esc_html__( 'Contact', 'sellkit' ); ?></span>
338 <span class="mail email"></span>
339 </div>
340 <span class="edit edit-email go-to-first sellkit-checkout-widget-links">
341 <?php echo esc_html__( 'Change', 'sellkit' ); ?>
342 </span>
343 </div>
344 <hr class="sellkit-checkout-widget-divider">
345 <div class="info-b">
346 <div>
347 <span class="title"><?php echo esc_html__( 'Ship to', 'sellkit' ); ?></span>
348 <span class="mail address"></span>
349 </div>
350 <span class="edit edit-ship go-to-first sellkit-checkout-widget-links">
351 <?php echo esc_html__( 'Change', 'sellkit' ); ?>
352 </span>
353 </div>
354 </section>
355 <?php
356 }
357
358 /**
359 * Step 3 preview box.
360 *
361 * @return void
362 * @since 1.1.0
363 */
364 public static function step_three_preview_box() {
365 if ( ! WC()->cart->needs_shipping() ) {
366 return;
367 }
368
369 ?>
370 <section class="sellkit-multistep-checkout-third-header multistep-headers sellkit-checkout-widget-divider">
371 <div class="info-a" >
372 <div>
373 <span class="title"><?php echo esc_html__( 'Contact', 'sellkit' ); ?></span>
374 <span class="mail email"></span>
375 </div>
376 <span class="edit edit-email go-to-first sellkit-checkout-widget-links">
377 <?php echo esc_html__( 'Change', 'sellkit' ); ?>
378 </span>
379 </div>
380 <hr class="sellkit-checkout-widget-divider">
381 <div class="info-b">
382 <div>
383 <span class="title"><?php echo esc_html__( 'Ship to', 'sellkit' ); ?></span>
384 <span class="mail address"></span>
385 </div>
386 <span class="edit edit-ship go-to-first sellkit-checkout-widget-links">
387 <?php echo esc_html__( 'Change', 'sellkit' ); ?>
388 </span>
389 </div>
390 <hr class="sellkit-checkout-widget-divider">
391 <div class="info-c">
392 <div>
393 <span class="title"><?php echo esc_html__( 'Method', 'sellkit' ); ?></span>
394 <span class="mail method"></span>
395 </div>
396 <span class="edit edit-method go-to-second-header sellkit-checkout-widget-links">
397 <?php echo esc_html__( 'Change', 'sellkit' ); ?>
398 </span>
399 </div>
400 </section>
401 <?php
402 }
403 }
404