This code fully works, and unlike a few others codes the link to the checkout works. This is a mashup of snippets that works.
add this to your functions.php file and it will find the word ‘Coupon’ and change it to ‘Voucher’.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
//change coupon to voucher - codehaven snippet add_filter( 'gettext', 'fix_woocommerce_strings', 999, 3 ); add_filter( 'gettext', 'bt_rename_coupon_field_on_cart', 10, 3 ); 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 ); 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; } function bt_rename_coupon_label( $err, $err_code=null, $something=null ){ $err = str_ireplace("Coupon","Voucher Code ",$err); return $err; } add_filter( 'woocommerce_checkout_coupon_message', 'bbloomer_have_coupon_message'); function bbloomer_have_coupon_message() { return '<i class="fa fa-ticket" aria-hidden="true"></i> Have a Voucher? <a href="#" class="showcoupon">Click here to enter your Voucher code</a>'; } |