Just renaming the coupon field to something else can likewise diminish the quantity of clients that leave your site amid checkout to discover coupon codes. Clients that as of now have the code will comprehend what name to search for whatever length of time that you're steady. For instance, on the off chance that you email out "Offer Codes" or "Promo Codes", then clients will search for this field, yet those without coupons won't get occupied by the words "coupon" or 'rebate'.
Simply following the steps of code changing for rename the coupon code fields.
Add following code in "functions.php" file.
<?php
/************************************************
* rename the coupon field on the cart page
************************************************/
function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
// bail if not modifying frontend woocommerce text
if ( is_admin() || 'woocommerce' !== $text_domain ) {
return $translated_text;
}
if ( 'Apply Coupon' === $text ) {
$translated_text = 'Apply Promo Code';
}
return $translated_text;
}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );
/************************************************
* 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 );
?>
Above bold text place do rename as you need.
For more Interesting, Useful Article & codes visit IT New Code.
Thank you for sharing your tutorial. It works as advertised. I did however have to make a minor adjustment. All instances of 'Apply Coupon' needed to be changed to 'Apply coupon' (with a lower case 'c').
ReplyDeleteDo you know how to change the message that comes up AFTER you enter a coupon code? The default says "Coupon code applied successfully"
ReplyDeletethanks for the info,
ReplyDeletemy problem is how can i rename the Coupon does not exist! when a wrong coupon in entered.
Exactly where in the functions.php do add the suggested code?
ReplyDelete