Open
Reported for: WooCommerce Multilingual & Multicurrency 5.3.2
Overview of the issue
When using WooCommerce Multilingual, setting the my-account page as a child of the shop page can lead to 404 errors accessing My Account endpoints (like Orders, Downloads, etc.) in secondary languages. This issue typically occurs with permalink settings like Shop base with category or Shop base.
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open theme’s functions.php file.
- Add the following code:
add_filter( 'init', function() { $my_account_page_id = wc_get_page_id( 'myaccount' ); $my_account_parent_id = get_post_parent( $my_account_page_id ); if ( $my_account_page_id && $my_account_parent_id ) { $default_language = apply_filters( 'wpml_default_language', '' ); $languages = apply_filters( 'wpml_active_languages', [] ); foreach ( $languages as $language ) { if ( $language['code'] !== $default_language ) { $translated_id = apply_filters( 'wpml_object_id', $my_account_page_id, 'page', true, $language['code'] ); if ( $translated_id ) { $translated_url = get_page_uri( $translated_id ); add_rewrite_rule( trailingslashit( $translated_url ) . '?$' , 'index.php?pagename=' . $translated_url, 'top' ); foreach ( WC()->query->query_vars as $endpoint ) { $translated_endpoint = apply_filters( 'wpml_get_endpoint_translation', $endpoint, $endpoint, $language['code'] ); add_rewrite_rule( trailingslashit( $translated_url ) . $translated_endpoint . '(/(.*))?/?$' , 'index.php?' . $endpoint . '=$matches[2]&pagename=' . $translated_url, 'top' ); } } } } } } );