Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential fatal in the WooPay express checkout button #10236

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading