| 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 |
* Class construct. |
| 18 |
* |
| 19 |
* @param array $settings widget settings. |
| 20 |
*/ |
| 21 |
public function __construct( $settings ) { |
| 22 |
// Widget settings. |
| 23 |
$this->settings = $settings; |
| 24 |
|
| 25 |
/* Step 1 wrap. */ |
| 26 |
add_action( 'sellkit-checkout-step-a-begins', [ $this, 'first_step_begin' ], 10 ); |
| 27 |
add_action( 'sellkit-checkout-step-a-ends', [ $this, 'first_step_ends' ] ); |
| 28 |
|
| 29 |
/* Step 2 wrap. */ |
| 30 |
add_action( 'sellkit-checkout-step-b-begins', [ $this, 'second_step_begin' ] ); |
| 31 |
add_action( 'sellkit-checkout-step-b-ends', [ $this, 'second_step_ends' ] ); |
| 32 |
// Step 2 preview box. |
| 33 |
if ( 'yes' === $this->settings['show_preview_box'] ) { |
| 34 |
add_action( 'sellkit-checkout-widget-step-two-header', [ $this, 'step_two_preview_box' ] ); |
| 35 |
} |
| 36 |
|
| 37 |
/* Step 3 wrap. */ |
| 38 |
add_action( 'sellkit-checkout-step-c-begins', [ $this, 'third_step_begin' ] ); |
| 39 |
add_action( 'sellkit-checkout-multistep-third-step-back-btn', [ $this, 'third_step_back_btn' ] ); |
| 40 |
add_action( 'sellkit-checkout-step-c-ends', [ $this, 'third_step_ends' ] ); |
| 41 |
// Step 3 preview box. |
| 42 |
if ( 'yes' === $this->settings['show_preview_box'] ) { |
| 43 |
add_action( 'sellkit-checkout-widget-step-three-header', [ $this, 'step_three_preview_box' ] ); |
| 44 |
} |
| 45 |
|
| 46 |
// Remove payment method from order review & attach it to step 3. |
| 47 |
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); |
| 48 |
add_action( 'sellkit-checkout-step-c-begins', 'woocommerce_checkout_payment' ); |
| 49 |
|
| 50 |
// Sidebar order-review wrap. |
| 51 |
add_action( 'sellkit-checkout-multistep-sidebar-begins', [ $this, 'sidebar_starts' ], 10 ); |
| 52 |
add_action( 'sellkit-checkout-multistep-sidebar-ends', [ $this, 'sidebar_ends' ] ); |
| 53 |
|
| 54 |
// Attach Breadcrumbs. |
| 55 |
if ( 'yes' === $settings['show_breadcrumb'] ) { |
| 56 |
// We added this custom hook @sellkit-local-hooks class, before form. |
| 57 |
add_action( 'sellkit-checkout-widget-breadcrumb-desktop', [ $this, 'checkout_breadcrumb_desktop' ] ); |
| 58 |
add_action( 'sellkit-checkout-widget-breadcrumb-mobile', [ $this, 'checkout_breadcrumb_mobile' ] ); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Inner wrapper begins. |
| 64 |
* Left columns begins. |
| 65 |
* First Step Begins. |
| 66 |
* |
| 67 |
* @return void |
| 68 |
* @since 1.1.0 |
| 69 |
*/ |
| 70 |
public function first_step_begin() { |
| 71 |
echo sprintf( |
| 72 |
'<div class="inner_wrapper" id="sellkit-checkout-multistep-inner-wrap"> |
| 73 |
<div class="sellkit-checkout-left-column"> |
| 74 |
<div class="sellkit-multistep-checkout sellkit-multistep-checkout-first">' |
| 75 |
); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* First step ends. |
| 80 |
* close first step wrapper and also adds buttons that link to second step & cart page. |
| 81 |
* |
| 82 |
* @return void |
| 83 |
* @since 1.1.0 |
| 84 |
*/ |
| 85 |
public function first_step_ends() { |
| 86 |
?> |
| 87 |
<div class="sellkit-multistep-checkout-first-footer"> |
| 88 |
<span class="go-to-shipping sellkit-checkout-widget-primary-button"> |
| 89 |
<?php |
| 90 |
$text = esc_html__( 'Continue to shipping', 'sellkit' ); |
| 91 |
|
| 92 |
if ( 'yes' !== $this->settings['show_shipping_method'] ) { |
| 93 |
$text = esc_html__( 'Continue to payment', 'sellkit' ); |
| 94 |
} |
| 95 |
|
| 96 |
echo $text; |
| 97 |
?> |
| 98 |
</span> |
| 99 |
</div> |
| 100 |
<?php /* Closed step wrapper */ ?> |
| 101 |
</div> |
| 102 |
<?php |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Second step begins. |
| 107 |
* add a wrapper around second step. also adds header elements to second step. |
| 108 |
* |
| 109 |
* @return void |
| 110 |
* @since 1.1.0 |
| 111 |
*/ |
| 112 |
public function second_step_begin() { |
| 113 |
?> |
| 114 |
<div class="sellkit-multistep-checkout sellkit-multistep-checkout-second"> |
| 115 |
<?php do_action( 'sellkit-checkout-widget-step-two-header' ); ?> |
| 116 |
<?php |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Second step ends. |
| 121 |
* close second step by closing wrapper. also adds button to first step & third step. |
| 122 |
* |
| 123 |
* @return void |
| 124 |
* @since 1.1.0 |
| 125 |
*/ |
| 126 |
public function second_step_ends() { |
| 127 |
?> |
| 128 |
<section class="sellkit-multistep-checkout-second-footer"> |
| 129 |
<span class="go-to-first sellkit-checkout-widget-return-button"> |
| 130 |
<i class="fa fa-chevron-left"></i> |
| 131 |
<span><?php echo esc_html__( 'Return to previous step', 'sellkit' ); ?></span> |
| 132 |
</span> |
| 133 |
<span class="go-to-payment sellkit-checkout-widget-primary-button"> |
| 134 |
<?php echo esc_html__( 'Continue to Payment', 'sellkit' ); ?> |
| 135 |
</span> |
| 136 |
</section> |
| 137 |
<?php /* Closed step wrapper */ ?> |
| 138 |
</div> |
| 139 |
<?php |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Third step begins. |
| 144 |
* adds third step wrapper & also header section. |
| 145 |
* |
| 146 |
* @return void |
| 147 |
* @since 1.1.0 |
| 148 |
*/ |
| 149 |
public function third_step_begin() { |
| 150 |
?> |
| 151 |
<div class="sellkit-multistep-checkout sellkit-multistep-checkout-third"> |
| 152 |
<?php do_action( 'sellkit-checkout-widget-step-three-header' ); ?> |
| 153 |
<?php |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Back button for third step. |
| 158 |
* |
| 159 |
* @return void |
| 160 |
* @since 1.1.0 |
| 161 |
*/ |
| 162 |
public function third_step_back_btn() { |
| 163 |
?> |
| 164 |
<span class="go-to-second sellkit-checkout-widget-return-button"> |
| 165 |
<i class="fa fa-chevron-left"></i> |
| 166 |
<span><?php echo esc_html__( 'Return to previous step', 'sellkit' ); ?></span> |
| 167 |
</span> |
| 168 |
<?php |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Third step ends. |
| 173 |
* Left columns ends. |
| 174 |
* |
| 175 |
* @return void |
| 176 |
* @since 1.1.0 |
| 177 |
*/ |
| 178 |
public function third_step_ends() { |
| 179 |
?> |
| 180 |
<?php /* Closed step wrapper */ ?> |
| 181 |
</div> |
| 182 |
<?php /* Closed left column */ ?> |
| 183 |
</div> |
| 184 |
<?php |
| 185 |
} |
| 186 |
|
| 187 |
/** |
| 188 |
* Right columns starts. |
| 189 |
* Side bar starts. |
| 190 |
* |
| 191 |
* @return void |
| 192 |
* @since 1.1.0 |
| 193 |
*/ |
| 194 |
public function sidebar_starts() { |
| 195 |
$class = 'sellkit-multistep-checkout sellkit-multistep-checkout-sidebar'; |
| 196 |
// In multi step make sidebar sticky. |
| 197 |
if ( 'yes' === $this->settings['show_sticky_cart_details'] && 'multi-step' === $this->settings['layout-type'] ) { |
| 198 |
$class .= ' sellkit-multistep-checkout-sidebar-sticky'; |
| 199 |
} |
| 200 |
?> |
| 201 |
<div class="sellkit-checkout-right-column"> |
| 202 |
<div id="sellkit-checkout-widget-sidebar" class="<?php echo $class; ?>"> |
| 203 |
<div class="summary_toggle"> |
| 204 |
<span class="icon"><i class="fa fa-shopping-cart" aria-hidden="true"></i></span> |
| 205 |
<span class="title sellkit-checkout-widget-links"><?php echo esc_html__( 'Hide order summary', 'sellkit' ); ?></span> |
| 206 |
<i class="fa fa-3px fa-chevron-up sellkit-checkout-widget-links" style="font-size: 13px; color:#007bff"></i> |
| 207 |
<span class="price"><?php wc_cart_totals_order_total_html(); ?></span> |
| 208 |
</div> |
| 209 |
<?php |
| 210 |
} |
| 211 |
|
| 212 |
/** |
| 213 |
* Side bar ends. |
| 214 |
* |
| 215 |
* @return void |
| 216 |
* @since 1.1.0 |
| 217 |
*/ |
| 218 |
public function sidebar_ends() { |
| 219 |
echo '</div>'; // sidebar! |
| 220 |
do_action( 'sellkit-checkout-widget-breadcrumb-mobile' ); |
| 221 |
echo '</div>'; // right column! |
| 222 |
echo '</div>'; // inner wrapper! |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* Breadcrumb for desktop mode. |
| 227 |
* |
| 228 |
* @return void |
| 229 |
* @since 1.1.0 |
| 230 |
*/ |
| 231 |
public function checkout_breadcrumb_desktop() { |
| 232 |
$font = 'fa'; |
| 233 |
if ( Elementor::$instance->editor->is_edit_mode() ) { |
| 234 |
$font = 'fas'; |
| 235 |
} |
| 236 |
?> |
| 237 |
<section id="checkout-widget-breadcrumb" class="sellkit-checkout-widget-breadcrumb-desktop sellkit-checkout-widget-breadcrumb"> |
| 238 |
<span class="cart blue-line"> |
| 239 |
<a href="<?php echo wc_get_cart_url(); ?>" > |
| 240 |
<?php echo esc_html__( 'Cart', 'sellkit' ); ?> |
| 241 |
</a> |
| 242 |
</span> |
| 243 |
|
| 244 |
<i class="<?php echo $font; ?> fa-chevron-right sellkit-checkout-widget-bc-icon"></i> |
| 245 |
<span class="information current"><?php echo esc_html__( 'Information', 'sellkit' ); ?></span> |
| 246 |
|
| 247 |
<?php if ( 'yes' === $this->settings['show_shipping_method'] ) : ?> |
| 248 |
<i class="<?php echo $font; ?> fa-chevron-right sellkit-checkout-widget-bc-icon"></i> |
| 249 |
<span class="shipping inactive"><?php echo esc_html__( 'Shipping', 'sellkit' ); ?></span> |
| 250 |
<?php endif; ?> |
| 251 |
|
| 252 |
<i class="<?php echo $font; ?> fa-chevron-right sellkit-checkout-widget-bc-icon"></i> |
| 253 |
<span class="payment inactive"><?php echo esc_html__( 'Payment', 'sellkit' ); ?></span> |
| 254 |
</section> |
| 255 |
<?php |
| 256 |
} |
| 257 |
|
| 258 |
/** |
| 259 |
* Breadcrumb for mobile mode. |
| 260 |
* |
| 261 |
* @return void |
| 262 |
* @since 1.1.0 |
| 263 |
*/ |
| 264 |
public function checkout_breadcrumb_mobile() { |
| 265 |
?> |
| 266 |
<section id="checkout-widget-breadcrumb" class="sellkit-checkout-widget-breadcrumb-mobile sellkit-checkout-widget-breadcrumb"> |
| 267 |
|
| 268 |
<span class="cart"> |
| 269 |
<a href="<?php echo wc_get_cart_url(); ?>" class="blue-line" > |
| 270 |
<?php echo esc_html__( 'Cart', 'sellkit' ); ?> |
| 271 |
</a> |
| 272 |
</span> |
| 273 |
|
| 274 |
<i class="fa fa-chevron-right sellkit-checkout-widget-bc-icon" aria-hidden="true"></i> |
| 275 |
<span class="information current"><?php echo esc_html__( 'Information', 'sellkit' ); ?></span> |
| 276 |
|
| 277 |
<?php if ( 'yes' === $this->settings['show_shipping_method'] ) : ?> |
| 278 |
<i class="fa fa-chevron-right sellkit-checkout-widget-bc-icon" aria-hidden="true"></i> |
| 279 |
<span class="shipping inactive"><?php echo esc_html__( 'Shipping', 'sellkit' ); ?></span> |
| 280 |
<?php endif; ?> |
| 281 |
|
| 282 |
<i class="fa fa-chevron-right sellkit-checkout-widget-bc-icon" aria-hidden="true"></i> |
| 283 |
<span class="payment inactive"><?php echo esc_html__( 'Payment', 'sellkit' ); ?></span> |
| 284 |
</section> |
| 285 |
<?php |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* Step two preview box. |
| 290 |
* |
| 291 |
* @return void |
| 292 |
* @since 1.1.0 |
| 293 |
*/ |
| 294 |
public static function step_two_preview_box() { |
| 295 |
?> |
| 296 |
<section class="sellkit-multistep-checkout-second-header multistep-headers sellkit-checkout-widget-divider"> |
| 297 |
<div class="info-a" > |
| 298 |
<div> |
| 299 |
<span class="title"><?php echo esc_html__( 'Contact', 'sellkit' ); ?></span> |
| 300 |
<span class="mail email"></span> |
| 301 |
</div> |
| 302 |
<span class="edit edit-email go-to-first sellkit-checkout-widget-links"> |
| 303 |
<?php echo esc_html__( 'Change', 'sellkit' ); ?> |
| 304 |
</span> |
| 305 |
</div> |
| 306 |
<hr class="sellkit-checkout-widget-divider"> |
| 307 |
<div class="info-b"> |
| 308 |
<div> |
| 309 |
<span class="title"><?php echo esc_html__( 'Ship to', 'sellkit' ); ?></span> |
| 310 |
<span class="mail address"></span> |
| 311 |
</div> |
| 312 |
<span class="edit edit-ship go-to-first sellkit-checkout-widget-links"> |
| 313 |
<?php echo esc_html__( 'Change', 'sellkit' ); ?> |
| 314 |
</span> |
| 315 |
</div> |
| 316 |
</section> |
| 317 |
<?php |
| 318 |
} |
| 319 |
|
| 320 |
/** |
| 321 |
* Step 3 preview box. |
| 322 |
* |
| 323 |
* @return void |
| 324 |
* @since 1.1.0 |
| 325 |
*/ |
| 326 |
public static function step_three_preview_box() { |
| 327 |
?> |
| 328 |
<section class="sellkit-multistep-checkout-third-header multistep-headers sellkit-checkout-widget-divider"> |
| 329 |
<div class="info-a" > |
| 330 |
<div> |
| 331 |
<span class="title"><?php echo esc_html__( 'Contact', 'sellkit' ); ?></span> |
| 332 |
<span class="mail email"></span> |
| 333 |
</div> |
| 334 |
<span class="edit edit-email go-to-first sellkit-checkout-widget-links"> |
| 335 |
<?php echo esc_html__( 'Change', 'sellkit' ); ?> |
| 336 |
</span> |
| 337 |
</div> |
| 338 |
<hr class="sellkit-checkout-widget-divider"> |
| 339 |
<div class="info-b"> |
| 340 |
<div> |
| 341 |
<span class="title"><?php echo esc_html__( 'Ship to', 'sellkit' ); ?></span> |
| 342 |
<span class="mail address"></span> |
| 343 |
</div> |
| 344 |
<span class="edit edit-ship go-to-first sellkit-checkout-widget-links"> |
| 345 |
<?php echo esc_html__( 'Change', 'sellkit' ); ?> |
| 346 |
</span> |
| 347 |
</div> |
| 348 |
<hr class="sellkit-checkout-widget-divider"> |
| 349 |
<div class="info-c"> |
| 350 |
<div> |
| 351 |
<span class="title"><?php echo esc_html__( 'Method', 'sellkit' ); ?></span> |
| 352 |
<span class="mail method"></span> |
| 353 |
</div> |
| 354 |
<span class="edit edit-method go-to-second-header sellkit-checkout-widget-links"> |
| 355 |
<?php echo esc_html__( 'Change', 'sellkit' ); ?> |
| 356 |
</span> |
| 357 |
</div> |
| 358 |
</section> |
| 359 |
<?php |
| 360 |
} |
| 361 |
} |
| 362 |
|