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.
sdk.common.methods.setCustomURLsBuilder()setCustomURLsBuilder(customURLsBuilder: CustomURLsBuilderInterface): Promise<Success>Parameters
customURLsBuilderCustomURLsBuilderInterface- An object implementing the
CustomURLsBuilderInterfaceinterface.
Returns
Promise<Success>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:
CustomURLsBuilderInterfaceMethods
createCollectionUrl(params)stringcreateProductUrl(params)stringcreateStorefrontLoginUrl()string
Parameters
| Name | Type | Description |
|---|---|---|
| params | { collectionHandle: string; collectionId?: number } | — |
Returns:
string
Parameters
| Name | Type | Description |
|---|---|---|
| params | { productHandle: string; productId?: number; variantId?: number } | — |
Returns:
string
Returns:
string