Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 10, 2015 16:58
Show Gist options
  • Save trys/c8325701fea44ba99fed to your computer and use it in GitHub Desktop.
Save trys/c8325701fea44ba99fed to your computer and use it in GitHub Desktop.
Change WooCommerce text strings
/**
* Change WooCommerce text strings.
*
* @param string $translated
* @param string $text
* @param string $domain
* @return string
*/
function projectnamespace_woocommerce_text( $translated, $text, $domain ) {
if ( $domain === 'woocommerce' ) {
$translated = str_replace(
array( 'Apply Coupon', 'Update Basket', 'Coupon code', 'Free!' ),
array( '' , 'Update' , 'Voucher' , '' ),
$translated
);
}
return $translated;
}
add_filter( 'gettext', 'projectnamespace_woocommerce_text', 30, 3 );
@jgangso
Copy link

jgangso commented Oct 7, 2017

Just putting a note, since this scores quite high in Google, that nowadays it would be better to change text strings using translation tools. (even for English)
This would allow for better re-usability and easier upgrades. Good starting point here: https://docs.woocommerce.com/document/woocommerce-localization/#section-11

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