Skip to content

Commit 1709a16

Browse files
authored
Extract is_link_enabled in a separate static method to fix compatibility issues (#2403)
* Extract is_link_enabled in a separate static method
1 parent 8e54228 commit 1709a16

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
= 6.6.0 - 2022-xx-xx =
44

5+
= 6.5.1 - 2022-08-01 =
6+
* Fix - Stripe Link fatal error on `get_upe_enabled_payment_method_ids` method.
7+
58
= 6.5.0 - 2022-07-28 =
69
* Add - Stripe Link: Add beta headers for Stripe server requests
710
* Add - Stripe Link payment method option in admin

includes/payment-methods/class-wc-stripe-upe-payment-method-link.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,22 @@ public function __construct() {
2626
'woocommerce-gateway-stripe'
2727
);
2828
}
29+
30+
/**
31+
* Return if Stripe Link is enabled
32+
*
33+
* @return bool
34+
*/
35+
public static function is_link_enabled() {
36+
// Assume Link is disabled if UPE is disabled.
37+
if ( ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
38+
return false;
39+
}
40+
41+
return in_array(
42+
self::STRIPE_ID,
43+
woocommerce_gateway_stripe()->get_main_stripe_gateway()->get_upe_enabled_payment_method_ids(),
44+
true
45+
);
46+
}
2947
}

woocommerce-gateway-stripe.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ public function init() {
243243
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
244244

245245
// Update the email field position.
246-
add_filter( 'woocommerce_billing_fields', [ $this, 'checkout_update_email_field_priority' ], 50 );
246+
if ( ! is_admin() ) {
247+
add_filter( 'woocommerce_billing_fields', [ $this, 'checkout_update_email_field_priority' ], 50 );
248+
}
247249

248250
// Modify emails emails.
249251
add_filter( 'woocommerce_email_classes', [ $this, 'add_emails' ], 20 );
@@ -659,13 +661,7 @@ public function get_main_stripe_gateway() {
659661
* @return array WooCommerce checkout fields.
660662
*/
661663
public function checkout_update_email_field_priority( $fields ) {
662-
$is_link_enabled = in_array(
663-
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
664-
$this->stripe_gateway->get_upe_enabled_payment_method_ids(),
665-
true
666-
);
667-
668-
if ( $is_link_enabled ) {
664+
if ( isset( $fields['billing_email'] ) && WC_Stripe_UPE_Payment_Method_Link::is_link_enabled() ) {
669665
// Update the field priority.
670666
$fields['billing_email']['priority'] = 1;
671667

0 commit comments

Comments
 (0)