Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 08:12
Show Gist options
  • Save bradleysa/b10d040875cb18517febbc767958233e to your computer and use it in GitHub Desktop.
Save bradleysa/b10d040875cb18517febbc767958233e to your computer and use it in GitHub Desktop.
WC: rename 'Have a Coupon' on Checkout page
// rename the "Have a Coupon?" message on the checkout page
function woocommerce_rename_coupon_message_on_checkout() {
return 'Got a coupon? Score!' . ' <a href="#" class="showcoupon">' . __( 'Redeem it here.', '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 = 'Coupon Code';
} elseif ( 'Apply Coupon' === $text ) {
$translated_text = 'Apply Coupon';
}
return $translated_text;
}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 );
/** https://gist.github.com/maxrice/8551024 **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment