mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #1384 from woocommerce/PCP-1700-js-error-event
Trigger WC checkout_error event
This commit is contained in:
commit
715e9bcf17
3 changed files with 16 additions and 0 deletions
|
@ -102,6 +102,9 @@ class CheckoutActionHandler {
|
|||
} else {
|
||||
errorHandler.message(data.data.message);
|
||||
}
|
||||
|
||||
// fire WC event for other plugins
|
||||
jQuery( document.body ).trigger( 'checkout_error' , [ errorHandler.currentHtml() ] );
|
||||
}
|
||||
|
||||
throw {type: 'create-order-error', data: data.data};
|
||||
|
|
|
@ -40,6 +40,10 @@ class FreeTrialHandler {
|
|||
if (errors.length > 0) {
|
||||
this.spinner.unblock();
|
||||
this.errorHandler.messages(errors);
|
||||
|
||||
// fire WC event for other plugins
|
||||
jQuery( document.body ).trigger( 'checkout_error' , [ this.errorHandler.currentHtml() ] );
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
@ -40,6 +40,15 @@ class ErrorHandler {
|
|||
this._scrollToMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {String}
|
||||
*/
|
||||
currentHtml()
|
||||
{
|
||||
const messageContainer = this._getMessageContainer();
|
||||
return messageContainer.outerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {String} text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue