Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brandonkramer/e7858c28f88c989c7191e0dbc10a58d7 to your computer and use it in GitHub Desktop.
Save brandonkramer/e7858c28f88c989c7191e0dbc10a58d7 to your computer and use it in GitHub Desktop.
Remove the 'Billing' word from the error validation message in WooCommerce. When using WooCommerce, the checkout billing validation has the word 'Billing' automatically prefixed. Use the following filter to remove this.
add_filter( 'woocommerce_add_error', 'woocommerceAddError' );
/**
* Remove billing from the validation message
* @see wc_add_notice
*
* @param $error
* @return string|string[]
*/
function woocommerceAddError ( $error )
{
if ( strpos( $error, 'Billing ' ) !== false ) {
$error = str_replace( "Billing ", "", $error );
}
if ( strpos( $error, 'Facturering ' ) !== false ) {
$error = str_replace( "Facturering ", "", $error );
}
return $error;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment