mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +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 {
|
} else {
|
||||||
errorHandler.message(data.data.message);
|
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};
|
throw {type: 'create-order-error', data: data.data};
|
||||||
|
|
|
@ -40,6 +40,10 @@ class FreeTrialHandler {
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
this.spinner.unblock();
|
this.spinner.unblock();
|
||||||
this.errorHandler.messages(errors);
|
this.errorHandler.messages(errors);
|
||||||
|
|
||||||
|
// fire WC event for other plugins
|
||||||
|
jQuery( document.body ).trigger( 'checkout_error' , [ this.errorHandler.currentHtml() ] );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -40,6 +40,15 @@ class ErrorHandler {
|
||||||
this._scrollToMessages();
|
this._scrollToMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {String}
|
||||||
|
*/
|
||||||
|
currentHtml()
|
||||||
|
{
|
||||||
|
const messageContainer = this._getMessageContainer();
|
||||||
|
return messageContainer.outerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {String} text
|
* @param {String} text
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue