Skip to content

Instantly share code, notes, and snippets.

@maxrice
Last active October 8, 2025 00:29
Show Gist options
  • Select an option

  • Save maxrice/8551024 to your computer and use it in GitHub Desktop.

Select an option

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
<?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 );
@GarrettSYHampton

Copy link
Copy Markdown

Thanks for this! Works great as of WooCommerce 2.1.3 / WordPress 3.8.1.

@craiggrella

Copy link
Copy Markdown

Max, you the man. This work perfect. Thanks.

@bradleysa

Copy link
Copy Markdown

Thanks Max. While using this snippet, after the promo code is successfully entered, the message given is "Coupon code applied successfully." I'm wondering how we can change that text as well from 'Coupon' to 'Promo', presumably using WC_COUPON_SUCCESS

@bridgetwes

Copy link
Copy Markdown

Filter woocommerce_coupon_message will change the "Coupon code applied successfully." message

@bridgetwes

Copy link
Copy Markdown

Also filter woocommerce_cart_totals_coupon_label will change "Coupon" label in "Cart Totals" box on Cart page and "Your Order" box on checkout.

@gainleads

Copy link
Copy Markdown

thanks for this, just what i needed. Really appreciate it!

ghost commented Jun 28, 2017

Copy link
Copy Markdown

As of WC 3.0, the word "coupon" in Apply Coupon on line 21 should be lowercase,

@Preciousomonze

Copy link
Copy Markdown

Works perfectly, thanks

@Frithir

Frithir commented Jul 21, 2017

Copy link
Copy Markdown

if ( 'Coupon code' === $text ) { $translated_text = 'Voucher Code'; } elseif ( 'Apply coupon' === $text ) { $translated_text = 'Apply Voucher Code'; } elseif ( 'Coupon:' === $text ) { $translated_text = 'Gift Voucher'; }

I found the filter hook perfect but the if requires exact matches eg "Coupon" needs to be "Coupon:".

@bradleywiebe2

bradleywiebe2 commented Aug 6, 2017

Copy link
Copy Markdown

I used the below inside functions.php to successfully change "Coupon Code" to "Customer Code". I just used "Apply Code" in order to keep the button from becoming too wide & wordy. Used on Wordpress 4.8.1 with WooCommerce 3.1.1.

// 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 ( 'Coupon:' === $text ) {
		$translated_text = 'Customer 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 Customer 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 = 'Customer Code';
	
	} elseif ( 'Apply coupon' === $text ) {
		$translated_text = 'Apply Code';
	}
	return $translated_text;
}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 );`
```

@WebDevByAlex

Copy link
Copy Markdown

@bradleywiebe2 Thanx bro! Your's was the only code that I found online that worked for both the button and placeholder and on both the cart and checkout pages :)

@krgauravit007

Copy link
Copy Markdown

@bradleywiebe2 - Really - Your code only worked for label on button . Now, How do I change text for coupon success or unsuccess message. Please advice.

@zakirsajib

zakirsajib commented Feb 25, 2018

Copy link
Copy Markdown
function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Billing details' :
            $translated_text = __( 'Faktureringsdetaljer', 'woocommerce' );
            break;
        case 'Your order' :
            $translated_text = __( 'Din bestilling', 'woocommerce' );
            break;
        case 'View cart' :
            $translated_text = __( 'Se indkøbsvogn', 'woocommerce' );
            break;
        case 'Apply coupon' :
            $translated_text = __( 'Anvend kupon', 'woocommerce' );
            break;
        case 'Update cart' :
            $translated_text = __( 'Opdater indkøbsvogn', 'woocommerce' );
            break;
        case 'Proceed to checkout' :
            $translated_text = __( 'Gå til kassen', 'woocommerce' );
            break;
        case 'Cart totals' :
            $translated_text = __( 'Indkøbskurv totaler', 'woocommerce' );
            break;
        case 'Place order' :
            $translated_text = __( 'Angiv bestilling', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

// rename the "Have a Coupon?" message on the checkout page
function woocommerce_rename_coupon_message_on_checkout() {
	return 'Har du en kupon?' . ' <a href="#" class="showcoupon">' . __( 'Klik her for at indtaste din kode', 'woocommerce' ) . '</a>';
}
add_filter( 'woocommerce_checkout_coupon_message', 'woocommerce_rename_coupon_message_on_checkout' );

@stewartanthony

Copy link
Copy Markdown

Not sure what im doing wrong here, but I cant get this to work. I've downloaded the wc-rename-checkout-coupon-field.php file and uploaded it inside my theme folder but nothing happened. Is that wrong?

@BKeanu1989

Copy link
Copy Markdown

@stewartanthony the code won't be executed. you have to put inside your theme functions.php or some plugin. In your case I would advise going for the solution with functions.php

@johnlaine1

Copy link
Copy Markdown

@bradleywiebe2 - Works like a charm, thank you sir!

@FrankTsaur

FrankTsaur commented Sep 6, 2018

Copy link
Copy Markdown

I'm having just a bit of trouble...Everything works great, however, one part that that I can't seem to fix is on the checkout page. I changed the name of the coupon code section in every part successfully to "Gift Code" instead, except this area:

"If you have a coupon code, please apply it below." see screenshot: http://prntscr.com/kr9nkj

How do I change that line to say "Gift Code" as well?

Here is the code I'm using:

`// 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 ( 'Coupon:' === $text ) {
$translated_text = 'Gift 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 Gift Code?' . ' ' . __( 'Click here to enter your code', 'woocommerce' ) . '';
}
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 = 'Gift Code';

} elseif ( 'Apply coupon' === $text ) {
	$translated_text = 'Apply Code';
}
return $translated_text;

}
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 );`

@foamymedia

foamymedia commented Sep 7, 2018

Copy link
Copy Markdown

you can just edit the woocommerce/checkout/form-coupon.php file and add this to your theme

@gabros20

gabros20 commented Apr 7, 2019

Copy link
Copy Markdown

In case someone want's to change the "If you have a coupon code, please apply it below." string to something else, here is a way to do it.

add_filter( 'gettext', 'woocommerce_change_coupon_field_instruction_text' );

function woocommerce_change_coupon_field_instruction_text($translated) {
$translated = str_ireplace('If you have a coupon code, please apply it below.', 'YOUR NEW STRING', $translated);
return $translated;
}

@jthomae1

Copy link
Copy Markdown

@gabros20 anything changed here? That's not working for me so far

@Ruben2600

Copy link
Copy Markdown

Hello! Can I change also the background off the promo code? Is now #FFFFFF I want to change it! THanks!

@sajjadalis

Copy link
Copy Markdown

This is not working for me as well.

@Ruben2600 try to change with css.

.cart .coupon .button {
    background-color: #000000;
}

replace it with proper css class (applied in your theme).

@rtpHarry

Copy link
Copy Markdown

I just went through this and this code snippet is working for me:

/**
 * Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function bt_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 ( 'Coupon:' === $text ) {
		$translated_text = 'Voucher Code:';
	}

	if ('Coupon has been removed.' === $text){
		$translated_text = 'Voucher code has been removed.';
	}

	if ( 'Apply coupon' === $text ) {
		$translated_text = 'Apply voucher';
	}

	if ( 'Coupon code' === $text ) {
		$translated_text = 'Voucher code';
	
	} 

	return $translated_text;
}
add_filter( 'gettext', 'bt_rename_coupon_field_on_cart', 10, 3 );

/**
 * Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function bt_rename_coupon_message_on_checkout() {
	return 'Have a voucher code?' . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>.';
}
add_filter( 'woocommerce_checkout_coupon_message', 'bt_rename_coupon_message_on_checkout' );

/**
 * Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function bt_rename_coupon_label( $err, $err_code=null, $something=null ){
	$err = str_ireplace("Coupon","voucher",$err);
	return $err;
}
add_filter( 'woocommerce_coupon_error', 'bt_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_coupon_message', 'bt_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_cart_totals_coupon_label', 'bt_rename_coupon_label',10, 1 );

Just posting it for easy reference for future developers, as it compiles others feedback in this thread, plus fixes missing bits of html in one of the comments.

@rtpHarry

Copy link
Copy Markdown

Actually I've tweaked it to the following code now, just to catch a couple more edge cases:

/**
 * Soka - Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function soka_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 ( 'Coupon:' === $text ) {
		$translated_text = 'Voucher Code:';
	}

	if ('Coupon has been removed.' === $text){
		$translated_text = 'Voucher code has been removed.';
	}

	if ( 'Apply coupon' === $text ) {
		$translated_text = 'Redeem voucher';
	}

	if ( 'Coupon code' === $text ) {
		$translated_text = 'Voucher code';
	} 

	if ( 'If you have a coupon code, please apply it below.' === $text ) {
		$translated_text = 'If you have a voucher code, please apply it below.';
	} 

	return $translated_text;
}
add_filter( 'gettext', 'soka_rename_coupon_field_on_cart', 10, 3 );

/**
 * Soka - Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function soka_rename_coupon_message_on_checkout() {
	return 'Have a voucher code?' . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>.';
}
add_filter( 'woocommerce_checkout_coupon_message', 'soka_rename_coupon_message_on_checkout' );

/**
 * Soka - Change 'coupon' text to 'voucher'
 * @source https://gist.github.com/maxrice/8551024
 */
function soka_rename_coupon_label( $err, $err_code=null, $something=null ){
	$err = str_replace("Coupon","Voucher",$err);
	$err = str_replace("coupon","voucher",$err);
	return $err;
}
add_filter( 'woocommerce_coupon_error', 'soka_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_coupon_message', 'soka_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_cart_totals_coupon_label', 'soka_rename_coupon_label',10, 1 );

@RubienRe

RubienRe commented Jun 4, 2023

Copy link
Copy Markdown

image
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

@jkdeleteme

Copy link
Copy Markdown

The code is not working for me, does anyone have an update?

@nidzo80

nidzo80 commented Aug 8, 2025

Copy link
Copy Markdown

add_filter( 'gettext', 'custom_translate_elementor_coupon_texts', 999, 3 );
function custom_translate_elementor_coupon_texts( $translated, $text, $domain ) {
if ( $domain === 'elementor-pro' ) {
switch ( $text ) {
case 'Have a coupon?':
$translated = 'Imate kupon?';
break;
case 'Click here to enter your coupon code':
$translated = 'Kliknite ovde da unesete kod kupona';
break;
case 'If you have a coupon code, please apply it below.':
$translated = 'Unesite kod kupona ispod';
break;
case 'Coupon code':
$translated = 'Kod kupona';
break;
case 'Apply':
$translated = 'Primeni';
break;
}
}
return $translated;
}

@SagiruAhmed

Copy link
Copy Markdown

So I need this code but I honestly don't know what it is. I need your help.

@SagiruAhmed

Copy link
Copy Markdown

If you have a coupon code, please apply it below

@SagiruAhmed

Copy link
Copy Markdown

Bella rejoindre la maison de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment