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 1 reply, has 2 voices.

Last updated by Carlos Rojas 1 year ago.

Assigned support staff: Carlos Rojas.

Author Posts
October 10, 2018 at 10:25 am #2803823

goetzB

Tell us what you are trying to do?
The language of the page is in english and there will be no translation for any page or product.
In the shopping cart the user fill out the delivery address and the country of the delivery destination. The emails the user get will be in the selected language. I thought this would be possible with the WPML snippet:
do_action( 'wpml_add_language_selector' )

But the language selector has to be in the shopping cart after the street and city.
I can create my own checkout fields with this code snippet:

add_filter( 'woocommerce_checkout_fields' , 'wp_bibel_de_add_checkout_fields' );

function wp_bibel_de_add_checkout_fields( $fields ) {
$fields['shipping']['shipping_phone'] = array(
'label' => 'Phone',
'placeholder' => 'Phone',
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);

return $fields;
}

But i don´t know how to combine these two code snippets. Is it possible in that way? Can you give me a hint or any documentations that i can follow. That would be great.

Is there any documentation that you are following?
I use google to solve this problem but i did´nt find any solutions.
Checkout fields:
hidden link
WPML:
https://wpml.org/wpml-hook/wpml_add_language_selector/

Is there a similar example that we can see?
No.

What is the link to your site?
hidden link
Site-protection:
Username:
admin
Password:
knauf

Login:
Username:
uni8_new
Password:
123Uni8!

I hope you can help me.
Thanks in advance.

Mark Hindsches

October 11, 2018 at 1:30 am #2806112

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hello Mark,
Thank you for contacting WPML support.
I will do my best to help you solve this issue.

Please take in account that custom coding falls outside of our support service.

1.- Instead of using the language switcher you can add a select list with the languages populated using WPML hooks: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/ and pass this info to the order.

With this hook you can get the active languages in the site: wpml_active_languages

Note: Please take in account that if there is no custom code involved the emails will be sent in the customer's language.

2.- In case you still want to use the language switcher, then you will need take in account that when the language is changed using the language switcher then the page will be reloaded, which means that the strings will probably change based on the translations made in String Translations and the .mo and .po files of Woocommerce.

For this variant I recommend you to contact one of our certified partners in this page: https://wpml.org/contractors/

Please let me know if you need further assistance and I will be more than happy to help.
Kind regards,
Carlos