This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a new checkout based on the checkout template.
Before using this function, you must have a checkout template available. Create a checkout template with createCheckoutTemplate()
.
The customer can be directed to the new checkout using the checkout's checkoutUrl
.
function createCheckoutFromTemplate(
checkoutTemplateId: string,
siteId: string,
): Promise<CreateCheckoutFromTemplateResponse>;
ID of the checkout template to use to create a checkout from.
ID of the site associated with the checkout template.
import { checkoutTemplates } from "wix-ecom-backend";
async function createCheckoutFromTemplate(checkoutTemplateId, siteId) {
try {
const result = await checkoutTemplates.createCheckoutFromTemplate(
checkoutTemplateId,
siteId,
);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.