Created
April 22, 2022 08:12
-
-
Save bradleysa/b10d040875cb18517febbc767958233e to your computer and use it in GitHub Desktop.
WC: rename 'Have a Coupon' on Checkout page
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
// 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