Skip to content

Commit

Permalink
Fix potential fatal in the WooPay express checkout button (#10236)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarcosta99 authored Jan 28, 2025
1 parent 0454bb5 commit 6bb24e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-10193-woopay-express-button-fatal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Prevent potential fatal when initializing the WooPay express checkout button.
10 changes: 5 additions & 5 deletions includes/class-wc-payments-woopay-button-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ public function init() {

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

$all_locations = $this->gateway->form_fields[ self::BUTTON_LOCATIONS ]['options'];

$this->gateway->update_option( self::BUTTON_LOCATIONS, array_keys( $all_locations ) );

WC_Payments::woopay_tracker()->woopay_locations_updated( $all_locations, array_keys( $all_locations ) );
$this->gateway->update_option( self::BUTTON_LOCATIONS, array_keys( $all_locations ) );
WC_Payments::woopay_tracker()->woopay_locations_updated( $all_locations, array_keys( $all_locations ) );
}
}

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

0 comments on commit 6bb24e1

Please sign in to comment.