From backend I use wc hooks and return htmlentities
add_filter( 'woocommerce_coupon_error', array( $this, 'implement_coupon_error_message_block' ), 10, 3 );
public function implement_coupon_error_message_block( $error_message, $error_code, $coupon ) {
$error_message = "Custom message <a class='button'>Custom Button</a>"
return htmlentities($error_message);
}
Then on frontend I use wc blocks third-party-developers to catch the event cart error:
const store = select( CART_STORE_KEY );
const cartErrors = store.getCartErrors();
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-blocks/docs/third-party-developers/extensibility/data-store/cart.md
Lastly I use dispatch and create custom function to parsing htmlentities from backend.
const { createNotice } = useDispatch( noticesStore );
createNotice( 'success', toHtml(error_message) );
https://developer.www.ads-software.com/block-editor/reference-guides/data/data-core-notices/