get_settings_for_display(); $this->clear_sellkit_checkout_custom_hooks( $settings ); if ( 'multi-step' === $settings['layout-type'] ) { $this->apply_multi_step_design( $settings ); } $this->apply_local_hooks( $settings ); if ( 'one-page' === $settings['layout-type'] ) { $this->add_render_attribute( 'wrapper', 'class', 'sellkit-checkout-widget-one-page-build sellkit-checkout-widget-main-wrapper' ); } else { $this->add_render_attribute( 'wrapper', 'class', 'sellkit-checkout-widget-multi-page-build sellkit-checkout-widget-main-wrapper' ); } if ( Elementor::$instance->editor->is_edit_mode() ) { $current_user = wp_get_current_user()->ID; wp_set_current_user( 0 ); } echo '
get_render_attribute_string( 'wrapper' ) . ' >'; echo do_shortcode( '[woocommerce_checkout]' ); echo do_shortcode( '[sellkit_checkout_widget_simulated]' ); echo '
'; do_action( 'sellkit-after-checkout-content', $settings ); if ( Elementor::$instance->editor->is_edit_mode() ) { wp_set_current_user( $current_user ); } } /** * Remove every function attached to sellkit checkout custom hooks. * * @param array $settings widget settings. * @since 1.1.0 * @return void */ private function clear_sellkit_checkout_custom_hooks( $settings ) { // Removed function that attached to custom hooks to prevent any error. remove_all_actions( 'sellkit-checkout-cart-item' ); remove_all_actions( 'sellkit-checkout-step-a-begins' ); remove_all_actions( 'sellkit-checkout-step-a-ends' ); remove_all_actions( 'sellkit-checkout-step-b-begins' ); remove_all_actions( 'sellkit-checkout-step-b-ends' ); remove_all_actions( 'sellkit-checkout-widget-step-two-header' ); remove_all_actions( 'sellkit-checkout-step-c-begins' ); remove_all_actions( 'sellkit-checkout-multistep-third-step-back-btn' ); remove_all_actions( 'sellkit-checkout-step-c-ends' ); remove_all_actions( 'sellkit-checkout-widget-step-three-header' ); remove_all_actions( 'sellkit-checkout-multistep-sidebar-begins' ); remove_all_actions( 'sellkit-checkout-multistep-sidebar-ends' ); remove_all_actions( 'sellkit-checkout-widget-breadcrumb-desktop' ); remove_all_actions( 'sellkit-checkout-widget-breadcrumb-mobile' ); remove_all_actions( 'sellkit_checkout_shipping_fields' ); remove_all_actions( 'sellkit_checkout_billing_fields' ); remove_all_actions( 'sellkit_checkout_after_shipping_section' ); remove_all_actions( 'sellkit_checkout_one_page_express_methods' ); remove_all_actions( 'sellkit-checkout-widget-custom-coupon-form' ); remove_all_filters( 'woocommerce_locate_template' ); if ( Elementor::$instance->editor->is_edit_mode() ) { $this->editor_mode( $settings ); } } /** * Editor mode, Render widget content on clicking it's wrapper. * * @since 1.1.0 * @return void */ private function editor_mode( $settings ) { add_action( 'sellkit_checkout_required_hidden_fields', function() { echo ''; } ); // Some frontend Hooks doesn't work in editor mode. // So we just hide them in editor mode, BUT we use real hooks in frontend. // Purpose is to increase user experience in editor mode. if ( 'yes' !== $settings['show_cart_items'] ) { $this->hide_items_in_editor( 'cart_item' ); } if ( 'yes' !== $settings['show_cart_edit'] ) { $this->hide_items_in_editor( 'sellkit-one-page-checkout-product-qty' ); add_action( 'sellkit-checkout-widget-disable-quantity', [ Helper::instance(), 'checkout_order_hidden_quantity' ], 10, 2 ); } if ( 'yes' !== $settings['show_shipping_method'] ) { $this->hide_items_in_editor( 'sellkit-one-page-shipping-methods' ); } add_action( 'sellkit-checkout-widget-custom-coupon-form', function() use ( $settings ) { Local_Hooks::coupon_form( $settings ); } ); if ( 'yes' !== $settings['show_coupon_field'] ) { $this->hide_items_in_editor( 'coupon-form' ); } if ( 'yes' !== $settings['order_summary_show_image'] ) { $this->hide_items_in_editor( 'sellkit-checkout-widget-item-image' ); } } private function hide_items_in_editor( $class ) { echo sprintf( /** Translators : %s : class name */ '', $class ); } }