Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Shopify
ShopifyClient::build_rest_url
Build the REST API URL.
Method of the class: ShopifyClient{}
No Hooks.
Returns
String. The complete API URL.
Usage
// private - for code of main (parent) class only $result = $this->build_rest_url( $domain, $path, $query_params ): string;
- $domain(string) (required)
- The Shopify domain.
- $path(string) (required)
- The API path.
- $query_params(array) (required)
- Query parameters.
ShopifyClient::build_rest_url() ShopifyClient::build rest url code WC 10.8.1
private function build_rest_url( string $domain, string $path, array $query_params ): string {
// Ensure the domain has the protocol.
if ( ! preg_match( '~^https?://~i', $domain ) ) {
$domain = 'https://' . $domain;
}
$shop_url = untrailingslashit( $domain );
// Use the latest stable API version.
$api_version = '2025-04';
$rest_endpoint = "{$shop_url}/admin/api/{$api_version}{$path}";
if ( ! empty( $query_params ) ) {
$rest_endpoint = add_query_arg( $query_params, $rest_endpoint );
}
return $rest_endpoint;
}