mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
handle messages from WC as HTML
This commit is contained in:
parent
223aa6493d
commit
45dd4a91d9
2 changed files with 20 additions and 2 deletions
|
@ -40,8 +40,17 @@ class CheckoutActionHandler {
|
|||
if (!data.success) {
|
||||
spinner.unblock();
|
||||
//handle both messages sent from Woocommerce (data.messages) and this plugin (data.data.message)
|
||||
const message = typeof(data.messages) !== 'undefined' ? data.messages : data.data.message;
|
||||
errorHandler.message(message, true);
|
||||
if (typeof(data.messages) !== 'undefined' )
|
||||
{
|
||||
const domParser = new DOMParser();
|
||||
errorHandler.appendPreparedErrorMessageElement(
|
||||
domParser.parseFromString(data.messages, 'text/html')
|
||||
.querySelector('ul')
|
||||
);
|
||||
} else {
|
||||
errorHandler.message(data.data.message, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
const input = document.createElement('input');
|
||||
|
|
|
@ -15,6 +15,15 @@ class ErrorHandler {
|
|||
this.message(this.genericErrorText)
|
||||
}
|
||||
|
||||
appendPreparedErrorMessageElement(errorMessageElement)
|
||||
{
|
||||
if(this.messagesList === null) {
|
||||
this.prepareMessagesList();
|
||||
}
|
||||
|
||||
this.messagesList.replaceWith(errorMessageElement);
|
||||
}
|
||||
|
||||
message(text, persist = false)
|
||||
{
|
||||
if(! typeof String || text.length === 0){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue