Created
April 5, 2021 08:27
-
-
Save ankitrox/1768ca893dbd67bd792e11cac2d70e9b to your computer and use it in GitHub Desktop.
Helper
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
<?php | |
public function prevent_duplicate_error_notices( string $message ): ?string { | |
if ( wc_has_notice( $message ) ) { | |
return null; | |
} | |
return $message; | |
} | |
public function wc_add_wp_error_notices( \WP_Error $errors ): void { | |
add_filter( 'woocommerce_add_error', [ $this, 'prevent_duplicate_error_notices' ] ); | |
wc_add_wp_error_notices( $errors ); | |
remove_filter( 'woocommerce_add_error', [ $this, 'prevent_duplicate_error_notices' ] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment