Support » Plugin: WooCommerce » Cant edit WooCommerce account page with elementor. wc_get_notices() error

  • WordPress version 5.4.1
    Current theme: GeneratePress (version 2.4.2)
    Current plugin: WooCommerce (version 4.2.0)
    PHP version 7.2.30

    Error Details
    =============
    An error of type E_ERROR was caused in line 69 of the file /home/titleofthesite/titleofthesite.com/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php. Error message: Uncaught Error: Call to undefined function wc_get_notices() in /home/titleofthesite/titleofthesite.com/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php:69
    Stack trace:
    #0 /home/titleofthesite/titleofthesite.com/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(72): WC_Shortcode_My_Account::output(”)
    #1 /home/titleofthesite/titleofthesite.com/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(115): WC_Shortcodes::shortcode_wrapper(Array, ”)
    #2 /home/titleofthesite/titleofthesite.com/wp-includes/shortcodes.php(343): WC_Shortcodes::my_account(”, ”, ‘woocommerce_my_…’)
    #3 [internal function]: do_shortcode_tag(Array)
    #4 /home/titleofthesite/titleofthesite/wp-includes/shortcodes.php(218): preg_replace_callback(‘/\\[(\\[?)(woocom…’, ‘do_shortcode_ta…’, ‘[woocommerce_my…’)
    #5 /home/titleofthesite/titleofthesite.com/wp-content/plugins/elementor/includes/widgets/shortcode.php(130): do_shortcode(‘[woocommerce_my…’)
    #6 /home/titleofthesite/titleofthesite/wp-content/plugins/elementor/includes/base/widget-ba

    Code of woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php:

    public static function output( $atts ) {
    		global $wp;
    
    		// Check cart class is loaded or abort.
    		if ( is_null( WC()->cart ) ) {
    			return;
    		}
    
    		if ( ! is_user_logged_in() ) {
    			$message = apply_filters( 'woocommerce_my_account_message', '' );
    
    			if ( ! empty( $message ) ) {
    				wc_add_notice( $message );
    			}
    
    			// After password reset, add confirmation message.
    			if ( ! empty( $_GET['password-reset'] ) ) { // WPCS: input var ok, CSRF ok.
    				wc_add_notice( __( 'Your password has been reset successfully.', 'woocommerce' ) );
    			}
    
    			if ( isset( $wp->query_vars['lost-password'] ) ) {
    				self::lost_password();
    			} else {
    				wc_get_template( 'myaccount/form-login.php' );
    			}
    		} else {
    			// Start output buffer since the html may need discarding for BW compatibility.
    			ob_start();
    
    			if ( isset( $wp->query_vars['customer-logout'] ) ) {
    				/* translators: %s: logout url */
    				wc_add_notice( sprintf( __( 'Are you sure you want to log out? <a href="%s">Confirm and log out</a>', 'woocommerce' ), wc_logout_url() ) );
    			}
    
    			// Collect notices before output.
    			$notices = wc_get_notices(); //line 69
    
    			// Output the new account page.
    			self::my_account( $atts );
    
    			/**
    			 * Deprecated my-account.php template handling. This code should be
    			 * removed in a future release.
    			 *
    			 * If woocommerce_account_content did not run, this is an old template
    			 * so we need to render the endpoint content again.
    			 */
    			if ( ! did_action( 'woocommerce_account_content' ) ) {
    				if ( ! empty( $wp->query_vars ) ) {
    					foreach ( $wp->query_vars as $key => $value ) {
    						if ( 'pagename' === $key ) {
    							continue;
    						}
    						if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) {
    							ob_clean(); // Clear previous buffer.
    							wc_set_notices( $notices );
    							wc_print_notices();
    							do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
    							break;
    						}
    					}
    
    					wc_deprecated_function( 'Your theme version of my-account.php template', '2.6', 'the latest version, which supports multiple account pages and navigation, from WC 2.6.0' );
    				}
    			}
    
    			// Send output buffer.
    			ob_end_flush();
    		}
    	}

    Code of woocommerce/includes/wc-notice-functions.php:

    function wc_get_notices( $notice_type = '' ) {
    	if ( ! did_action( 'woocommerce_init' ) ) {
    		wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
    		return;
    	}
    
    	$all_notices = WC()->session->get( 'wc_notices', array() );
    
    	if ( empty( $notice_type ) ) {
    		$notices = $all_notices;
    	} elseif ( isset( $all_notices[ $notice_type ] ) ) {
    		$notices = $all_notices[ $notice_type ];
    	} else {
    		$notices = array();
    	}
    
    	return $notices;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kibizoffs

    (@kibizoffs)

    🙁 heeeelp

    Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    Looking at the stack trace in the error, you’ll notice the following: plugins/elementor (This is at #5). There also seems to be some 3rd party function calling #3 [internal function]: do_shortcode_tag(Array).

    Practically speaking, it looks like you might be using a 3rd party page builder plugin (with/without additional custom coding) that’s using a function that needs updating. Are you seeing the same thing when disabling Elementor and switching to a default theme like Storefront / TwentyTwenty? If you’d like a step-by-step guide on running that conflict test, have a look at the following guide: https://docs.woocommerce.com/document/how-to-test-for-conflicts/

    Thread Starter kibizoffs

    (@kibizoffs)

    Hello, I just deleted Account Page and created the new one. Everything works fine now.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cant edit WooCommerce account page with elementor. wc_get_notices() error’ is closed to new replies.