| @@ 336-348 (lines=13) @@ | ||
| 333 | * @param WP_REST_Request $request Full details about the request. |
|
| 334 | * @return WP_Error|WP_REST_Response |
|
| 335 | */ |
|
| 336 | public function get_item( $request ) { |
|
| 337 | $id = (int) $request['id']; |
|
| 338 | $customer = get_userdata( $id ); |
|
| 339 | ||
| 340 | if ( empty( $id ) || empty( $customer->ID ) ) { |
|
| 341 | return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 342 | } |
|
| 343 | ||
| 344 | $customer = $this->prepare_item_for_response( $customer, $request ); |
|
| 345 | $response = rest_ensure_response( $customer ); |
|
| 346 | ||
| 347 | return $response; |
|
| 348 | } |
|
| 349 | ||
| 350 | /** |
|
| 351 | * Update a single user. |
|
| @@ 325-337 (lines=13) @@ | ||
| 322 | * @param WP_REST_Request $request Full details about the request. |
|
| 323 | * @return WP_Error|WP_REST_Response |
|
| 324 | */ |
|
| 325 | public function get_item( $request ) { |
|
| 326 | $id = (int) $request['id']; |
|
| 327 | $tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT ); |
|
| 328 | ||
| 329 | if ( empty( $id ) || empty( $tax_obj ) ) { |
|
| 330 | return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) ); |
|
| 331 | } |
|
| 332 | ||
| 333 | $tax = $this->prepare_item_for_response( $tax_obj, $request ); |
|
| 334 | $response = rest_ensure_response( $tax ); |
|
| 335 | ||
| 336 | return $response; |
|
| 337 | } |
|
| 338 | ||
| 339 | /** |
|
| 340 | * Update a single tax. |
|