WC_REST_Shipping_Zones_V2_Controller::update_item()
Update a single Shipping Zone.
Method of the class: WC_REST_Shipping_Zones_V2_Controller{}
No Hooks.
Return
WP_REST_Request|WP_Error
.
Usage
$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) (required)
- Full details about the request.
WC_REST_Shipping_Zones_V2_Controller::update_item() WC REST Shipping Zones V2 Controller::update item code WC 7.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 ); }