I'm trying to change the text in the 'Place order' button on my multilingual site in WooCommerce. My default lang is English US, other is Polish. I can easily modify the secondary language text via my WPML plugin, but I cannot change the default language. I tried modifying the button text via a JS code which worked in the default EN page, but the Polish one started to display the new English text too. I also tried using Loco and adding English as a language, changed the English text - but that didn't work. How is this doable - to change text strings in default language and making them translatable via WPML in the same time?

You could use their filter to do this:

/* Add to the functions.php file of your theme */

add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text' ); 

function woo_custom_order_button_text() {
    return __( 'Your new button text here', 'woocommerce' ); 
}
  • Like I said before, I used this code, but it changes permanently also the secondary language button text, which I want to stay translatable. So this doesn't solve the issue. – Chris Osiak Dec 3 at 23:46
  • 1
    @ChrisOsiak your comment is wrong. yes it does change also the polish text, since there is no translation for it yet, but if you add the translation inside WPML string translation for polish to that specific string, than this works as you expect it to. – honk31 Dec 4 at 17:58
  • I don't see anywhere above stating you tried to use the woocommerce filter... As @chrisosiak said though...add a translator. This is how it's designed to be used and you stated that's what you were already doing. – rudtek Dec 4 at 18:05

If you have static texts, which are hard-coded in the PHP, you can just use GetText calls, like:

<?php __('Hello world','cool_theme'); ?>

WPML hooks to the GetText calls and makes these texts translatable via the String Translation interface. Please note that this method only works for texts that cannot be edited and are fixed in the theme.

  • This is a WooCommerce default button. I used this code add_filter( 'woocommerce_order_button_text', 'bbloomer_rename_place_order_button' ); function bbloomer_rename_place_order_button() { return 'Download'; } but it changed the button text also in the secondary language discarding the translation. – Chris Osiak Dec 3 at 19:10
  • Ohh I see then just override button file. Process explained on this link. lockedownseo.com/change-place-order-text-woocommerce-checkout – dado Dec 3 at 19:16
  • No, this does the same what my does: overrides button text in all languages, whereas I want to override only the default language (English), while the translation should be taken from the string translation of WPML. So another words, I want native button text in each language. – Chris Osiak Dec 4 at 22:02
  • No it shouldn't override all languages.yoi are doing something wrong. Because when you override like this you override English. Then this string is added to translation and you can translate it to different languages – dado Dec 5 at 6:36

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.