As of WooCommerce 7.4.0, we’ve seen that there’s a problem with the Addresses tab in the WooCommerce My Account area when the site is using British English translations.
We’ve done some investigating and it’s because of a missing/blank translation in the core WooCommerce file, “woocommerce-en_GB.po”.
The following code snippet will fix the problem, and also catch any future empty/missing translations for My Account menu items.
Place the following code into your custom child theme’s functions.php, or you can use a code snippets plugin if you prefer.
/**
* Fix missing WooCommerce My Account menu item translation(s).
*
* Original post: https://power-plugins.com/news/woocommerce-missing-addresses-menu-item/
*/
function pp_fix_account_menu_item_translations($items, $endpoints) {
$fixed_items = array();
$original_items = array(
'dashboard' => 'Dashboard',
'orders' => 'Orders',
'downloads' => 'Downloads',
'edit-address' => 'Addresses',
'payment-methods' => 'Payment methods',
'edit-account' => 'Account details',
'customer-logout' => 'Logout',
);
foreach ($items as $slug => $label) {
if (empty($slug)) {
// This shouuld never happen.
} elseif (!empty($label) || !array_key_exists($slug, $original_items)) {
// Pass through the current value.
$fixed_items[$slug] = $label;
} else {
// Replace the empty label with the stock label.
$fixed_items[$slug] = $original_items[$slug];
}
}
return $fixed_items;
}
add_filter('woocommerce_account_menu_items', 'pp_fix_account_menu_item_translations', PHP_INT_MAX, 2);Save that, go back to your My Account area and you should see the “Addresses” menu item has been set back to the stock label, “Addresses” 👍
