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

Last updated by Shekhar Bhandari 5 months, 3 weeks ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
March 14, 2019 at 11:48 am #3343969

chadJ

I am trying to:

On my Woocommerce site I have 2 payment methods. Each of these sends a callback to my site after the transaction.

Link to a page where the issue can be seen:

An example of the transaction API callback request is:
hidden link

I expected to see:

After a successful payment (or error) I expected the callback to be received and the status updated accordingly in Woocommerce.

Instead, I got:

Instead, the callback is never received.

More info:

My WPML is setup to use different directories for each language.

I use a root HTML file called lang.php that has the following contents sourced from these forums:

<?php
if(substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) == 'sv' ) {
header( 'Location: /sv/' );
}else {
header( 'Location: /en/' );
}
?>

This redirect code is intercepting the API requests and directing to /en/ where the callback doesn't register.

How can I change lang.php so that it redirects users but doesn't interfere with API callbacks such as `hidden link`

Thanks
Chad

March 15, 2019 at 4:14 am #3351197

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to assist you further on this issue.

It seems like a theme/plugin conflict or a PHP error that is blocking some functionalities and creating such issues, so could you please perform the below steps and let me know if that helps?

Minimal Setup

If you disable all non-related WPML plugins, switch to one of the default themes, the problem persists or not?

NOTE:
+ Make a backup (both files and database) for your site before updating/proceeding anything (Always a good practice!).

Debugging

1. Please follow the debugging information provided here: http://wpml.org/documentation/support/debugging-wpml/
2. Repeat the action of creating the problem.
3. Copy and paste the contents of debug.log (log file inside the /wp-content/ directory) here for me to see.

Look forward to your reply.

Thanks

March 15, 2019 at 10:55 am #3353145

chadJ

Hello. Thanks for your response.

I disabled all other plugins and tested it, and the problem was still there.
I've also tried switching themes.

php_error.log

[15-Mar-2019 10:48:40 UTC] PHP Warning:  Use of undefined constant yes - assumed 'yes' (this will throw an Error in a future version of PHP) in /www/wp-content/plugins/woo-swish-e-commerce/classes/api/woo-swish-api.php on line 48
[15-Mar-2019 10:48:42 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:48:45 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:48:48 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:48:51 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:48:54 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:48:57 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:00 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:03 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:05 UTC] PHP Notice:  Undefined index: HTTP_ACCEPT_LANGUAGE in /www/lang.php on line 3
[15-Mar-2019 10:49:06 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:09 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:12 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:15 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:18 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:21 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:24 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:27 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:30 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:36 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:40 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:49:48 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198
[15-Mar-2019 10:50:02 UTC] PHP Notice:  Undefined variable: order_id in /www/wp-content/plugins/woo-swish-e-commerce/woo-swish-e-commerce.php on line 198

access.log

157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:12:49 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:12:51 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:12:50 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
66.249.76.115, 127.0.0.1 - - [15/Mar/2019:10:16:23 +0000] "GET <em><u>hidden link</u></em> HTTP/1.0" 200 5814 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +<em><u>hidden link</u></em>)" hinterland.se hit fwhash:egihbgb2sr FLYWHEEL_BOT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:16:23 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:31:44 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:33:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:35:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:36:49 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:37:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:38:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:40:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:42:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:44:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:46:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:47:43 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
83.233.137.254, 127.0.0.1 - - [15/Mar/2019:10:47:54 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 302 0 "<em><u>hidden link</u></em>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15" hinterland.se miss fwhash:egihbgb2sr VISIT
83.233.137.254, 127.0.0.1 - - [15/Mar/2019:10:47:54 +0000] "GET <em><u>hidden link</u></em> HTTP/1.0" 200 213598 "<em><u>hidden link</u></em>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15" hinterland.se miss fwhash:egihbgb2sr VISIT
83.233.137.254, 127.0.0.1 - - [15/Mar/2019:10:48:08 +0000] "GET <em><u>hidden link</u></em> HTTP/1.0" 200 280670 "<em><u>hidden link</u></em>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15" hinterland.se miss fwhash:egihbgb2sr VISIT
83.233.137.254, 127.0.0.1 - - [15/Mar/2019:10:48:15 +0000] "GET <em><u>hidden link</u></em> HTTP/1.0" 200 281019 "<em><u>hidden link</u></em>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:48:32 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
83.233.137.254, 127.0.0.1 - - [15/Mar/2019:10:48:32 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 84 "<em><u>hidden link</u></em>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15" hinterland.se miss fwhash:egihbgb2sr VISIT
213.132.115.94, 127.0.0.1 - - [15/Mar/2019:10:49:04 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 302 0 "-" "Apache-HttpClient/4.5.3 (Java/1.8.0_121)" hinterland.se miss fwhash:egihbgb2sr FLYWHEEL_BOT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:49:12 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
157.230.99.82, 127.0.0.1 - - [15/Mar/2019:10:49:36 +0000] "POST <em><u>hidden link</u></em> HTTP/1.0" 200 0 "<em><u>hidden link</u></em>" "WordPress/5.1.1; <em><u>hidden link</u></em>" hinterland.se miss fwhash:egihbgb2sr VISIT
March 15, 2019 at 11:06 am #3353281

chadJ

I did some more debugging, and was able to get it working.

In WPML Language URL format settings I selected "Different languages in directories" and unchecked "Use directory for default language" and I was able to complete a transaction.

The previous setting I had "Use directory for default language" checked and set to lang.php above. This doesn't work.

Progress!

But how can I have a both /en/ and /sv/ and a root page that redirects users?

March 16, 2019 at 1:53 pm #3360491

chadJ

I did some more debugging.

Instead of a "html file" I chose a "a page" and the callback worked successfully.
As above it also worked with the default settings.

However transaction callbacks do NOT work when a "html file" is selected (or at least not the php file I was using).

Note: despite my saying "it works" the desired configuration does not work, so this is still an issue.

March 18, 2019 at 9:24 am #3367233

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

To further debug this issue, I need to request temporary access (wp-admin and FTP) to your site in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. hidden link

These info is private, and available to you and supporters only. Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note that:

#1
Backup (both files and database) your site before giving us your credentials. You can use a plugin for this if you like. I often use the Duplicator plugin for this purpose.
See: http://wordpress.org/plugins/duplicator/

Duplicator instruction
hidden link

#2
It would be better if you give me the test site rather than the live site.

#3
If the issues needs some changes in the plugins updates/disabling we will install a plugin called “duplicator” and replicate the site in our local server for testing.

Look forward to your reply.

Thanks

March 19, 2019 at 8:39 am #3376399

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

The wp-login details is not working, so could you please check it once, you can edit the previous private reply to update the details.

Thanks

March 19, 2019 at 8:41 am #3376411

chadJ

The login should work now.

March 19, 2019 at 11:37 am #3378529

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

I can reproduce the issue and In order to be better help on this issue, I have escalated this issue to our 2nd tier supporter.

Our 2nd tier supporter will take a look at this issue. Once they provide any feedback, I will get back to you with that feedback here.

Thanks

March 25, 2019 at 9:11 am #3450667

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I just received the feedback from the 2nd tier supporter and they mentioned that the use of code in the lang.php is forwarding all requests to your site to either one or the other URL, depending on the browser language.

Forwarding these requests in this manner does not allow for the site to parse the callback from the payment gateway as it disregards all posted data and just redirects.

Being so, you should handle this case with some custom code that detects the expected parameters and do not forward the request.

An example will be to bypass the callback URL to not use this redirect using some PHP code.

Let me know if this helps.

Thanks

March 26, 2019 at 5:19 pm #3465129

chadJ

> Forwarding these requests in this manner does not allow for the site to parse the callback from the payment gateway as it disregards all posted data and just redirects.

That isn't accurate, as the script (taken from your support staff on this site) works with a vanilla install. Something else is going on that prevents the API calls to be working.

> An example will be to bypass the callback URL to not use this redirect using some PHP code. Let me know if this helps.

Sorry, this doesn't help. How can WPML callbacks work when using a redirect root file?

March 27, 2019 at 3:37 am #3467443

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I already tested the issue on a fresh installation and it's not working, regarding the vanilla installation you mentioned, could you please provide login details for that install so I can check what's different in that server rather than our test site?

Enabled the private reply for you.

Further, the root page of your website is the content that loads when visitors access your domain name, i.e. “mysite.com” in a web browser. In case you are using the Use directory for default language option, the starting page will be the same for all your visitors, regardless of the available languages on your site.
https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/#what-is-a-root-page-and-do-i-need-one

Using the code we are using some redirect to display default language in the URL for default language too, this creation is creating conflicts with callbacks URL i.e. in the case probably, payment callback URL.

You can contact the plugin developer and ask how the order status is being retrieved back so you can create custom code to bypass the callback URL to not use this redirect using some PHP code.

Look forward to your reply.

Thanks

April 15, 2019 at 12:02 pm #3613227

chadJ

Still haven't the problem, and this suggested steps don't seem to address the issue.

April 15, 2019 at 1:07 pm #3613597

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Could you provide feedback on my latest reply? I would be happy to help you further here.

Please provide login details to the site where the issue couldn't be reproduced.

Look forward to your reply.

Thanks

April 24, 2019 at 7:07 am #3669739

chadJ

Hi,
Thanks for your reply.

I setup a clean install that I could send you, but I failed to fix things on a clean install.????

As for asking plugin authors to fix this, well it isn't just an issue with one plugin. Several plugins use the WC callback API and it is impractical to ask everyone to re-write their plugins.

So I'm not sure where this leaves us, but the core WC API is broken when using a WPML configuration.

Is there another way to solve this problem? I'll restate it to see if we can think of another approach:

My site has languages setup like:
/en
/sv

I'd like users coming to / to redirect to /sv if they are in Sweden, or /en if they are elsewhere.

What is the recommended way to achieve this?