Fix toggle tracking

This commit is contained in:
Fernando Marichal 2022-02-10 17:05:27 -03:00
parent ca88734006
commit 7abd23438d
3 changed files with 5 additions and 3 deletions

View File

@ -215,7 +215,6 @@ abstract class WC_Settings_API {
}
}
}
$this->add_admin_options_tracking();
return update_option( $this->get_option_key(), apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' );
}

View File

@ -3086,16 +3086,20 @@ class WC_AJAX {
continue;
}
$enabled = $gateway->get_option( 'enabled', 'no' );
$gateway->add_admin_options_tracking();
$option = array(
'id' => $gateway->get_option_key()
);
if ( ! wc_string_to_bool( $enabled ) ) {
if ( $gateway->needs_setup() ) {
wp_send_json_error( 'needs_setup' );
wp_die();
} else {
do_action( 'woocommerce_update_option', $option );
$gateway->update_option( 'enabled', 'yes' );
}
} else {
do_action( 'woocommerce_update_option', $option );
// Disable the gateway.
$gateway->update_option( 'enabled', 'no' );
}

View File

@ -32,7 +32,6 @@ class WC_Settings_Tracking {
public function init() {
add_action( 'woocommerce_settings_page_init', array( $this, 'track_settings_page_view' ) );
add_action( 'woocommerce_update_option', array( $this, 'add_option_to_list' ) );
add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'add_option_to_list' ) );
add_action( 'woocommerce_update_options', array( $this, 'send_settings_change_event' ) );
}