WC_REST_Shipping_Zones_V2_Controller::update_item()
Update a single Shipping Zone.
Метод класса: WC_REST_Shipping_Zones_V2_Controller{}
Хуков нет.
Возвращает
WP_REST_Request|WP_Error
.
Использование
$WC_REST_Shipping_Zones_V2_Controller = new WC_REST_Shipping_Zones_V2_Controller(); $WC_REST_Shipping_Zones_V2_Controller->update_item( $request );
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Код WC_REST_Shipping_Zones_V2_Controller::update_item() WC REST Shipping Zones V2 Controller::update item WC 8.7.0
public function update_item( $request ) { $zone = $this->get_zone( $request->get_param( 'id' ) ); if ( is_wp_error( $zone ) ) { return $zone; } if ( 0 === $zone->get_id() ) { return new WP_Error( 'woocommerce_rest_shipping_zone_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) ); } $zone_changed = false; if ( ! is_null( $request->get_param( 'name' ) ) ) { $zone->set_zone_name( $request->get_param( 'name' ) ); $zone_changed = true; } if ( ! is_null( $request->get_param( 'order' ) ) ) { $zone->set_zone_order( $request->get_param( 'order' ) ); $zone_changed = true; } if ( $zone_changed ) { $zone->save(); } return $this->get_item( $request ); }