ts' ) ) ? $kit->get_settings_for_display( 'woocommerce_notices_elements' ) : []; // Front end checks. if ( 0 < count( $this->woocommerce_notices_elements ) // At least one notice has been activated. && $woocommerce_active // WooCommerce is active. && ( ! is_admin() || $is_editor ) // We are not in WP Admin. ) { return true; } return false; } public function get_order_received_endpoint_url( $url, $endpoint, $value ) { $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ); if ( $order_received_endpoint === $endpoint ) { $woocommerce_purchase_summary_page_id = get_option( 'elementor_woocommerce_purchase_summary_page_id' ); $order = wc_get_order( $value ); if ( $woocommerce_purchase_summary_page_id && $order ) { $url = trailingslashit( trailingslashit( trailingslashit( get_permalink( $woocommerce_purchase_summary_page_id ) ) . $order_received_endpoint ) . $order->get_id() ); } } return $url; } public function maybe_define_woocommerce_checkout() { $woocommerce_purchase_summary_page_id = get_option( 'elementor_woocommerce_purchase_summary_page_id' ); if ( $woocommerce_purchase_summary_page_id && intval( $woocommerce_purchase_summary_page_id ) === get_queried_object_id() ) { if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { define( 'WOOCOMMERCE_CHECKOUT', true ); } } } public function __construct() { parent::__construct(); add_action( 'elementor/kit/register_tabs', [ $this, 'init_site_settings' ], 1, 40 ); $this->add_update_kit_settings_hooks(); $this->use_mini_cart_template = 'yes' === get_option( 'elementor_' . self::OPTION_NAME_USE_MINI_CART, 'no' ); if ( is_admin() ) { add_action( 'elementor/admin/after_create_settings/' . Settings::PAGE_ID, [ $this, 'register_admin_fields' ], 15 ); } add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_init_cart' ] ); add_action( 'elementor/dynamic_tags/register', [ $this, 'register_tags' ] ); add_action( 'elementor/documents/register', [ $this, 'register_documents' ] ); add_action( 'elementor/theme/register_conditions', [ $this, 'register_conditions' ] ); add_action( 'wp_ajax_elementor_woocommerce_checkout_login_user', [ $this, 'elementor_woocommerce_checkout_login_user' ] ); add_action( 'wp_ajax_nopriv_elementor_woocommerce_checkout_login_user', [ $this, 'elementor_woocommerce_checkout_login_user' ] ); add_filter( 'elementor/theme/need_override_location', [ $this, 'theme_template_include' ], 10, 2 ); add_filter( 'elementor_pro/frontend/localize_settings', [ $this, 'localized_settings_frontend' ] ); // Load our widget Before WooCommerce Ajax. See the variable's PHPDoc for details. add_action( 'woocommerce_checkout_update_order_review', [ $this, 'load_widget_before_wc_ajax' ] ); // On Editor - Register WooCommerce frontend hooks before the Editor init. // Priority = 5, in order to allow plugins remove/add their wc hooks on init. if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) { add_action( 'init', [ $this, 'register_wc_hooks' ], 5 ); } // Allow viewing of Checkout page in the Editor with an empty cart. if ( ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) // Elementor Editor || ! empty( $_REQUEST['elementor-preview'] ) // Elementor Editor Preview || ( ! empty( $_REQUEST['action'] ) && 'elementor_ajax' === $_REQUEST['action'] ) // Elementor Editor Preview - Ajax Render Widget ) { add_filter( 'woocommerce_checkout_redirect_empty_cart', '__return_false', 5 ); } if ( $this->use_mini_cart_template ) { add_filter( 'woocommerce_add_to_cart_fragments', [ $this, 'menu_cart_fragments' ] ); add_filter( 'woocommerce_locate_template', [ $this, 'woocommerce_locate_template' ], 10, 3 ); } add_filter( 'elementor/widgets/wordpress/widget_args', [ $this, 'woocommerce_wordpress_widget_css_class' ], 10, 2 ); add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); // Make the Logout redirect go to our my account widget page instead of the set My Account Page. add_action( 'init', [ $this, 'elementor_wc_my_account_logout' ], 5 ); add_filter( 'elementor_pro/editor/localize_settings', [ $this, 'add_localize_data' ] ); add_action( 'wp', [ $this, 'maybe_define_woocommerce_checkout' ] ); add_filter( 'woocommerce_get_endpoint_url', [ $this, 'get_order_received_endpoint_url' ], 10, 3 ); // Filters for messages on the Shipping calculator add_filter( 'woocommerce_shipping_may_be_available_html', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-shipping-may-be-available-html e-checkout-message e-cart-content' ); }, 10, 1 ); add_filter( 'woocommerce_shipping_not_enabled_on_cart_html', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-shipping-not_enabled-on-cart-html e-checkout-message e-cart-content' ); }, 10, 1 ); add_filter( 'woocommerce_shipping_estimate_html', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-shipping-estimate-html e-checkout-message e-cart-content' ); }, 10, 1 ); add_filter( 'woocommerce_cart_no_shipping_available_html', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-cart-no-shipping-available-html e-checkout-message e-cart-content' ); }, 10, 1 ); add_filter( 'woocommerce_no_available_payment_methods_message', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-no-available-payment-methods-message e-description' ); }, 10, 1 ); add_filter( 'woocommerce_no_shipping_available_html', function ( $html ) { return $this->print_woocommerce_shipping_message( $html, 'woocommerce-no-shipping-available-html e-checkout-message' ); }, 10, 1 ); add_action( 'woocommerce_add_to_cart', [ $this, 'localize_added_to_cart_on_product_single' ] ); // WooCommerce Notice Site Settings if ( $this->should_load_wc_notices_styles() ) { add_filter( 'body_class', [ $this, 'e_notices_body_classes' ] ); // WooCommerce Notices CSS wp_enqueue_style( 'e-woocommerce-notices', ELEMENTOR_PRO_URL . 'assets/css/woocommerce-notices.min.css', [], ELEMENTOR_PRO_VERSION ); } } }