createCheckoutTemplate( )
Creates a checkout template.
Description
A checkout template is used to create a new checkout that will include predefined information. For example, a single link with
a checkoutTemplateId
can be shared with customers and each time the link is clicked, a new checkout page will be created
for that customer with certain checkout information already populated.
The customizable features include the option to allow or to lock coupon codes or gift cards. For example, if a store owner is
using the checkout template to offer a flash sale to their social media followers, they may want to lock the option to apply an
additional coupon on top of the sale being offered. If so, they can set customization.applyCouponLocked
to true
.
A checkout can be created with a checkout template by calling createCheckoutFromTemplate()
. The site may add further customizations to the new checkout and then redirect the customer using the new checkout's checkoutUrl
.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function createCheckoutTemplate(checkoutTemplate: CheckoutTemplate): Promise<CheckoutTemplate>
createCheckoutTemplate Parameters
NAME
TYPE
DESCRIPTION
Checkout template to create.
Returns
Created checkout template.
Return Type:
NAME
TYPE
DESCRIPTION
Checkout template ID.
Coupon code.
Note that a checkout can only hold one couponCode
at a time. If an additional couponCode
is added, it will override the existing couponCode
.
For additional information, see the Coupons API.
Custom settings to apply to the checkout page created from this template.
Line items.
Max: 300 items
Status of the checkout template.
When status
is INACTIVE
checkouts will not be created with this template _id
. Instead, the function will redirect to the domain site.
Default: ACTIVE
Was this helpful?
createCheckoutTemplate example
1import { checkoutTemplates } from 'wix-ecom-backend';23 async function createCheckoutTemplate(checkoutTemplate) {4 try {5 const result = await checkoutTemplates.createCheckoutTemplate(checkoutTemplate);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13