Hi,
I suspect ... WordPress Admin > Settings > General your Site Address option is missing the locale portion of the url
Yes, and that is the expected behaviour.
When I echo home_url() the url is correct and includes /en/.
Thank you for the link in your reply!!
Looking at the source code, I saw on line 843:
$api_request_url = trailingslashit( home_url( '/wc-api/' . $request, $scheme ) );
This is where the issue occurs! Looks like the path you set in ‘ ‘ overrides the url set by Polylang. However, you added a filter on line 851 (great!)
apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl )
So here’s a little snippet that adds the language slug to the url:
function ppl_api_request_url($api_request_url, $request, $ssl) {
$ppl_url = trailingslashit( home_url('/'.pll_current_language().'/wc-api/' . $request, $scheme ) );
return $ppl_url;
}
add_filter('woocommerce_api_request_url', 'ppl_api_request_url', 10, 3);
Tested and works!
Thank you again for your help and support!
-
This reply was modified 1 year, 3 months ago by
Massimo.