| 1 |
<?php |
| 2 |
// Exit if accessed directly. |
| 3 |
use WPFunnels\Wpfnl; |
| 4 |
use WPFunnels\Wpfnl_functions; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
$checkout_layout = Wpfnl_functions::get_checkout_layout( $checkout_id ); |
| 11 |
|
| 12 |
$floating_label = Wpfnl_functions::get_checkout_step_setting( $checkout_id, 'wpfnl_floating_label', 'wpfnl-col-2' ); |
| 13 |
|
| 14 |
if( PHP_SESSION_DISABLED == session_status() ) { |
| 15 |
session_start(); |
| 16 |
} |
| 17 |
$_SESSION[ 'checkout_layout' ] = $checkout_layout; |
| 18 |
|
| 19 |
if( \WPFunnels\Wpfnl_functions::is_wpfnl_pro_activated() && 'wpfnl-express-checkout' === $checkout_layout ) { |
| 20 |
$checkout_layout .= ' wpfnl-multistep'; |
| 21 |
} |
| 22 |
|
| 23 |
if( \WPFunnels\Wpfnl_functions::is_wpfnl_pro_activated() && 'wpfnl-2-step' === $checkout_layout ) { |
| 24 |
$checkout_layout .= ' wpfnl-multistep'; |
| 25 |
} |
| 26 |
|
| 27 |
// Add shared modern checkout class for both modern layouts |
| 28 |
if( 'wpfnl-modern-one-column' === $checkout_layout || 'wpfnl-modern-checkout' === $checkout_layout ) { |
| 29 |
if( false === strpos( $checkout_layout, 'wpfnl-modern-checkout' ) ) { |
| 30 |
$checkout_layout .= ' wpfnl-modern-checkout'; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
if( 'wpfnl-modern-multistep' === $checkout_layout ) { |
| 35 |
$checkout_layout .= ' wpfnl-modern-checkout'; |
| 36 |
} |
| 37 |
|
| 38 |
?> |
| 39 |
|
| 40 |
<div id="wpfnl-checkout-form" class="wpfnl-checkout <?php echo esc_attr( $checkout_layout ); ?> <?php echo esc_attr( $floating_label ); ?> "> |
| 41 |
<?php |
| 42 |
if ( WC()->cart && WC()->cart->is_empty() ) { |
| 43 |
// WC shortcode redirects to cart when empty — bypass it and render the |
| 44 |
// checkout form template directly so the design is visible without products. |
| 45 |
// Set a session flag so the woocommerce_checkout_update_order_review_expired |
| 46 |
// filter can suppress the "session expired" AJAX response for this session. |
| 47 |
wc_clear_notices(); |
| 48 |
WC()->session->set( 'wpfnl_checkout_preview_mode', true ); |
| 49 |
ob_start(); |
| 50 |
wc_get_template( 'checkout/form-checkout.php', array( 'checkout' => WC()->checkout() ) ); |
| 51 |
echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 52 |
} else { |
| 53 |
$checkout_html = do_shortcode( '[woocommerce_checkout]' ); |
| 54 |
if ( empty( $checkout_html ) || trim( $checkout_html ) === '<div class="woocommerce"></div>' ) { |
| 55 |
echo esc_html__( 'Your cart is currently empty.', 'wpfnl' ); |
| 56 |
} else { |
| 57 |
echo $checkout_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 58 |
} |
| 59 |
} |
| 60 |
?> |
| 61 |
</div> |
| 62 |
|