Automattic\WooCommerce\Internal\RestApi\Routes\V4\Fulfillments
Controller::get_providers
Get all shipping providers.
Метод класса: Controller{}
Хуки из метода
Возвращает
WP_REST_Response.
Использование
$Controller = new Controller(); $Controller->get_providers( $request ): WP_REST_Response;
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Список изменений
| С версии 10.5.0 | Введена. |
Код Controller::get_providers() Controller::get providers WC 10.5.2
public function get_providers( WP_REST_Request $request ): WP_REST_Response {
$providers = \Automattic\WooCommerce\Internal\Fulfillments\FulfillmentUtils::get_shipping_providers_object();
/**
* Filters the shipping providers response before it is returned.
*
* Each provider in the array must have the following structure:
* - 'label' (string): The display name of the provider.
* - 'icon' (string): URL to the provider's icon.
* - 'value' (string): The provider's unique identifier.
* - 'url' (string): The tracking URL template.
*
* @param array $providers The shipping providers data.
* @param WP_REST_Request $request The request object.
*
* @since 10.5.0
*/
$providers = apply_filters( 'woocommerce_rest_prepare_fulfillments_providers', $providers, $request );
// Validate filtered result to prevent extensions from returning invalid structures.
if ( ! is_array( $providers ) ) {
_doing_it_wrong(
'woocommerce_rest_prepare_fulfillments_providers',
esc_html__( 'The filter must return an array of providers.', 'woocommerce' ),
'10.5.0'
);
$providers = array();
} else {
$providers = $this->validate_providers_structure( $providers );
}
return new WP_REST_Response( $providers, WP_Http::OK );
}