@@ -29,6 +29,14 @@ public function maybe_init_subscriptions() {
29
29
return ;
30
30
}
31
31
32
+ /**
33
+ * We need to attach the callbacks below once per Gateway (CC, SEPA, etc.), but only once.
34
+ * Therefore, we use a static flag at class level to indicate that they have been attached.
35
+ */
36
+ if ( self ::$ has_attached_integration_hooks ) {
37
+ return ;
38
+ }
39
+
32
40
$ this ->supports = array_merge (
33
41
$ this ->supports ,
34
42
[
@@ -61,16 +69,16 @@ public function maybe_init_subscriptions() {
61
69
// Validate the payment method meta data set on a subscription.
62
70
add_filter ( 'woocommerce_subscription_validate_payment_meta ' , [ $ this , 'validate_subscription_payment_meta ' ], 10 , 2 );
63
71
72
+ self ::$ has_attached_integration_hooks = true ;
73
+
64
74
/**
65
75
* The callbacks attached below only need to be attached once. We don't need each gateway instance to have its own callback.
66
76
* Therefore we only attach them once on the main `stripe` gateway and store a flag to indicate that they have been attached.
67
77
*/
68
- if ( self :: $ has_attached_integration_hooks || WC_Gateway_Stripe::ID !== $ this ->id ) {
78
+ if ( WC_Gateway_Stripe::ID !== $ this ->id ) {
69
79
return ;
70
80
}
71
81
72
- self ::$ has_attached_integration_hooks = true ;
73
-
74
82
add_action ( 'woocommerce_subscriptions_change_payment_before_submit ' , [ $ this , 'differentiate_change_payment_method_form ' ] );
75
83
add_action ( 'wcs_resubscribe_order_created ' , [ $ this , 'delete_resubscribe_meta ' ], 10 );
76
84
add_action ( 'wcs_renewal_order_created ' , [ $ this , 'delete_renewal_meta ' ], 10 );
0 commit comments