Skip Navigation

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

Last updated by Noman 2 years, 1 month ago.

Assigned support staff: Noman.

Author Posts
July 26, 2018 at 11:50 pm #2586232

jeroenv-42

I am trying to register a functions.php snippet as a translatable string in WPML, but I don't know how. Here's the snippet:

add_filter( 'woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2 );
 
function bbloomer_change_processing_email_subject( $subject, $order ) {
$subject = $order->get_billing_first_name() . ', Thanks for your Spikes & Sparrow order!';
return $subject;
}

How do I register

Thanks for your Spikes & Sparrow order!

as a WPML string so that I can translate it with WPML?

July 27, 2018 at 6:35 am #2587051

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. I have wrap the string in the gettext functions __() with a text domain like 'themedomain’. Please use updated code:

add_filter( 'woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2 );

function bbloomer_change_processing_email_subject( $subject, $order ) {
$subject = $order->get_billing_first_name() .', '. __('Thanks for your Spikes & Sparrow order!', 'themedomain');
return $subject;
}

Then, scan the theme again in WPML >> Theme and plugins localization and translate this string under WPML >> String Translation

Thank you

August 2, 2018 at 12:18 pm #2605250

jeroenv-42

I added this snippet:

add_filter( 'woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2 );
 
function bbloomer_change_processing_email_subject( $subject, $order ) {
$subject = $order->get_billing_first_name() .', '. __('Thanks for your Spikes & Sparrow order!', 'woocommerce');
return $subject;
}

And I scanned all plugins and themes for new strings, however, the string "Thanks for your Spikes & Sparrow order!" doesn't appear under under WPML >> String Translation.

What could be the issue?

August 2, 2018 at 12:43 pm #2605310

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

- I have noticed that your website’s WP Memory Limit is 40MB. The WP memory limit needs to be increased, it's different than php memory. PHP memory is fine but WordPress uses 40Mb as default in your site. Minimum requirements for WPML are 128Mb: https://wpml.org/home/minimum-requirements/

Please add this to the top of wp-config.php to increase WP memory:

/* WP Memory Limit */
define('WP_MEMORY_LIMIT', '512M');
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

- Please increase MaxInputVars to 10000 or more. For this, please try to set this variables in your php.ini:

max_input_vars = 10000;
suhosin.post.max_vars = 10000;
suhosin.request.max_vars = 10000;

You may need to contact your hosting provider to set them.

- Please delete all sort of caches on your site / server cache if any / plugin (WP Rocket Cache) / CDN cache (if any) browser cache and then see if it resolves the issue afterwards.

Thank you

August 7, 2018 at 11:22 am #2619945

jeroenv-42

I'm sorry, but it still doesn't work. Are you sure the snippet is correct?

August 7, 2018 at 5:00 pm #2621170

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Could you please try with the following snippet:

add_filter( 'woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2 );
function bbloomer_change_processing_email_subject( $subject, $order ) {
	$thanks_message = __('Thanks for your Spikes & Sparrow order!', 'woocommerce-custom');	
	$subject = $order->get_billing_first_name() .', '. $thanks_message;
	return $subject;
}

If still issue persists, please provide temporary access (WP-Admin and FTP Login info) to your site (preferably staging site), so that I can look into your setup and debug the issue.

Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

Thank you

The topic ‘[Closed] How to register this snippet as a WPML string?’ is closed to new replies.