Last active
July 5, 2023 19:34
-
-
Save maxrice/8551024 to your computer and use it in GitHub Desktop.
WooCommerce - rename the "Have a Coupon?" message and "Apply Coupon" field on the checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// rename the "Have a Coupon?" message on the checkout page | |
function woocommerce_rename_coupon_message_on_checkout() { | |
return 'Have a Promo Code?' . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>'; | |
} | |
add_filter( 'woocommerce_checkout_coupon_message', 'woocommerce_rename_coupon_message_on_checkout' ); | |
// rename the coupon field on the checkout page | |
function woocommerce_rename_coupon_field_on_checkout( $translated_text, $text, $text_domain ) { | |
// bail if not modifying frontend woocommerce text | |
if ( is_admin() || 'woocommerce' !== $text_domain ) { | |
return $translated_text; | |
} | |
if ( 'Coupon code' === $text ) { | |
$translated_text = 'Promo Code'; | |
} elseif ( 'Apply Coupon' === $text ) { | |
$translated_text = 'Apply Promo Code'; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bit late to the party, but is there a way to just hide / remove: 'Have a coupon? [Click here to enter your code]' and 'Coupon:'? I already made it so it automatically opens whenever you enter the checkout page. Thanks! :D