How to change "Have a coupon?" text in Woocommerce checkout page How to change "Have a coupon?" text in Woocommerce checkout page wordpress wordpress

How to change "Have a coupon?" text in Woocommerce checkout page


It doesn't work because the text is not in capitals and you are not using the right variable.

There is 2 ways to change this text (the second way seems the best):

1) Using gettext filter hook this way:

add_filter('gettext', 'custom_strings_translation', 20, 3);function custom_strings_translation( $translated_text, $text, $domain ) {    if( $text == 'Have a coupon?' ){        $translated_text =  __( 'Tienes un cupón?', $domain );    }    return $translated_text;}

Code goes in function.php file of the active child theme (or active theme). Tested and works.


2) Using woocommerce_checkout_coupon_message filter hook that will allow you more changes:

add_filter( 'woocommerce_checkout_coupon_message', 'custom_checkout_coupon_message', 20, 1 );function custom_checkout_coupon_message( $notice ) {    return __( 'Tienes un cupón?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Haga clic aquí para ingresar su código', 'woocommerce' ) . '</a>'}

Code goes in function.php file of the active child theme (or active theme). Tested and works.


Related: