Dev Resources

  • Home
  • Reference
  • BuddyX Theme
  • Functions
  • Hooks
  • Classes
Filter by type:
Search
Browse: Home / Reference / Classes / WC_Shortcode_My_Account / WC_Shortcode_My_Account::output()

WC_Shortcode_My_Account::output( array $atts )

Output the shortcode.

Contents

  • Description
    • Parameters
    • Source
  • Related
    • Uses
  • User Contributed Notes

Description #Description


Parameters #Parameters

$atts

(Required) Shortcode attributes.


Top ↑

Source #Source

File: 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();

			// 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();
		}
	}

Expand full source code Collapse full source code


Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
woocommerce.php: WC()

Returns the main instance of WC.

includes/wc-notice-functions.php: wc_get_notices()

Returns all queued notices, optionally filtered by a notice type.

includes/wc-notice-functions.php: wc_print_notices()

Prints messages and errors which are stored in the session, then clears them.

includes/wc-notice-functions.php: wc_add_notice()

Add and store a notice.

includes/wc-notice-functions.php: wc_set_notices()

Set all notices at once.

includes/wc-core-functions.php: wc_get_template()

Get other templates (e.g. product attributes) passing attributes and including the file.

includes/wc-template-functions.php: wc_logout_url()

Get logout endpoint.

includes/wc-deprecated-functions.php: wc_deprecated_function()

Wrapper for deprecated functions so we can apply some extra logic.

includes/shortcodes/class-wc-shortcode-my-account.php: WC_Shortcode_My_Account::lost_password()

Lost password page handling.

includes/shortcodes/class-wc-shortcode-my-account.php: WC_Shortcode_My_Account::my_account()

My account page.

includes/shortcodes/class-wc-shortcode-my-account.php: woocommerce_my_account_message

My Account Shortcodes

includes/shortcodes/class-wc-shortcode-my-account.php: woocommerce_account_{$key}_endpoint

Deprecated my-account.php template handling. This code should be removed in a future release.

Show 7 more uses Hide more uses

Top ↑

User Contributed Notes #User Contributed Notes

You must log in before being able to contribute a note or feedback.

Proudly powered by WordPress