HTML tags in Woocommerce Error Message

Decode HTML Tags from Woocommerce Error Message

This is live scenerion when we used checkout custom plugin and passed HTML link inside label, this HTML tag will display in woocommerce error as required field.

To show HTML decode or remove HTML tags I prefered to use wordpress predefined function wp_specialchars_decode with ‘ENT_QUOTES’ inside filter woocommerce_add_error.

Below filter will run each time when error occured and decode HTML tags:

add_filter( 'woocommerce_add_error', function( $message ) {
    return wp_specialchars_decode($message, 'ENT_QUOTES');

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *