diff --git a/modules/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js b/modules/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js index ac3c363b0..eb120623d 100644 --- a/modules/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js +++ b/modules/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js @@ -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'); diff --git a/modules/ppcp-button/resources/js/modules/ErrorHandler.js b/modules/ppcp-button/resources/js/modules/ErrorHandler.js index accfc8bd5..8c4d7149f 100644 --- a/modules/ppcp-button/resources/js/modules/ErrorHandler.js +++ b/modules/ppcp-button/resources/js/modules/ErrorHandler.js @@ -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){