I ran into this issue: Any link in my code/theme/plugin to standard Woocommerce pages did not go to the correct translated page!
However the solution provided here will break whenever WooCommerce is updated. The correct way of solving this is adding some filters…
//20210216 - (c) My Brain - correction for function wc_get_page_id()
function woocommerce_translate_polylang_page_id($pageid) {
if (!empty($pageid)) {
if (PLL() instanceof PLL_Frontend) {
$pllpageid = pll_get_post($pageid);
if (!empty($pllpageid)) {
$pageid = $pllpageid;
}
}
}
return $pageid;
}
//myaccount, edit_address, shop, cart, checkout, pay, view_order, terms
add_filter( 'woocommerce_get_myaccount_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_edit_address_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_shop_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_cart_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_checkout_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_pay_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_view_order_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
add_filter( 'woocommerce_get_terms_page_id', array( $this, 'woocommerce_translate_polylang_page_id' ), 10, 1 );
Have a nice day!