WC_Settings_API::process_admin_options()publicWC 1.0

Processes and saves options. If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.

Method of the class: WC_Settings_API{}

Return

true|false. was anything saved?

Usage

$WC_Settings_API = new WC_Settings_API();
$WC_Settings_API->process_admin_options();

WC_Settings_API::process_admin_options() code WC 8.7.0

public function process_admin_options() {
	$this->init_settings();

	$post_data = $this->get_post_data();

	foreach ( $this->get_form_fields() as $key => $field ) {
		if ( 'title' !== $this->get_field_type( $field ) ) {
			try {
				$this->settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
				if ( 'select' === $field['type'] || 'checkbox' === $field['type'] ) {
					/**
					 * Notify that a non-option setting has been updated.
					 *
					 * @since 7.8.0
					 */
					do_action(
						'woocommerce_update_non_option_setting',
						array(
							'id'    => $key,
							'type'  => $field['type'],
							'value' => $this->settings[ $key ],
						)
					);
				}
			} catch ( Exception $e ) {
				$this->add_error( $e->getMessage() );
			}
		}
	}

	$option_key = $this->get_option_key();
	do_action( 'woocommerce_update_option', array( 'id' => $option_key ) ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	return update_option( $option_key, apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
}