wc_get_account_menu_items

Get My Account menu items.

Description

(array) wc_get_account_menu_items(); 

Returns (array)


Usage

  1. if ( !function_exists( 'wc_get_account_menu_items' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-account-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_get_account_menu_items(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-account-functions.php  
  1. function wc_get_account_menu_items() { 
  2. $endpoints = array( 
  3. 'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),  
  4. 'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),  
  5. 'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),  
  6. 'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),  
  7. 'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),  
  8. 'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),  
  9. ); 
  10.  
  11. $items = array( 
  12. 'dashboard' => __( 'Dashboard', woocommerce ),  
  13. 'orders' => __( 'Orders', woocommerce ),  
  14. 'downloads' => __( 'Downloads', woocommerce ),  
  15. 'edit-address' => __( 'Addresses', woocommerce ),  
  16. 'payment-methods' => __( 'Payment methods', woocommerce ),  
  17. 'edit-account' => __( 'Account details', woocommerce ),  
  18. 'customer-logout' => __( 'Logout', woocommerce ),  
  19. ); 
  20.  
  21. // Remove missing endpoints. 
  22. foreach ( $endpoints as $endpoint_id => $endpoint ) { 
  23. if ( empty( $endpoint ) ) { 
  24. unset( $items[ $endpoint_id ] ); 
  25.  
  26. // Check if payment gateways support add new payment methods. 
  27. if ( isset( $items['payment-methods'] ) ) { 
  28. $support_payment_methods = false; 
  29. foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway ) { 
  30. if ( $gateway->supports( 'add_payment_method' ) || $gateway->supports( 'tokenization' ) ) { 
  31. $support_payment_methods = true; 
  32. break; 
  33.  
  34. if ( ! $support_payment_methods ) { 
  35. unset( $items['payment-methods'] ); 
  36.  
  37. return apply_filters( 'woocommerce_account_menu_items', $items );