WordPress at Your Fingertips
function is not described

WC_Shipping_Method::process_admin_options() public WC 2.6.0

Processes and saves global shipping method options in the admin area.

This method is usually attached to woocommerce_update_options_x hooks.

{} It's a method of the class: WC_Shipping_Method{}

Return

true|false. was anything saved?

Usage

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

Changelog

Since 2.6.0 Introduced.

Code of WC_Shipping_Method::process_admin_options() WC 5.8.0

public function process_admin_options() {
	if ( ! $this->instance_id ) {
		return parent::process_admin_options();
	}

	// Check we are processing the correct form for this instance.
	if ( ! isset( $_REQUEST['instance_id'] ) || absint( $_REQUEST['instance_id'] ) !== $this->instance_id ) { // WPCS: input var ok, CSRF ok.
		return false;
	}

	$this->init_instance_settings();

	$post_data = $this->get_post_data();

	foreach ( $this->get_instance_form_fields() as $key => $field ) {
		if ( 'title' !== $this->get_field_type( $field ) ) {
			try {
				$this->instance_settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
			} catch ( Exception $e ) {
				$this->add_error( $e->getMessage() );
			}
		}
	}

	return update_option( $this->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this ), 'yes' );
}