get_woocommerce_api_url( string $path )
Get the URL to the WooCommerce REST API.
Description Description
Parameters Parameters
- $path
-
(Required) an endpoint to include in the URL.
Return Return
(string) the URL.
Source Source
File: includes/wc-core-functions.php
function get_woocommerce_api_url( $path ) {
if ( Constants::is_defined( 'WC_API_REQUEST_VERSION' ) ) {
$version = Constants::get_constant( 'WC_API_REQUEST_VERSION' );
} else {
$version = substr( WC_API::VERSION, 0, 1 );
}
$url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' );
if ( ! empty( $path ) && is_string( $path ) ) {
$url .= ltrim( $path, '/' );
}
return $url;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1 | Introduced. |