Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

WooCommerce Multilingual - Product category base issue with children categories in an a tag.

Solution:

This issue is solved with the latest version of WPML (4.4.4).

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 25 replies, has 2 voices.

Last updated by Itamar 3 months, 1 week ago.

Assigned support staff: Itamar.

Author Posts
December 20, 2019 at 11:37 am #5170259

pierS-2

Hi again,

the problem is not related to HTML block.

We have the same problem also with attached link.

Please let me know.

December 22, 2019 at 9:16 pm #5180305

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

In this case, you need to insert the full path of the URL for the 'href' attribute. Please see the attached screenshot. Then the link supposes to work. On your site, the link is to another site and I couldn't find the product page, so I couldn't check it.

Please let me know if this information is helpful to you.

Regards,
Itamar.

December 23, 2019 at 10:30 am #5183541

pierS-2

HI AGAIN,

It seems that you don't want to understand the problem.

We already tried to add teh full url but once saved it is converted to the short url.

It's the same problem as the link in top header.

Please try and let me know

December 24, 2019 at 3:40 pm #5189843

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

I'm sorry for the inconvenience that was caused to you.
Yes, I can see now the issue on your staging site.
I think that it is related to the permalinks structure.
But I haven't completely found the cause yet.
I'm still debugging this issue.

I have a request from you, please.
Can you please send me a screenshot of the Permalinks settings on your live site?
This is in Settings -> Permalinks. I need please to see all the settings. For example, like this: Please see the attached screenshots.

Thanks,
Itamar.

December 25, 2019 at 10:15 pm #5193263

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

I've progress here with this issue. It seems to be happening with child product categories that are placed in <a> tags. Tomorrow I'll be able to escalate this.

Thanks,
Itamar.

December 26, 2019 at 10:50 am #5195529

pierS-2

HI,

We have the same settings in permalinks live site.

Please let me know what you found.

regards

December 26, 2019 at 8:22 pm #5197165

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi

After a long debugging process, I've found what the issue on your site was.
In Settings -> Permalinks, you have used 'shop' as the Product category base slug.
But it was not translated to the other languages. Once, I translated this slug in WooCommerce -> WooCommerce Multilingual -> Store URLs (also possible to translate it in String Translation), the problem is not happening. Please see the attached screenshot.

Can you please check that and confirm that the issue is solved?

Thanks,
Itamar.

December 27, 2019 at 11:08 am #5200021

pierS-2

HI,

It always worked before with the same /shop/ in different language folder.

December 30, 2019 at 2:32 pm #5211769

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

I've escalated this issue to our second tier supporters. They will check it and once I have news from them I'll let you know here.

Thank you for your patience.
Itamar.

January 7, 2020 at 2:54 pm #5247811

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

Our second tier supporter was able to replicate this issue and found the source of the problem. The issue is now escalated to our developers. When I have more information on this issue, I'll let you know here.

Regards,
Itamar.

January 8, 2020 at 1:30 pm #5254699

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

As mentioned the issue is escalated to our developers. But meanwhile, we can share a workaround with you. Here is what you need to do.

1. Take a backup of your site.

2. Open the following file with the code editor that you are using.

wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php

3. At line 471 see this 'private function':

	private function get_regex_replacement( $def_url,
										    $type,
											$type_id,
										    $lang_negotiation,
											$lang,
											$dir_path,
											$home_url,
											$url_parts,
											$req_uri_params,
											$anchor_output ) {

		if ( $lang_negotiation == 1 && $lang ) {
			$langprefix = '/' . $lang;
		} else {
			$langprefix = '';
		}
		$perm_url = '(' . rtrim( $home_url, '/' ) . ')?' . $langprefix . '/' . str_replace( '?', '\?', $dir_path );
		$regk     = '@href=[\'"](' . $perm_url . ')[\'"]@i';
		$regv     = 'href="' . '/' . ltrim( $url_parts[ 'path' ], '/' ) . '?' . $type . '=' . $type_id;
		if ( $req_uri_params != '' ) {
			$regv .= '&' . $req_uri_params;
		}
		$regv .= $anchor_output . '"';
		$def_url[ $regk ] = $regv;
		return $def_url;
	}

4. Add this code to the function:

		//Check if have more than 1 slug on type_id. If so, explode then get only the last item:
		if (strpos($type_id, '/') !== false) {
			$type_id_strings = explode("/", $type_id);
			$type_id = end($type_id_strings);
		}

5. It will look like this after the change:

	private function get_regex_replacement( $def_url,
										    $type,
											$type_id,
										    $lang_negotiation,
											$lang,
											$dir_path,
											$home_url,
											$url_parts,
											$req_uri_params,
											$anchor_output ) {
		//Check if have more than 1 slug on type_id. If so, explode then get only the last item:
			if (strpos($type_id, '/') !== false) {
				$type_id_strings = explode("/", $type_id);
				$type_id = end($type_id_strings);
			}
		if ( $lang_negotiation == 1 && $lang ) {
			$langprefix = '/' . $lang;
		} else {
			$langprefix = '';
		}
		$perm_url = '(' . rtrim( $home_url, '/' ) . ')?' . $langprefix . '/' . str_replace( '?', '\?', $dir_path );
		$regk     = '@href=[\'"](' . $perm_url . ')[\'"]@i';
		$regv     = 'href="' . '/' . ltrim( $url_parts[ 'path' ], '/' ) . '?' . $type . '=' . $type_id;
		if ( $req_uri_params != '' ) {
			$regv .= '&' . $req_uri_params;
		}
		$regv .= $anchor_output . '"';
		$def_url[ $regk ] = $regv;
		return $def_url;
	}

6. Save the chenge and now the problem should be fixed.

Note: You might need to re-save the related strings in String Translation. If you update WPML with a new version and this fix is not included yet, you will have to add it again.

When the version with the fix will be released I'll let you know here.

Regards,
Itamar.

October 18, 2020 at 6:47 am #7251029

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

This issue is solved with the latest version of WPML (4.4.4).
Please update our plugins on your site to their latest versions.
If you think that this problem is not solved on your site then please open a new ticket on our support forum.

Regards,
Itamar.