Skip to main content

setCustomURLsBuilder

The setCustomURLsBuilder method allows you to provide custom URL builders for product, collection, and login pages. Use this on custom storefronts where Shopify's standard URL structure (/products/<handle>, /collections/<handle>, /account/login) does not apply.

When set, all three builder methods are used by Growave widgets in place of the default Shopify URL builders.

Usage example​

Ensure the SDK is ready before setting the custom URLs builder.

function onSdkReady() {
window.gw.sdk.common.methods.setCustomURLsBuilder({
createProductUrl({ productHandle, variantId, productId }) {
const url = `/p/${productHandle}`;
return variantId ? `${url}?variant=${variantId}` : url;
},
createCollectionUrl({ collectionHandle, collectionId }) {
return `/c/${collectionHandle}`;
},
createStorefrontLoginUrl() {
return "/custom-auth-url";
},
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

Types​

CustomURLsBuilderInterface​

Your custom URLs builder must implement this interface:

CustomURLsBuilderInterface
interface
Methods
createCollectionUrl(params)string
Parameters
NameTypeDescription
params{ collectionHandle: string; collectionId?: number }—
Returns:
string
createProductUrl(params)string
Parameters
NameTypeDescription
params{ productHandle: string; productId?: number; variantId?: number }—
Returns:
string
createStorefrontLoginUrl()string
Returns:
string