-
AuthorPosts
-
July 23, 2020 at 12:56 am #1232459
Hi,
I’m trying to modify “Proceed with PayPal” button text.
I added this function found everywhere on the web and which seems to work for many people:add_filter( 'gettext', 'custom_paypal_button_text', 20, 3 ); function custom_paypal_button_text( $translated_text, $text, $domain ) { if( $translated_text == 'Proceed to PayPal' ) { $translated_text = 'Payerthgy'; // new button text is here } return $translated_text; }
…but it doesn’t work for me and I think there’s something to do with the theme.
Any idea?
If needed, you can find a link and credentials to my website in private content.
Thanks a lot!July 27, 2020 at 6:40 am #1233436Hey fcp,
Your Paypal checkout buttons says Payer avec PayPal, did you try adding that text instead of Proceed to PayPal in the code example?
Best regards,
RikardJuly 27, 2020 at 9:30 am #1233460Try this:
function my_text_strings( $translated_text, $text, $domain ){ switch ( $translated_text ){ case 'Proceed to PayPal': $translated_text = __( 'Payerthgy', $domain ); break; } return $translated_text; } add_filter('gettext', 'my_text_strings', 20, 3);
PS: the position of add_filter is not important – i notice it always this way in my child-theme functions.php because it provides a clearer conclusion to the above function
PPS: if you have to translate more than one string – it always have to be case 1 …; break; case 2 , break;
after each string translation there had to be a break.- This reply was modified 4 years, 3 months ago by Guenni007.
July 27, 2020 at 11:06 pm #1233608Hi Rikard,
I need to add the text “Payer” instead of “Proceed to PayPal”.July 27, 2020 at 11:08 pm #1233609Hi Guenni,
Thanks for your reply.
I’m sorry but this code doesn’t work neither for me :-(July 28, 2020 at 6:39 am #1233666The above code has been tested on many strings and should work; of course, the first string “Proceed to PayPal” may not be in your source code. It would be enough if the spaces were represented by characters, or e.g. there is Paypal instead of PayPal.
Which plugin do you use for your payment systems.Try this:
function my_text_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Proceed to PayPal' : $translated_text = __( 'Payerthgy', 'woocommerce' ); break; } return $translated_text; } add_filter( 'gettext', 'my_text_strings', 20, 3 );
On woocommerce there are some filter for different buttons ( woocommerce_order_button_text or woocommerce_order_button_html)
is it the checkout button ?
Best would be if i can see the page it concerns.July 28, 2020 at 7:19 am #1233668and if it is the woocommerce you use the part where it is handled is:
woocommerce – includes – gateways – paypal: “class-wc-gateway-paypal.php” about line 44:
$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
but try first the above! it is more specific on paypal – this below changes the order_button_text on all instances)
so this could be ok too : –
function my_order_button_text() { return __( 'Payerthgy', 'woocommerce' ); } add_filter( 'woocommerce_order_button_text', 'my_order_button_text' );
July 28, 2020 at 11:54 pm #1233810Hi Guenni,
Both functions don’t work :-(
Yes, it is the checkout button.I checked woocommerce / includes / gateways / paypal / “class-wc-gateway-paypal.php” about line 44 and the text IS “Proceed to PayPal”:
I also checked wp-content / languages / plugins / “woocommerce-fr_FR.po” and the text IS also “Proceed to PayPal”:I use Stripe plugin for my payments by credit card, but no plugin for PayPal. It is included in WooCommerce.
August 2, 2020 at 7:34 pm #1234665Hi,
Sorry for the late reply, is this the button you are trying to change?
Thanks to @Guenni007 for the function, I modified it a little to find the button text “Payer avec PayPal” and it seems to work now.function my_text_strings( $translated_text, $text, $domain ){ switch ( $translated_text ){ case 'Payer avec PayPal': $translated_text = __( 'Payerthgy', $domain ); break; } return $translated_text; } add_filter('gettext', 'my_text_strings', 20, 3);
Please clear your browser cache and check.Best regards,
MikeAugust 20, 2020 at 9:50 pm #1239629Hi Mike,
Thanks for your reply.
As usual, your function works like a charm.
Thanks a lot for your help guys! ;-)August 20, 2020 at 10:11 pm #1239641Hi,
I’m glad this was resolve for you. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Modify "Proceed with PayPal" button text on WooCommerce’ is closed to new replies.