WC_REST_Shipping_Methods_V2_Controller::get_items
Get shipping methods.
Method of the class: WC_REST_Shipping_Methods_V2_Controller{}
No Hooks.
Returns
WP_Error|WP_REST_Response.
Usage
$WC_REST_Shipping_Methods_V2_Controller = new WC_REST_Shipping_Methods_V2_Controller(); $WC_REST_Shipping_Methods_V2_Controller->get_items( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
WC_REST_Shipping_Methods_V2_Controller::get_items() WC REST Shipping Methods V2 Controller::get items code WC 10.3.6
public function get_items( $request ) {
$wc_shipping = WC_Shipping::instance();
$data = array();
foreach ( $wc_shipping->get_shipping_methods() as $id => $shipping_method ) {
$method = $this->prepare_item_for_response( $shipping_method, $request );
$method = $this->prepare_response_for_collection( $method );
$data[] = $method;
}
$total = count( $data );
$response = rest_ensure_response( $data );
$response->header( 'X-WP-Total', (int) $total );
$response->header( 'X-WP-TotalPages', $total ? 1 : 0 );
return $response;
}