Created
April 10, 2015 16:58
-
-
Save trys/c8325701fea44ba99fed to your computer and use it in GitHub Desktop.
Change WooCommerce text strings
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
/** | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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