Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 1 voice.

Last updated by quintinA 3 years, 1 month ago.

Author Posts
October 24, 2017 at 10:58 am #1409875


WPML Multilingual CMS 3.8.3
WPML String Translation 2.6.2
WPML Translation Management 2.4.0
WPML Media 2.2.1
WooCommerce Multilingual 4.2.5
WooCommerce Advanced Ajax Layered Navigation 1.4.10

There's a problem using the ajax filters on translated pages, see:
hidden link

I noticed the following, when i click on a filter, the URL filter parameters are added with a / in front of it:
Example: hidden link

When i remove the / the URL and all translations work fine:
hidden link

I haven't investigated this problem any further but i suspect the problem lies with WOO advanched ajax layered nav, but i'm hoping WPML already encountered this problem and has a good solution ;-).

Best regards,
Bjorn Joosen

October 24, 2017 at 12:04 pm #1409974


Well, maybe i should have started with my investigation before creating this post.. After a quick look at the WooCommerce Advanched Ajax layered Nav plugin the problem was quickly found.

File: plugins/woocommerce-ajax-layered-nav/widgets/class-sod-widget-ajax-layered-nav.php
Function: get_page_base_url()
Row: +/- 650

After collecting the correct base URL i found this line:

$link .= ( substr( $link, -1 ) == '/' ? '' : '/' );

Which basically adds a trailing slash when the base url does not end with a slash. We do not want this when using WPML ?lang= URL parameters.

Simple fix, maybe a bit dirty:

// URL WPML FIX: do not add trailing slash when lang url parameter is active
if (strpos($link, 'lang=') === false) $link .= ( substr( $link, -1 ) == '/' ? '' : '/' );
//$link .= ( substr( $link, -1 ) == '/' ? '' : '/' );

I will ask WooCommerce that they change this function to be compatible with WPML.

Best regards,
Bjorn Joosen

November 7, 2017 at 5:40 pm #1423578


A quick follow up.

I've contacted Woocommerce and they created a Github feature request.

If/when it is fixed it will visible in the changelog, which can be found here:
hidden link