0

I have been trying to change the language of mini cart without success. It keeps showing the same default set language, even though I choose a different language using polylang.

I have tried the below code in functions.php, but it keeps returning the same French version of the page.

   function modify_cart_url($wc_get_page_permalink) {
    $setLocale = pll_current_language();
    echo $cart_page_id = pll_get_post(2374,"$setLocale");
    $wc_get_page_permalink = get_permalink($cart_page_id);
    return $wc_get_page_permalink;
  }
  add_filter( 'woocommerce_get_cart_url', 'modify_cart_url',10, 1);

2374 is the page ID of the French cart page.

Mini cart locale problem in woocommerce

Cœur
  • 37,241
  • 25
  • 195
  • 267
Pankaj Kumar
  • 129
  • 1
  • 12

1 Answers1

1

So in case if anyone facing the same problem,

You can copy the complete woocommerce - mini-cart.php code inside the header.php of your theme.

After that you can get the correct locale set whenever you change the language using polylang. And the get the cart page url of that particular language.

$curr_set_lan =get_locale();
$woo_cart_page_id = get_option( 'woocommerce_cart_page_id' );   
the_permalink(pll_get_post($woo_cart_page_id, $curr_set_lan));
Pankaj Kumar
  • 129
  • 1
  • 12