Skip to content Skip to sidebar

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

Problem:
When using the Vikrentcar plugin with WPML on your site, the language automatically changes during the ordering process at step 3.
Solution:
To address this issue, you need to modify the code in the Vikrentcar plugin. Follow these steps:
1. Open the file at

wp-content/plugins/vikrentcar/libraries/adapter/application/route.php

.
2. Locate the function

JRoute::getPermalink()

around line 192.
3. Replace the existing code snippet within the function with the following code:

if ($post_id) {<br />    // WPML Workaround for compsupp-7493<br />    $post_id = apply_filters('wpml_object_id', $post_id, get_post_type($post_id), TRUE);<br />    $wpml_post_lang = apply_filters('wpml_post_language_details', null, $post_id);<br />    if ($wpml_post_lang) {<br />        // WPML supported, go ahead<br />        return apply_filters('wpml_permalink', get_permalink($post_id), $wpml_post_lang['language_code']);<br />    }<br />    // WPML not supported, fallback to the default behavior<br />    return get_permalink($post_id);<br />}

Please note that this is a temporary workaround. We recommend contacting the Vikrentcar plugin developer for a permanent solution.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket with us for further assistance.

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.

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 7 months ago.

Assisted by: Christopher Amirian.

Author Posts
July 21, 2024 at 12:06 pm

mehdiA-10

Background of the issue:
I used WPML plugin for my site until I installed and configured this plugin. When I clicked order on a car like: hidden link, it changes language in step 3. You need to login to see my site because it's under construction. User: vikcar, Pass: 51c^HHvFF6ghwRJFrnN, URL: karaplus.ae. I used vikcar plugin for rent car and they told me that the plugin is compatible with WPML.

Symptoms:
It changes language automatically in step 3 when I click order on a car.

Questions:
What can I do to correct this problem?

July 21, 2024 at 2:03 pm #15983333

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

The issue is reported to the compatibility team.

I will get back here as soon as I have news.

Thank you.

July 21, 2024 at 2:03 pm #15983334

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

The issue is reported to the compatibility team.

I will get back here as soon as I have news.

Thank you.

July 23, 2024 at 1:01 pm #15992524

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

We have a reply from the compatibility team.

- Open the wp-content/plugins/vikrentcar/libraries/adapter/application/route.php file.
- Inside JRoute::getPermalink(), around line 192, replace the following snippet:

protected static function getPermalink($post_id = null)
{
	// if the post ID is set, get the permalink directly
	if ($post_id)
	{
		/**
		 * Added support to WPML, since it is unable to properly obtain the
		 * correct permalink depending the requested language tag.
		 * 
		 * @since 10.1.55
		 */
		$wpml_post_lang = apply_filters('wpml_post_language_details', null, $post_id);

		if ($wpml_post_lang)
		{
			// WPML supported, go ahead
			return apply_filters('wpml_permalink', get_permalink($post_id), $wpml_post_lang['language_code']); // If we comment this line, it works as expected
		}

		// WPML not supported, fallback to the default behavior
		return get_permalink($post_id);
	}

With:

if ($post_id)
{
	/**
	 * Added support to WPML, since it is unable to properly obtain the
	 * correct permalink depending the requested language tag.
	 * 
	 * @since 10.1.55
	 */

	// WPML Workaround for compsupp-7493
	$post_id = apply_filters( 'wpml_object_id', $post_id, get_post_type($post_id) , TRUE  );

	$wpml_post_lang = apply_filters('wpml_post_language_details', null, $post_id);

	if ($wpml_post_lang)
	{
		// WPML supported, go ahead
		return apply_filters('wpml_permalink', get_permalink($post_id), $wpml_post_lang['language_code']);
	}

	// WPML not supported, fallback to the default behavior
	return get_permalink($post_id);
}

Only replace the If statement and the content inside it.

Please consider that this is only a workaround and the plugin in question is a complete plugin and needs the developer's attention to make it compatible with WPML.

So please contact the developer and inform them.

Thank you