Skip Navigation

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

Problem:
The client needed to translate the "Phone" and "Email Address" fields in the Shipping Address area of the WooCommerce Checkout page, which were added using custom code.

Solution:
We recommended the client to try the following methods:
1. Enable the "Look for strings while pages are rendered" option in WPML > String Translation, visit the checkout page to render the strings, and then search for them in the String Translation interface.
2. If the strings are not found, they might be registered as admin texts. The client should follow the process outlined in our documentation to find and translate admin text strings: https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/
3. As an alternative, use CSS to target specific languages. We provided a custom search URL to find existing tickets with code examples for this method.

If these solutions do not resolve the issue or if they seem outdated or irrelevant, we encourage the client to open a new support ticket. We also highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that the latest versions of themes and plugins are installed. For further assistance, please contact our 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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Mihai Apetrei 10 months, 1 week ago.

Assisted by: Mihai Apetrei.

Author Posts
April 13, 2024 at 1:09 am #15514370

tareqA-6

Hello,

I used the following code to insert "Phone" and "Email Address" in the Shipping Address area of my Checkout page of WooCommerce:

/**
* @snippet Shipping Phone & Email - WooCommerce
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community hidden link
*/

// Add custom fields to checkout
add_filter( 'woocommerce_checkout_fields', 'bbloomer_shipping_phone_email_checkout' );

function bbloomer_shipping_phone_email_checkout( $fields ) {
$fields['shipping']['shipping_phone'] = array(
'label' => 'Phone',
'type' => 'tel',
'required' => true,
'class' => array( 'form-row-wide' ),
'validate' => array( 'phone' ),
'autocomplete'=> 'tel',
'priority' => 25,
);

$fields['shipping']['shipping_email'] = array(
'label' => 'Email Address',
'type' => 'email',
'required' => true,
'class' => array( 'form-row-wide' ),
'validate' => array( 'email' ),
'autocomplete'=> 'email',
'priority' => 26,
);

return $fields;
}

// Display custom fields in admin order data
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'bbloomer_shipping_phone_email_checkout_display' );

function bbloomer_shipping_phone_email_checkout_display( $order ) {
echo '<p><b>Shipping Phone:</b> ' . get_post_meta( $order->get_id(), '_shipping_phone', true ) . '</p>';
echo '<p><b>Shipping Email:</b> ' . get_post_meta( $order->get_id(), '_shipping_email', true ) . '</p>';
}

I have tried everything I know about WPML to translate "Phone" and "Email Address" but they all failed.

I found this article and tried to apply its instructions but still I failed to translate the required texts. Maybe I applied the instructions wrongly:

https://wpml.org/forums/topic/translate-text-given-in-snippets-to-other-language/#post-11166303

Please help me to translate "Phone" and "Email Address" in the Checkout form. They are the only two strings that still not translated into Arabic as shown in the screenshot attached.

Thanks in advance.

Phone and Email Address Fields Under Shipping Address.png
April 13, 2024 at 9:34 pm #15515196

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

Before this ticket gets assigned to one of my colleagues, I will try to help.

Please try the two methods here, number one might work (try it in the default language - EN):

1. Method 1:

Go to WPML > String Translation and at the bottom of the page you will find a checkbox called "Look for strings while pages are rendered". You can enable (check) that and then go in the front end to a page where you have that string showing up and then go back to WPML > String Translation and search for that string and see if it now shows up.

2. Method 2: If you can't find them inside the WPML > String Translation, they might be added as admin text.

This should be the normal process to find and translate admin text strings:
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/

3. There's also an alternative that you can use where you could use CSS to target specific languages - I created this custom search URL so that you can find existing tickets that contain recommendations from my colleagues with code examples of how that can be accomplished:
hidden link

I hope that you will find all this info helpful.

Please let us know how that goes.

Kind regards,
Mihai Apetrei