Skip to content

Commit 6bb24e1

Browse files
authored
Fix potential fatal in the WooPay express checkout button (#10236)
1 parent 0454bb5 commit 6bb24e1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Prevent potential fatal when initializing the WooPay express checkout button.

includes/class-wc-payments-woopay-button-handler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ public function init() {
125125

126126
// Create WooPay button location option if it doesn't exist and enable all locations by default.
127127
if ( ! array_key_exists( self::BUTTON_LOCATIONS, get_option( 'woocommerce_woocommerce_payments_settings' ) ) ) {
128+
if ( isset( $this->gateway->form_fields[ self::BUTTON_LOCATIONS ]['options'] ) ) {
129+
$all_locations = $this->gateway->form_fields[ self::BUTTON_LOCATIONS ]['options'];
128130

129-
$all_locations = $this->gateway->form_fields[ self::BUTTON_LOCATIONS ]['options'];
130-
131-
$this->gateway->update_option( self::BUTTON_LOCATIONS, array_keys( $all_locations ) );
132-
133-
WC_Payments::woopay_tracker()->woopay_locations_updated( $all_locations, array_keys( $all_locations ) );
131+
$this->gateway->update_option( self::BUTTON_LOCATIONS, array_keys( $all_locations ) );
132+
WC_Payments::woopay_tracker()->woopay_locations_updated( $all_locations, array_keys( $all_locations ) );
133+
}
134134
}
135135

136136
add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] );

0 commit comments

Comments
 (0)