Fixed get_woocommerce_api_url() for the new API versions numbers and
fixed the tests @mikejolley
This commit is contained in:
parent
dd24b978ff
commit
8a9ab7ffea
|
@ -563,7 +563,8 @@ function wc_setcookie( $name, $value, $expire = 0, $secure = false ) {
|
||||||
*/
|
*/
|
||||||
function get_woocommerce_api_url( $path ) {
|
function get_woocommerce_api_url( $path ) {
|
||||||
|
|
||||||
$version = defined( 'WC_API_REQUEST_VERSION' ) ? WC_API_REQUEST_VERSION : WC_API::VERSION;
|
$_version = substr( WC_API::VERSION, 0, 1 );
|
||||||
|
$version = defined( 'WC_API_REQUEST_VERSION' ) ? WC_API_REQUEST_VERSION : $_version;
|
||||||
|
|
||||||
$url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' );
|
$url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' );
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,10 @@ class Core_Functions extends \WC_Unit_Test_Case {
|
||||||
$base_uri = get_home_url();
|
$base_uri = get_home_url();
|
||||||
|
|
||||||
// base uri
|
// base uri
|
||||||
$this->assertEquals( "$base_uri/wc-api/v2.1.0/", get_woocommerce_api_url( null ) );
|
$this->assertEquals( "$base_uri/wc-api/v2/", get_woocommerce_api_url( null ) );
|
||||||
|
|
||||||
// path
|
// path
|
||||||
$this->assertEquals( "$base_uri/wc-api/v2.1.0/orders", get_woocommerce_api_url( 'orders' ) );
|
$this->assertEquals( "$base_uri/wc-api/v2/orders", get_woocommerce_api_url( 'orders' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue