Skip Navigation

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

Problem:Add to cart button translation

Solution:If you go to wp-content/plugins/woocommerce-bookings/templates/single-product/add-to-cart/booking.php Line 39, you will see the string which is currently not wrapped in a getText call resulting in it to not be picked up by String Translation.

Documentation:
https://wpml.org/faq/language-setup/

I have now wrapped the string within the WC Bookings plugin with a GetText call() which allows you to translated it through String Translation. You can find it under the domain "wc-bookings"

Relevant Documentation:

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

Last updated by danE-4 4 years, 10 months ago.

Assisted by: Bobby.

Author Posts
January 13, 2020 at 5:39 pm #5284933

danE-4

Hi,

We are using WooCommerce with Woocommerce Bookings on several websites and usually, it seems the "Add to cart" button of product page gets translated automatically, i guess through WooCommerce Multilingual already including it?

On this new website the translation doesn't seem to work and we can't find a way to get this string to show up, even searching for new ones with the Theme & Plugins Localization tool.

Where can i access this translation please?

Thank you

January 14, 2020 at 2:28 am #5286131

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi There,

If I go to one of your products in French I am able to see the "Add to cart" button correctly translated, are you still experiencing this issue?

In case you still are experiencing the issue please provide me with steps on how I can replicate it and where I can see it in the front end.

Screen Shot 2020-01-13 at 6.27.05 PM.png
January 14, 2020 at 9:16 am #5287953

danE-4

Hi Bobby,

Thank you for your reply. You went straight to one of the very few products not using WooCommerce Bookings 🙂 Sorry i should have just given a link to a product, here it is : hidden link

You will notice a translated "Book now" or "Réserver" button when you land on the page, this is our own custom one and we were able to translate it without any problem. It triggers the actual WooCommerce Bookings form and the actual "Add to cart" button i was talking about shows up at the bottom of this blue form.

Thank you

2020-01-14 10_16_21-Window.png
January 14, 2020 at 5:56 pm #5291849

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for the details, I can see it now.

Go to WPML->String Translation->Translate texts in admin screens.
In the "..admin screens" dashboard, right-click and "View Page Source"

Once the page loads ctrl+F or cmd + F (I am using Chrome), to bring up the search option and search for a specific piece out of the string you are looking for.

You should be able to now locate the string or at least add it using the Custom XML Configuration are within WPML->Settings

https://wpml.org/documentation/support/language-configuration-files/

Let me know your results, please or if you find the string and have a hard time adding it to String Translation.

January 15, 2020 at 10:52 am #5296541

danE-4

Hi Bobby,

I had a look in this admin screens part before posting here and couldn't find anything. I didn't go as far as searching the source code of page though. I've just done this and i can't see anything looking relevant. The closest i find is an "[add_to_cart_display]" snippet, which i think is just a WooCommerce toggle to switch the website to catalog mode.

Any other idea please ?

January 16, 2020 at 5:58 am #5303163

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed I recommend taking FULL BACKUP of your database and your website.**
I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/

You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

January 18, 2020 at 6:34 am #5315329

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi There,

I noticed that the WPML plugins are currently using older versions. If possible please update to the latest versions and let me know your results.

Additionally, you mentioned that in some other sites the "Add to cart" string is showing translated. If you still have easy access to one of the sites that it is working please try the following:

1. Go to the site and navigate to WPML ->String Translation->Search for "Add to cart" and select "exact match"
2. Share with me a screenshot of the string results [there must be around 4-5 strings]

Usually, Add to cart by default is translated through .mo files when added through WooCommerce but in this case it is added through WC booking.

January 20, 2020 at 4:13 pm #5325767

danE-4

Hi Bobby,

Yeah, there are quite a lot of plugins on this website and updating them can be intense, so we're trying to do it when our client sales are a bit more quiet and we hope to be able to do this in a couple of weeks.

Before posting here i had a look on the other websites to compare and see if something was setup differently. I confirm i see the same 3 strings on both sites, and they are all translated. The only difference is the site i have the problem on is just translated in French and the one i'm comparing it with also has Arabic, Hebrew and Russian.

Does it help you understand what is going on ?

Thank you

2020-01-20 17_04_51-Window.png
January 21, 2020 at 7:18 am #5329585

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for the information!

The string "Add to Cart" is coming from the WC Bookings plugin rather than the WooCommerce plugin.

This is why the translation is working with Products such as hidden link but with the products that use WC booking, it is not working.

You can see this in my screenshots with the following test:

1. You go to WPML->String translation-> change the language of the "ADD TO CART" string
2. Now you can edit the "English" version, which I edited to "Test"
3. See that it works for simple products but not WC Bookings "Add to cart"

If you go to wp-content/plugins/woocommerce-bookings/templates/single-product/add-to-cart/booking.php Line 39, you will see the string which is currently not wrapped in a getText call resulting in it to not be picked up by String Translation.

Documentation:
https://wpml.org/faq/language-setup/

I have now wrapped the string within the WC Bookings plugin with a GetText call() which allows you to translated it through String Translation. You can find it under the domain "wc-bookings"

Please review the string in the front end and let me know your results as it should show as expected now.

Screen Shot 2020-01-20 at 11.16.04 PM.png
Screen Shot 2020-01-20 at 10.56.42 PM.png
Screen Shot 2020-01-20 at 10.48.22 PM.png
Screen Shot 2020-01-20 at 10.47.52 PM.png
Screen Shot 2020-01-20 at 10.47.41 PM.png
January 21, 2020 at 9:18 am #5330267

danE-4

Excellent, i didn't even think to check the GetText as this site is a copy from the other one i was mentioning before and we didn't do any custom coding since (or plug-in update, as you saw).

Thank you very much for your help Bobby 🙂