> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CreateCheckoutFromTemplate # Package: checkout # Namespace: CheckoutTemplateService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/checkout/checkout-templates/create-checkout-from-template.md ## Permission Scopes: Manage eCommerce - all permissions: SCOPE.DC-ECOM-MEGA.MANAGE-ECOM ## Introduction Creates a new checkout based on the checkout template. Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template. The customer can be directed to the new checkout using the checkout's `checkoutUrl`. --- ## REST API ### Schema ``` Method: createCheckoutFromTemplate Description: Creates a new checkout based on the checkout template. Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template. The customer can be directed to the new checkout using the checkout's `checkoutUrl`. URL: https://www.wixapis.com/ecom/v1/checkout-templates/{checkoutTemplateId}/create-checkout-from-template Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: siteId Method parameters: param name: siteId | type: siteId | description: GUID of the site associated with the checkout template. | required: true Return type: CreateCheckoutFromTemplateResponse - name: checkoutId | type: string | description: GUID of the created checkout. - name: checkoutUrl | type: string | description: URL of the created checkout page. - name: purchaseFlowId | type: string | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: One or more items in the checkout template have insufficient inventory. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ITEM_NOT_FOUND_IN_CATALOG | Description: One or more items in the checkout template could not be found in the catalog. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_CREATE_CHECKOUT_FROM_INACTIVE_TEMPLATE | Description: Checkout template is inactive. ``` ### Examples ### Create Checkout From Template ```curl curl -X POST \ 'https://www.wixapis.com/ecom/v1/checkout-templates/d447475f-34ed-4be5-b199-b120c6938c39/create-checkout-from-template' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "siteId": "811d8a67-3bd7-46a5-8cd9-843bb77b2a7d" }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.checkout.CheckoutTemplateService.createCheckoutFromTemplate(checkoutTemplateId, siteId) Description: Creates a new checkout based on the checkout template. Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template. The customer can be directed to the new checkout using the checkout's `checkoutUrl`. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: checkoutTemplateId, siteId Method parameters: param name: checkoutTemplateId | type: string | description: GUID of the checkout template to use to create a checkout from. | required: true param name: siteId | type: string | description: GUID of the site associated with the checkout template. | required: true Return type: PROMISE - name: checkoutId | type: string | description: GUID of the created checkout. - name: checkoutUrl | type: string | description: URL of the created checkout page. - name: purchaseFlowId | type: string | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: One or more items in the checkout template have insufficient inventory. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ITEM_NOT_FOUND_IN_CATALOG | Description: One or more items in the checkout template could not be found in the catalog. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_CREATE_CHECKOUT_FROM_INACTIVE_TEMPLATE | Description: Checkout template is inactive. ``` ### Examples ### createCheckoutFromTemplate ```javascript import { checkoutTemplates } from '@wix/ecom'; async function createCheckoutFromTemplate(checkoutTemplateId,siteId) { const response = await checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId,siteId); }; ``` ### createCheckoutFromTemplate (with elevated permissions) ```javascript import { checkoutTemplates } from '@wix/ecom'; import { auth } from '@wix/essentials'; async function myCreateCheckoutFromTemplateMethod(checkoutTemplateId,siteId) { const elevatedCreateCheckoutFromTemplate = auth.elevate(checkoutTemplates.createCheckoutFromTemplate); const response = await elevatedCreateCheckoutFromTemplate(checkoutTemplateId,siteId); } ``` ### createCheckoutFromTemplate (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { checkoutTemplates } from '@wix/ecom'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { checkoutTemplates }, // Include the auth strategy and host as relevant }); async function createCheckoutFromTemplate(checkoutTemplateId,siteId) { const response = await myWixClient.checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId,siteId); }; ``` ---