Skip Navigation

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

Problem:
The client is trying to change the button label from 'Book now' to 'Add to Cart' and translate it to German ('Zum Warenkorb hinzufügen') using WooCommerce Bookings. Despite modifying the functions.php file and using WPML to scan and translate the string, the German translation does not appear on the products.
Solution:
We recommended the client to ensure that the custom code in functions.php is correctly using the WPML translation function. Here is the code snippet that should be used:

add_filter( 'woocommerce_booking_single_add_to_cart_text', 'custom_booking_button_text_wpml' );<br />function custom_booking_button_text_wpml() {<br />    return __( 'Add to Cart', 'doras-cheesecake' );<br />}

We also suggested reproducing the issue in a new WordPress installation to determine if the problem is specific to the client's site or a general issue. If the problem persists, it might be necessary to review the theme or plugin compatibility or other specific configurations on the original site.

If this solution does not resolve the issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at 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.

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Carlos Rojas 3 weeks ago.

Assisted by: Carlos Rojas.

Author Posts
November 7, 2024 at 11:14 am #16376581

markusS-78

Background of the issue:
I am trying to change the button label from 'Book now' to 'Add to Cart' and translate this to German ('Zum Warenkorb hinzufügen') using Woocommerce Bookings. I edited the functions.php to change the button label and added a text domain 'doras-cheesecake'. I used the WPML translation function and scanned the theme for strings. It found the string 'Add to Cart', and I added the German translation.

Symptoms:
The German translation doesn't show up on any of the products. It always says 'Add to Cart'.

Questions:
Is there anything else I've forgotten?
Why doesn't the German translation show up on the products?

November 7, 2024 at 11:45 am #16376871

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hello,
Thank you for contacting us

Although this scenario is considered custom coding and falls outside of the scope of our support service, I will be more than happy to take a look at the issue.

1.- Please share the code you added in functions.php to change the button label.

2.- Also, I would need to access the site in order to reproduce the issue. I have set your next answer private so you can securely share the access credentials.

Please don't forget to create a full backup of the site before sharing the credentials.

Looking forward to your message.
Regards,
Carlos

November 8, 2024 at 12:56 pm #16382057

markusS-78

Hello Carlos,

thank you for the reply. I can share the code I've used in the functions.php, but I can not give you admin access to our site for security reasons.

Here's the code:

add_filter( 'woocommerce_booking_single_add_to_cart_text', 'custom_booking_button_text_wpml' );
function custom_booking_button_text_wpml() {
// Use the WPML translation function for dynamic language support
return __( 'Add to Cart', 'doras-cheesecake' );
}

November 8, 2024 at 1:02 pm #16382067

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hello there,
Thank you for your message.

In this case, I will need you to reproduce the issue in a new WordPress installation so we can determine if the problem only happens on your site or if it happens on any site. I have created a new WordPress + WPML installation that you can access using this link: hidden link

Please try to reproduce the issue and let me know the results.

November 8, 2024 at 1:56 pm #16382347

markusS-78

I've tried to access the sandbox, but I guess the server is too busy, so I've created my own new installation.

The problem is, that it is working there, with the same adjustments to the functions.php. There must be something else wrong.

November 8, 2024 at 1:57 pm #16382348

markusS-78

I guess I will have to find a solution on my own

November 8, 2024 at 2:27 pm #16382422

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Please don't hesitate to contact us if you need our help in the future with WPML. We will be more than happy to help.