0, 'type' => 'page' )); $page_id = $page_id['id']; $is_checkout = $page_id == wc_get_page_id( 'checkout' ) || get_query_var( 'et_is-checkout', false ); $is_cart = $page_id == wc_get_page_id( 'cart' ) || get_query_var( 'et_is-cart', false ); $is_order_pay = false; $is_order = false; // Handle checkout actions. if ( ! empty( $wp->query_vars['order-pay'] ) ) { $is_order_pay = true; } elseif ( isset( $wp->query_vars['order-received'] ) ) { $is_order = true; } return array( 'is_checkout' => $is_checkout, 'is_billing' => $is_checkout && !$is_order && (!isset($_GET['step']) || $_GET['step'] == 'billing'), 'is_shipping' => $is_checkout && isset($_GET['step']) && $_GET['step'] == 'shipping', 'is_payment' => $is_checkout && isset($_GET['step']) && $_GET['step'] == 'payment', 'is_cart' => $is_cart, 'is_order_pay' => $is_order_pay, 'is_order' => $is_order, ); } public function advanced_layout() { $this->disable_advanced_layout_actions(); $this->enable_advanced_layout_actions(); $this->advanced_layout_scripts(); } public function disable_advanced_layout_actions() { $actions_list = array(); if ( !get_query_var('et_cart-checkout-header-builder', false) ) { add_filter('etheme_header_template_basic', '__return_true'); $actions_list = array( array( 'action' => 'etheme_vertical_header', 'hook' => 'etheme_header', 'priority' => 1 ), array( 'action' => 'etheme_header_top', 'hook' => 'etheme_header', 'priority' => 10 ), array( 'action' => 'etheme_header_main', 'hook' => 'etheme_header', 'priority' => 20 ), array( 'action' => 'etheme_header_bottom', 'hook' => 'etheme_header', 'priority' => 30 ), array( 'action' => 'etheme_header_banner', 'hook' => 'etheme_header', 'priority' => 2 ), // mobile header // array( // 'action' => 'etheme_header_top', // 'hook' => 'etheme_header_mobile', // 'priority' => 10 // ), // array( // 'action' => 'etheme_header_main', // 'hook' => 'etheme_header_mobile', // 'priority' => 20 // ), // array( // 'action' => 'etheme_header_bottom', // 'hook' => 'etheme_header_mobile', // 'priority' => 30 // ), // array( // 'action' => 'etheme_header_banner', // 'hook' => 'etheme_header_mobile', // 'priority' => 40 // ), array( 'actions' => true, 'hook' => 'etheme_header_mobile', ), ); } $actions_list = array_merge($actions_list, array( // remove specific breadcrumbs and sales booster countdown array( 'action' => 'et_cart_checkout_breadcrumbs', 'hook' => 'etheme_page_heading', 'priority' => 20 ), array( 'action' => 'etheme_mobile_panel', 'hook' => 'after_page_wrapper', 'priority' => 1 ), array( 'action' => 'etheme_btt_button', 'hook' => 'after_page_wrapper', 'priority' => 30 ), array( 'action' => 'etheme_photoswipe_template', 'hook' => 'after_page_wrapper', 'priority' => 30 ), array( 'action' => 'et_notify', 'hook' => 'after_page_wrapper', 'priority' => 40 ), array( 'action' => 'et_buffer', 'hook' => 'after_page_wrapper', 'priority' => 40 ), array( 'action' => 'etheme_bordered_layout', 'hook' => 'et_after_body', ), )); if ( !get_query_var('et_cart-checkout-default-footer', false) ) { add_filter('etheme_footer_template_basic', '__return_true'); $actions_list = array_merge( $actions_list, array( array( 'actions' => true, 'hook' => 'etheme_prefooter', ), array( 'actions' => true, 'hook' => 'etheme_footer', ), ) ); } if ( get_query_var('et_cart-checkout-layout', 'default') != 'default' && !(get_query_var('et_is-cart-page-elementor-shortcode', false) || get_query_var('et_is-checkout-page-elementor-shortcode', false))) { $actions_list[] = array( 'action' => 'woocommerce_checkout_payment', 'hook' => 'woocommerce_checkout_order_review', 'priority' => 20 ); // $actions_list[] = array( // 'action' => 'woocommerce_order_review', // 'hook' => 'woocommerce_checkout_order_review', // 'priority' => 10 // ); } // add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); // add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); $actions_list[] = array( 'action' => 'woocommerce_checkout_login_form', 'hook' => 'woocommerce_before_checkout_form', 'priority' => 10 ); $actions_list[] = array( 'action' => 'woocommerce_checkout_coupon_form', 'hook' => 'woocommerce_before_checkout_form', 'priority' => 10 ); // } foreach ($actions_list as $action_details) { if ( isset( $action_details['actions'] ) ) { remove_all_actions( $action_details['hook'] ); } elseif ( isset( $action_details['priority'] ) ) { remove_action( $action_details['hook'], $action_details['action'], $action_details['priority'] ); } else { remove_action( $action_details['hook'], $action_details['action'] ); } } } public function header_steps($no_wrapper = false) { $check_pages = $this->check_page(); $classes = array( 'cart' => '', 'checkout' => '', 'order' => 'no-click' ); if ( $check_pages['is_order'] ) { $classes['cart'] = $classes['checkout'] = $classes['order'] = 'active'; } elseif ( $check_pages['is_checkout'] ) { $classes['cart'] = $classes['checkout'] = 'active'; $classes['checkout'] .= ' no-click'; } elseif ( $check_pages['is_cart'] ) { $classes['cart'] = 'active no-click'; } $cart_url = wc_get_cart_url(); $checkout_url = wc_get_checkout_url(); $arrow = ''; $no_wrapper = !!$no_wrapper; $texts = apply_filters('et_cart-checkout-nav-texts', array( 'cart' => esc_html__('Shopping cart', 'xstore'), 'order' => esc_html__('Order status', 'xstore'), 'order_received' => esc_html__('Your order has been received', 'xstore'), 'checkout' => esc_html__('Checkout', 'xstore'), 'shipping' => esc_html__('Shipping', 'xstore'), 'payment' => esc_html__('Payment', 'xstore'), )); if ( !$no_wrapper ) echo '
'; } public function update_progress_bar() { ob_start(); $this->sales_booster_progress_bar(); wp_send_json(ob_get_clean()); } public function enable_advanced_layout_actions() { if ( !get_query_var('et_cart-checkout-header-builder', false) ) { add_filter('theme_mod_header_overlap_et-desktop', '__return_false'); add_filter('theme_mod_header_overlap_et-mobile', '__return_false'); add_action( 'etheme_header_start', function () { $sticky_header = get_theme_mod( 'cart_checkout_main_header_sticky_et-desktop', '1' ) && get_query_var( 'et_cart-checkout-layout', 'default' ) != 'separated'; add_filter( 'theme_mod_top_header_sticky_et-mobile', '__return_false' ); add_filter( 'theme_mod_main_header_sticky_et-mobile', function ( $value ) use ( $sticky_header ) { return $sticky_header; } ); add_filter( 'theme_mod_bottom_header_sticky_et-mobile', '__return_false' ); add_filter( 'theme_mod_top_header_sticky_et-desktop', '__return_false' ); add_filter( 'theme_mod_main_header_sticky_et-desktop', function ( $value ) use ( $sticky_header ) { return $sticky_header; } ); add_filter( 'theme_mod_bottom_header_sticky_et-desktop', '__return_false' ); add_filter( 'theme_mod_header_sticky_type_et-desktop', function () { return 'sticky'; } ); }, 3 ); if ( get_query_var( 'et_cart-checkout-layout', 'default' ) != 'separated' || $this->check_page()['is_order'] ) { // etheme_woocommerce_above_checkout_form add_action( 'etheme_header', array( $this, 'etheme_cart_checkout_header_content' ), 10 ); } else { add_action( 'etheme_woocommerce_above_checkout_form', array( $this, 'etheme_cart_checkout_header_content_separated' ), - 10 ); // cart page use-case add_action( 'etheme_woocommerce_before_cart_form', array( $this, 'etheme_cart_checkout_header_content_separated' ), - 10 ); } } else { add_action( 'etheme_woocommerce_above_checkout_form', array( $this, 'header_steps' ), - 10 ); add_action( 'woocommerce_before_cart', array( $this, 'header_steps' ), - 10 ); } if ( !get_query_var('et_cart-checkout-default-footer', false) ) { add_action( 'etheme_footer', array( $this, 'etheme_cart_checkout_footer_content' ), 10 ); } set_query_var('et_page-banner', false); set_query_var('et_breadcrumbs', false); $is_builder_element = get_query_var('et_is-cart-page-elementor-shortcode', false) || get_query_var('et_is-checkout-page-elementor-shortcode', false); if ( get_option('xstore_sales_booster_settings_cart_checkout_countdown') && !WC()->cart->is_empty() ) { add_action('etheme_woocommerce_before_cart_form', array($this, 'sales_booster_countdown_output'), 2); add_action('etheme_woocommerce_above_checkout_form', array($this, 'sales_booster_countdown_output'), 2); // add_action('woocommerce_checkout_before_customer_details', array($this, 'sales_booster_countdown_output'), 2); } if ( get_theme_mod('cart_checkout_advanced_email_first', false) && !$is_builder_element ) { add_filter('woocommerce_billing_fields', function($fields) { if ( isset($fields['billing_email'])) { $fields['billing_email']['priority'] = 3; } // Fix autofocus - maybe be useful in future updates // if ( isset( $fields['billing'] ) ) $fields['billing']['billing_first_name']['autofocus'] = false; // if ( isset( $fields['shipping'] ) ) $fields['shipping']['shipping_first_name']['autofocus'] = false; return $fields; }); // compatibility with Brazilian Market on WooCommerce plugin add_filter('wcbcf_billing_fields', function($fields){ if ( isset($fields['billing_first_name'])) { $fields['billing_first_name']['priority'] = 15; } if ( isset($fields['billing_last_name'])) { $fields['billing_last_name']['priority'] = 15; } return $fields; }); } if ( get_theme_mod('cart_checkout_advanced_form_label', false) && !$is_builder_element ) { add_filter('woocommerce_default_address_fields', function ($fields) { $new_fields = array(); foreach ($fields as $field_key => $field) { if ( isset($field['label']) && $field['label'] != '' ) { if ( isset($field['label_class']) ) { if ( !in_array( 'screen-reader-text', $field['label_class'] ) ) $field['placeholder'] = ''; } elseif ( isset($field['placeholder']) ) { $field['placeholder'] = ''; } } $new_fields[$field_key] = $field; } return $new_fields; }); add_filter( 'woocommerce_form_field_args', function ( $args, $key, $value ) { if ( $args['label'] != '' && ! in_array( 'screen-reader-text', $args['label_class'] ) ) { $args['class'][] = 'et-advanced-label'; $args['placeholder'] = ''; } if ( $args['type'] == 'textarea' ) { $args['label_class'][] = 'textarea-label'; } if ( ! in_array( 'screen-reader-text', $args['label_class'] ) ) { $args['class'][] = 'et-validated'; } return $args; }, 3, 100 ); } $actions_list = array(); if ( get_query_var('et_cart-checkout-layout', 'default') == 'multistep') { if ( WC()->cart->needs_shipping() ) { $actions_list[] = array( 'action' => array( $this, 'cart_totals_shipping_wrapper_html' ), 'hook' => 'woocommerce_checkout_after_customer_details', 'priority' => 10 ); } $actions_list[] = array( 'action' => array( $this, 'checkout_payment' ), 'hook' => 'woocommerce_checkout_after_customer_details', 'priority' => 20 ); } $actions_list[] = array( 'action' => 'woocommerce_checkout_login_form', 'hook' => 'etheme_woocommerce_above_checkout_form', 'priority' => 10 ); $actions_list[] = array( 'action' => 'woocommerce_checkout_coupon_form', 'hook' => 'etheme_woocommerce_above_checkout_form', 'priority' => 10 ); if ( get_query_var('et_cart-checkout-layout', 'default') != 'default') { $actions_list[] = array( 'action' => array( $this, 'woocommerce_checkout_billing_footer_links' ), 'hook' => 'woocommerce_checkout_shipping', 'priority' => 100 ); add_filter('etheme_proceed_to_checkout_button_text', function ($text) { return ''.$text.'' . ''; }); add_action('woocommerce_review_order_before_shipping', function () { add_filter('etheme_show_chosen_shipping_method', '__return_true'); }); } foreach ($actions_list as $action_details) { if ( isset( $action_details['priority'] ) ) { add_action( $action_details['hook'], $action_details['action'], $action_details['priority'] ); } else { add_action( $action_details['hook'], $action_details['action'] ); } } } public function etheme_cart_checkout_header_content_separated() { etheme_header_wrapper_start(); $this->etheme_cart_checkout_header_content(); etheme_header_wrapper_end(); } public function woocommerce_checkout_billing_footer_links($step = '') { $step = $step ? $step : 'billing'; ?> esc_html__('Return to shop', 'xstore'), 'shipping' => esc_html__('Return to billing details', 'xstore'), 'payment' => esc_html__('Return to shipping', 'xstore') ); $steps = array( 'billing', ); if ( WC()->cart->needs_shipping() ) { $steps[] = 'shipping'; } else { $steps_titles['payment'] = $steps_titles['shipping']; } $steps[] = 'payment'; if ( $steps[0] == $active_step ) { // if first then it is billing if ( wc_get_page_id( 'shop' ) > 0 ) { echo '' . $steps_titles[$active_step] . ''; } return; } $step = $steps[array_search($active_step, $steps) - 1]; // switch ($active_step) { // case 'shipping': // $step_title = esc_html__('Return to billing details', 'xstore'); // break; // case 'payment': // $step_title = esc_html__('Return to shipping', 'xstore'); // break; // } echo '' . $steps_titles[$active_step] . ''; } public function next_step($active_step = 'billing') { $steps_titles = array( 'billing' => esc_html__('Continue to shipping', 'xstore'), 'shipping' => esc_html__('Continue to payment', 'xstore'), 'payment' => esc_html__('Place order', 'xstore') ); $steps = array( 'billing', ); if ( WC()->cart->needs_shipping() ) { $steps[] = 'shipping'; } else { $steps_titles['billing'] = $steps_titles['shipping']; } $steps[] = 'payment'; // $step_title = isset($steps['shipping']) ? esc_html__('Continue to shipping', 'xstore') : esc_html__('Continue to payment', 'xstore'); // if ( !WC()->cart->needs_shipping() && $active_step == 'billing' ) { // $active_step = 'shipping' // } if ( $steps[count($steps)-1] == $active_step ) { // if last then it is payment return; } $step = $steps[array_search($active_step, $steps) + 1]; // switch ($active_step) { // case 'shipping': // $step_title = esc_html__('Continue to payment', 'xstore'); // break; // case 'payment': // $step_title = esc_html__('Place order', 'xstore'); // break; // } echo '' . $steps_titles[$active_step] . ''; } public function cart_totals_shipping_html($return = false) { ob_start(); ?>