Skip Navigation

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

Problem:

When switching to client account from My Account page (feature provided by Sales Agent for WooCommerce plugins) and using Domain Per language WPML settings, the action does not works and redirects backs to my account page.

Solution:

- Backup the site completely first to prevent any issues or better test this on a staging site first.

- Open the wp-content\plugins\sales-agent-for-woocommerce\includes\admin\classes\user\wc-user-switching.php file

- Around line 143, replace the following code:

} else {
	wp_safe_redirect( add_query_arg( $args, admin_url() ), 302, self::$application );
}

- With the following code:

} else {							
	$redirect_to = admin_url();
	// WPML Workaround for compsupp-6847
	if ( class_exists('Sitepress') ) {
		$my_account_page = wc_get_page_id( 'myaccount' );
		if ($my_account_page) {
			$redirect_to = get_permalink($my_account_page);
		}								
	}
	wp_safe_redirect( add_query_arg( $args, $redirect_to ), 302, self::$application );
}

Relevant Documentation:
N/A

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

Last updated by Subash Chandra Poudel 1 year, 11 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
June 5, 2023 at 11:01 am

Fabio Antonio Troietto

Hi, I have an installation of woocommerce and WPML

i have installed this plugin https://woocommerce.com/products/sales-agent-for-woocommerce/ and all work correctly until one week.

Now. i'm in italian page my-account, click in 'effetuare ordine' and instead open a page off account-client in italian language open my-account in french language

I contact plugin assistance but tell me that is problem of cache but is not cache problem i think is problem of language change and not open correct link in same language

June 5, 2023 at 11:25 am
June 5, 2023 at 5:55 pm #13774133

Subash Chandra Poudel

Hi there, It looks like when you click on the "Effettuare un ordine" button it switches you as that user and you then view the my account page of that user in the profile language of that user. So this looks fine and as expected.

Or am I missing something here? Can you please let me know what exact page or content are you expect when you click on the "Effettuare un ordine" button?

June 7, 2023 at 9:30 am #13783683

Fabio Antonio Troietto

Please look this video hidden link.

button "Effettuare un ordine" button? Not open client account but load my-account page in french language.

Is not account problem because the same problem happens to all agents.

Thank you

June 8, 2023 at 9:51 am #13791789

Subash Chandra Poudel

Hi there,

I looked into the issue further and it looks like the Switch to user works only when you are on the French page and does not works ( redirects to French my account page ) when you try to switch as user from Italian or English page.

I see the Sales Agent For WooCommerce Plugin is not tested by us and is not listed as compatible with WPML at https://wpml.org/plugin/

I also checked the Plugin sales page https://woocommerce.com/products/sales-agent-for-woocommerce/ and I dont see any claim to be compatible to be WPML.

So some issues could be expected. I tried understating how the plugin works and how it is setup to see if we can fix it with some settings/options in WPML but looks like the plugin has minimal setup options and the switch user feature not working could be a coding or incompatibility issue.

In this case, I recommend you to contact the plugin provider and see if they are are compatible with WPML. If not please ask them to join our Go Global program at https://wpml.org/documentation/support/go-global-program/ so that we can help them make the plugin compatible with WPML.

If that does not helps, I recommend you to use a different plugin that is tested with WPML and listed at https://wpml.org/plugin/.

June 15, 2023 at 10:20 am #13831393

Fabio Antonio Troietto

Hi,

thank you for your response.
i contact with plugin Agent Sales Developers plugin and and after some test, they answer me this:

'Hi there,

We try our best to fix this issue but after thorough debugging, we have identified that the issue originates from the WPML plugin. We want to emphasize that we are not responsible for any functionality that alters the domain. However, we have observed that switching the user from a sales agent to a customer works correctly. Upon returning to the same domain, you will notice that the user has already been successfully switched to the corresponding customer.

I hope you will understand it.

Thanks'

Please, i need find a solution of this problem. And now change the plugin is not an option.

Thank you

June 15, 2023 at 2:37 pm #13833415

Fabio Antonio Troietto

another answer for developer of the plugin:


Our findings are here:

The URL is redirecting to:
hidden link
This:
hidden link

We have checked after setting the cookie to the same domain and path as the Italian version of the website. also, we used the

IMAGE

query parameter for the website redirection &lang=it, and this didn’t work either.

Thanks'

jira-generated-image-static-3d552165-e4d5-469f-92c8-6ec571a7e369.jpg
June 16, 2023 at 9:43 am #13838139

Subash Chandra Poudel

Hi there,

Since the plugin "Sales Agent For WooCommerce" does not seem to work well with WPML and thus this is an incompatibility issue between WPML and Sales Agent For WooCommerce the proper way to resolve this issue ( and all issues due to incompatibilities that are not known yet ) would be that the plugin provider contact us through our Go Global Program linked next:

https://wpml.org/documentation/support/go-global-program/

I recommend you to contact the plugin provider again and ask them to contact us through the link so that we can work together to resolve the incompatibilities. This is important specially because fixing incompatibility issues like this might require change in both WPML and/or the Plugin and we need their collaboration to do so.

Anyway, in this case I can forward this issue to our second tier team and see if we can at least provide some workaround/temporary fix for now to make the site and the feature functional.

For me to do that we need to do a few more test.

- Can you please backup your current site completely then change the Language URL format to language in directories from WPML -> Languages -> Language URL format and see if the issue persist or not?

- If the issue persist after Language URL format change lets replicate the issue on a test site, can you please login to the sandbox site I setup for you at hidden link and setup WPML and your plugin and let me know if the issue persist there, and is yes, how I can check it?

Also, for further troubleshooting if required, Is it okay if we copy/duplicate your site to a test site at our end?

Regards,
Subash

June 16, 2023 at 11:17 am #13838865

Fabio Antonio Troietto

Hi subash,

thank you for your answer.

I telled to plugin developer that contact you from https://wpml.org/documentation/support/go-global-program/

I hope he contact you.

- Can you please backup your current site completely then change the Language URL format to language in directories from WPML -> Languages -> Language URL format and see if the issue persist or not?

i test it and you can see result here: hidden link

- If the issue persist after Language URL format change lets replicate the issue on a test site, can you please login to the sandbox site I setup for you at hidden link and setup WPML and your plugin and let me know if the issue persist there, and is yes, how I can check it?

I Check and configure it.

- Also, for further troubleshooting if required, Is it okay if we copy/duplicate your site to a test site at our end?

Is not a problem, only for privacy is preferred if the duplicate site is not available for external user, and confirm me ,when work is ended, that the data be cancelled.

June 16, 2023 at 11:57 am
June 19, 2023 at 3:43 pm #13853227

Fabio Antonio Troietto

Hi Subash,

have some news for me?

Thank you

June 19, 2023 at 4:57 pm #13853605

Subash Chandra Poudel

Thank you for the details, and sorry for the delayed response due to the weekends.

I tried to test the issue further with a copy of the site but because the issue seem to be there only in a domain per language setup I was unable to test it clearly with a conclusive result in my local test environment.

Will it be possible for you to test the following on a your site?

- Make sure to backup the site completely to prevent any issues or if possible make a copy of the site on a similar domain per language setup and test it on that test site instead.

- Deactivate all plugins except WPML plugins, WooCommerce and Sales Agent for WooCommerce.

- Activate a default theme like twenty twenty one.

- Now test if the issue persist or not.

- If the issue no longer persist activate the original theme and plugins one at a time to see which one starts the issue again.

Please let me know how the test goes.

June 22, 2023 at 4:29 pm #13879617

Fabio Antonio Troietto

Hi,

sorry for delay of my answer.
I try test it this week-end.

I will keep you informed

Best Regards

June 22, 2023 at 4:49 pm #13879771

Subash Chandra Poudel

Sure, please let me know how the test goes once done.

June 25, 2023 at 5:26 pm #13891145

Fabio Antonio Troietto

Hi,

I did a test and the problem persists. I'll tell you one more thing.
Watch the video and maybe it can be interesting to understand the problem.
If I go back and load my-account page, the client is loaded.
Couldn't it be something related to cookies or some setting of the records or dns that manage the subdomains?

hidden link