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.


Top ↑

Return Return

(string) the URL.


Top ↑

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;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.