plugin-page.js
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
jQuery( function ( $ ) {
'use strict';
var wc_payments_plugin = {
init: function () {
this.init_deactivate_wc_subscriptions_warning();
this.init_deactivate_wcpay_warning();
},
// Initialise handlers for WC Pay deactivate warning.
init_deactivate_wcpay_warning() {
// If the store doesn't have active WCPay (Stripe Billing) subscriptions, no warning needed.
if (
! wcpay_subscriptions_plugin_screen_data.store_has_active_wcpay_subscriptions
) {
return;
}
// Intercept click on WCPay deactivate link to show modal.
$( '#deactivate-woocommerce-payments' ).on(
'click',
this.display_wcpay_warning
);
// Resume deactivate when user confirms modal.
$( document ).on(
'click',
'#wcpay-plugin-deactivate-modal-submit',
this.redirect_deactivate_wcpay
);
},
// Show a modal to warn merchant that disabling WCPay plugin may leave Stripe subscriptions active (and renewing).
display_wcpay_warning: function ( event ) {
event.preventDefault();
$( this ).WCBackboneModal( {
template: 'wcpay-plugin-deactivate-warning',
} );
return false;
},
// Trigger deactivate flow for WCPay.
redirect_deactivate_wcpay: function ( event ) {
$( '#wcpay-plugin-deactivate-modal-submit' ).addClass( 'busy' );
window.location = $( '#deactivate-woocommerce-payments' ).attr(
'href'
);
},
// Initialise handlers for WC Subscriptions deactivate warning.
init_deactivate_wc_subscriptions_warning() {
// Intercept click on WCS deactivate link to show modal.
$( '#deactivate-woocommerce-subscriptions' ).on(
'click',
this.display_wcs_warning
);
// Resume deactivate when user confirms modal.
$( document ).on(
'click',
'#wcpay-subscriptions-plugin-deactivation-submit',
this.redirect_deactivate_wc_subscriptions
);
},
// Show a modal to warn merchant that disabling WC Subscriptions plugin will switch to WCPay.
display_wcs_warning: function ( event ) {
event.preventDefault();
$( this ).WCBackboneModal( {
template: 'wcpay-subscriptions-plugin-warning',
} );
return false;
},
// Trigger deactivate flow for WC Subscriptions.
redirect_deactivate_wc_subscriptions: function ( event ) {
$( '#wcpay-subscriptions-plugin-deactivation-submit' ).addClass(
'busy'
);
window.location = $( '#deactivate-woocommerce-subscriptions' ).attr(
'href'
);
},
};
wc_payments_plugin.init();
} );