Skip Navigation

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

Problem:
The client is experiencing a compatibility issue between the WooCommerce PayPal Payments plugin and WPML, specifically with translating the PayPal payment fields.
Solution:
We recommend trying the following workaround to translate the strings of the WooCommerce PayPal Payments plugin:
1. Edit the file

wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Settings/Settings.php

2. Around line 157, replace the existing code with the following:

foreach ( $defaults as $key => $value ) {
	if ( isset( $this->settings[ $key ] ) ) {
		// WPML workaround for compsupp-7085
		$this->settings[$key] = apply_filters('wpml_translate_single_string', $this->settings[$key] , 'admin_texts_woocommerce-ppcp-settings', '[woocommerce-ppcp-settings]'.$key);
		continue;
	}
	$this->settings[ $key ] = $value;
}

Please ensure you back up your database and website before making any changes.

If this solution does not apply to your case, or if it's outdated, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket in the WPML support forum.

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

Last updated by Long Nguyen 1 year ago.

Assisted by: Long Nguyen.

Author Posts
March 19, 2024 at 10:21 am #15425461

joonaP

Thanks for this, I will try your instructions a bit later. What about the paypal payment fields?

March 19, 2024 at 10:25 am #15425490

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Here is the new ticket. I can replicate the issue on a clean installation. This is a compatibility issue of the plugin WooCommerce PayPal Payments and WPML. Please try the workaround below to translate strings of this plugin.

1. Edit the file wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Settings/Settings.php

2. Around line 157, replace the code

foreach ( $defaults as $key => $value ) {
	if ( isset( $this->settings[ $key ] ) ) {
		continue;
	}
	$this->settings[ $key ] = $value;
}

with this one

foreach ( $defaults as $key => $value ) {
	if ( isset( $this->settings[ $key ] ) ) {
		// WPML workaround for compsupp-7085
		$this->settings[$key] = apply_filters('wpml_translate_single_string', $this->settings[$key] , 'admin_texts_woocommerce-ppcp-settings', '[woocommerce-ppcp-settings]'.$key);
		continue;
	}
	$this->settings[ $key ] = $value;
}

❌ IMPORTANT: Please backup your database and website before proceeding ❌

Looking forward to your reply.
Thanks

March 19, 2024 at 11:40 am #15425998

joonaP

Thanks a million, it works! You are a superstar!

March 19, 2024 at 1:13 pm #15426513

joonaP

Sorry, I closed the ticket too early. It worked fine when I was inlogged as administrator. But it did brake the site. Enclosed you'll see the error message.

Pay pal virhekoodi.jpg
March 20, 2024 at 1:58 am #15429206

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Please carefully check the code added to the file Settings.php, I applied the workaround on your staging site and it works properly.

Looking forward to your reply.
Thanks

Ma caisse • Nordic Temptations 2024-03-20 08-56-00.png
WP File Manager ‹ Nordic Temptations — WordPress 2024-03-20 08-53-54.jpg
March 21, 2024 at 7:26 am #15434534

joonaP

My sincerest apologies, it was obviously me not paying enough attention