Add a hook to replace the existing My Account header menu
-
I’ve been in contact with the support team of the plugin My Account Customizer on Envato : https://codecanyon.net/item/woocommerce-customize-my-account-pro/31059126
And I’d need an improvement on WoodMart theme so that your My Account dropdown menu can be replaced and customized by whatever we wish to.
File to edit wp-content\themes\woodmart\inc\integrations\woocommerce\template-tags.php between line 1887-1904 find below given code
// **********************************************************************//
// ! My account menu
// **********************************************************************//
if ( ! function_exists( 'woodmart_get_my_account_menu' ) ) {
function woodmart_get_my_account_menu() {
$user_info = get_userdata( get_current_user_id() );
$user_roles = $user_info->roles;
$out = '<ul class="wd-sub-menu' . woodmart_get_old_classes( ' sub-menu' ) . '">';
foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
$out .= '<li class="' . wc_get_account_menu_item_classes( $endpoint ) . '"><a href="' . esc_url( wc_get_account_endpoint_url( $endpoint ) ) . '"><span>' . esc_html( $label ) . '</span></a></li>';
}
return $out . '</ul>';
}
}
and replace it with
// **********************************************************************//
// ! My account menu
// **********************************************************************//
if ( ! function_exists( 'woodmart_get_my_account_menu' ) ) {
function woodmart_get_my_account_menu() {
$user_info = get_userdata( get_current_user_id() );
$user_roles = $user_info->roles;
$out = '<ul class="wd-sub-menu' . woodmart_get_old_classes( ' sub-menu' ) . '">';
foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
$out .= '<li class="' . wc_get_account_menu_item_classes( $endpoint ) . '"><a href="' . esc_url( wc_get_account_endpoint_url( $endpoint ) ) . '"><span>' . esc_html( $label ) . '</span></a></li>';
}
$out .= '</ul>';
return apply_filters('woodmart_override_heading_my_account_menu',$out);
}
}
Can you perform this change please?
Thanks
Hello,
To override this content you can copy the whole function woodmart_get_my_account_menu to the child theme’s functions.php file and apply your changes there.
Kind Regards