Coupon to voucher

PHOTO EMBED

Thu May 28 2020 22:22:31 GMT+0000 (Coordinated Universal Time)

Saved by @performmarketing #php

<?php

add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );
add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );
add_filter('woocommerce_coupon_error', 'rename_coupon_label', 10, 3);
add_filter('woocommerce_coupon_message', 'rename_coupon_label', 10, 3);
add_filter('woocommerce_cart_totals_coupon_label', 'rename_coupon_label',10, 1);
add_filter( 'woocommerce_checkout_coupon_message', 'woocommerce_rename_coupon_message_on_checkout' );


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 = 'Voucher:';
	}

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

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

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

	return $translated_text;
}


// rename the "Have a Coupon?" message on the checkout page
function woocommerce_rename_coupon_message_on_checkout() {
	return 'Have a voucher?' . ' ' . __( 'Enter your voucher code', 'woocommerce' ) . '';
}


function rename_coupon_label($err, $err_code=null, $something=null){

	$err = str_ireplace("Coupon","Voucher ",$err);

	return $err;
}

?>
content_copyCOPY

https://www.grahamethomson.com/2018/10/07/rename-coupon-code-text-in-woocommerce/