Dev Resources

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

wc_get_account_menu_items()

Get My Account menu items.

Contents

  • Description
    • Return
    • Source
    • Changelog
  • Related
    • Uses
    • Used By
  • User Contributed Notes

Description #Description


Return #Return

(array)


Top ↑

Source #Source

File: includes/wc-account-functions.php

function wc_get_account_menu_items() {
	$endpoints = array(
		'orders'          => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
		'downloads'       => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
		'edit-address'    => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
		'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
		'edit-account'    => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),
		'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
	);

	$items = array(
		'dashboard'       => __( 'Dashboard', 'woocommerce' ),
		'orders'          => __( 'Orders', 'woocommerce' ),
		'downloads'       => __( 'Downloads', 'woocommerce' ),
		'edit-address'    => __( 'Addresses', 'woocommerce' ),
		'payment-methods' => __( 'Payment methods', 'woocommerce' ),
		'edit-account'    => __( 'Account details', 'woocommerce' ),
		'customer-logout' => __( 'Logout', 'woocommerce' ),
	);

	// Remove missing endpoints.
	foreach ( $endpoints as $endpoint_id => $endpoint ) {
		if ( empty( $endpoint ) ) {
			unset( $items[ $endpoint_id ] );
		}
	}

	// Check if payment gateways support add new payment methods.
	if ( isset( $items['payment-methods'] ) ) {
		$support_payment_methods = false;
		foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway ) {
			if ( $gateway->supports( 'add_payment_method' ) || $gateway->supports( 'tokenization' ) ) {
				$support_payment_methods = true;
				break;
			}
		}

		if ( ! $support_payment_methods ) {
			unset( $items['payment-methods'] );
		}
	}

	return apply_filters( 'woocommerce_account_menu_items', $items, $endpoints );
}

Expand full source code Collapse full source code


Top ↑

Changelog #Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
woocommerce.php: WC()

Returns the main instance of WC.

includes/wc-conditional-functions.php: wc_shipping_enabled()

Is shipping enabled?

Top ↑

Used By #Used By

Used By
Used By Description
includes/admin/class-wc-admin-customize.php: WC_Admin_Customize::register_customize_nav_menu_items()

Register account endpoints to customize nav menu items.

includes/admin/class-wc-admin-menus.php: WC_Admin_Menus::nav_menu_links()

Output menu links.


Top ↑

User Contributed Notes #User Contributed Notes

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

Proudly powered by WordPress