Search.../

createCheckoutFromTemplate( )

Developer Preview

Creates a new checkout based on the checkout template.

Description

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.

Syntax

function createCheckoutFromTemplate(checkoutTemplateId: string, siteId: string): Promise<CreateCheckoutFromTemplateResponse>

createCheckoutFromTemplate Parameters

NAME
TYPE
DESCRIPTION
checkoutTemplateId
string

ID of the checkout template to use to create a checkout from.

siteId
string

ID of the site associated with the checkout template.

Returns

Return Type:

Promise<
CreateCheckoutFromTemplateResponse
>
NAME
TYPE
DESCRIPTION
checkoutId
string

ID of the created checkout.

checkoutUrl
string

URL of the created checkout page.

Was this helpful?

createCheckoutFromTemplate example

Copy Code
1import { checkoutTemplates } from 'wix-ecom-backend';
2
3 async function createCheckoutFromTemplate(checkoutTemplateId, siteId) {
4 try {
5 const result = await checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId, siteId);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13