WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_REST_Shipping_Zone_Methods_V2_Controller::update_fields() public WC 1.0

Updates settings, order, and enabled status on create.

{} Это метод класса: WC_REST_Shipping_Zone_Methods_V2_Controller{}

Возвращает

WC_Shipping_Method.

Использование

$WC_REST_Shipping_Zone_Methods_V2_Controller = new WC_REST_Shipping_Zone_Methods_V2_Controller();
$WC_REST_Shipping_Zone_Methods_V2_Controller->update_fields( $instance_id, $method, $request );
$instance_id(число) (обязательный)
Instance ID.
$method(WC_Shipping_Method) (обязательный)
Shipping method data.
$request(WP_REST_Request) (обязательный)
Request data.

Код WC_REST_Shipping_Zone_Methods_V2_Controller::update_fields() WC 4.7.1

<?php
public function update_fields( $instance_id, $method, $request ) {
	global $wpdb;

	// Update settings if present.
	if ( isset( $request['settings'] ) ) {
		$method->init_instance_settings();
		$instance_settings = $method->instance_settings;
		$errors_found      = false;
		foreach ( $method->get_instance_form_fields() as $key => $field ) {
			if ( isset( $request['settings'][ $key ] ) ) {
				if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) {
					$value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field );
				} else {
					$value = $this->validate_setting_text_field( $request['settings'][ $key ], $field );
				}
				if ( is_wp_error( $value ) ) {
					$errors_found = true;
					break;
				}
				$instance_settings[ $key ] = $value;
			}
		}

		if ( $errors_found ) {
			return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
		}

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

	// Update order.
	if ( isset( $request['order'] ) ) {
		$wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'method_order' => absint( $request['order'] ) ), array( 'instance_id' => absint( $instance_id ) ) );
		$method->method_order = absint( $request['order'] );
	}

	// Update if this method is enabled or not.
	if ( isset( $request['enabled'] ) ) {
		if ( $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => $request['enabled'] ), array( 'instance_id' => absint( $instance_id ) ) ) ) {
			do_action( 'woocommerce_shipping_zone_method_status_toggled', $instance_id, $method->id, $request['zone_id'], $request['enabled'] );
			$method->enabled = ( true === $request['enabled'] ? 'yes' : 'no' );
		}
	}

	return $method;
}