isonnymichael
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
From backend I use wc hooks and return
htmlentitiesadd_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();Lastly I use dispatch and create custom function to parsing htmlentities from backend.
const { createNotice } = useDispatch( noticesStore ); createNotice( 'success', toHtml(error_message) );https://developer.ww.wp.xz.cn/block-editor/reference-guides/data/data-core-notices/
I’ve joined the group but haven’t found an answer. So I found my own solution to handle this problem by making modifications to the frontend, I think there is an easier solution.
Viewing 2 replies - 1 through 2 (of 2 total)