| @@ 80-91 (lines=12) @@ | ||
| 77 | * @param WP_REST_Request $request |
|
| 78 | * @return array |
|
| 79 | */ |
|
| 80 | public function get_items( $request ) { |
|
| 81 | $downloads = wc_get_customer_available_downloads( (int) $request['customer_id'] ); |
|
| 82 | ||
| 83 | $data = array(); |
|
| 84 | foreach ( $downloads as $download_data ) { |
|
| 85 | $download = $this->prepare_item_for_response( (object) $download_data, $request ); |
|
| 86 | $download = $this->prepare_response_for_collection( $download ); |
|
| 87 | $data[] = $download; |
|
| 88 | } |
|
| 89 | ||
| 90 | return rest_ensure_response( $data ); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Prepare a single download output for response. |
|
| @@ 95-104 (lines=10) @@ | ||
| 92 | * @param WP_REST_Request $request Full details about the request. |
|
| 93 | * @return WP_Error|WP_REST_Response |
|
| 94 | */ |
|
| 95 | public function get_items( $request ) { |
|
| 96 | $wc_shipping = WC_Shipping::instance(); |
|
| 97 | $response = array(); |
|
| 98 | foreach ( $wc_shipping->get_shipping_methods() as $id => $shipping_method ) { |
|
| 99 | $method = $this->prepare_item_for_response( $shipping_method, $request ); |
|
| 100 | $method = $this->prepare_response_for_collection( $method ); |
|
| 101 | $response[] = $method; |
|
| 102 | } |
|
| 103 | return rest_ensure_response( $response ); |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Get a single Shipping Method. |
|