Search.../

markCheckoutAsCompleted( )

Marks a checkout as completed - checkout.complete boolean is set to true.

Description

The markCheckoutAsCompleted() function returns a Promise that resolves when the specified checkout is marked as completed.

Syntax

function markCheckoutAsCompleted(_id: string): Promise<void>

markCheckoutAsCompleted Parameters

NAME
TYPE
DESCRIPTION
_id
string

Checkout ID.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Mark a checkout as completed

Copy Code
1/**************************************
2 * Backend code - my-backend-file.jsw *
3 *************************************/
4
5import { checkout } from 'wix-ecom-backend';
6
7export async function myMarkCheckoutAsCompletedFunction(checkoutId) {
8 try {
9 await checkout.markCheckoutAsCompleted(checkoutId);
10 console.log('Success! Checkout marked as completed');
11 return;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/*************
19 * Page code *
20 ************/
21
22import { myMarkCheckoutAsCompletedFunction } from 'backend/my-backend-file';
23
24// Sample checkoutId:
25const checkoutId = '96a61a4b-6b61-47d1-a039-0213a8230ccd';
26
27myMarkCheckoutAsCompletedFunction(checkoutId)
28 .then(() => {
29 console.log('Success! Checkout marked as completed');
30 return;
31 })
32 .catch((error) => {
33 console.error(error);
34 // Handle the error
35 });
36
Mark a checkout as completed (export from backend code)

Copy Code
1/**************************************
2 * Backend code - my-backend-file.web.js *
3 *************************************/
4
5import { Permissions, webMethod } from 'wix-web-module';
6import { checkout } from 'wix-ecom-backend';
7
8export const myMarkCheckoutAsCompletedFunction = webMethod(Permissions.Anyone, async (checkoutId) => {
9 try {
10 await checkout.markCheckoutAsCompleted(checkoutId);
11 console.log('Success! Checkout marked as completed');
12 return;
13 } catch (error) {
14 console.error(error);
15 // Handle the error
16 }
17});
18
19/*************
20 * Page code *
21 ************/
22
23import { myMarkCheckoutAsCompletedFunction } from 'backend/my-backend-file.web';
24
25// Sample checkoutId:
26const checkoutId = '96a61a4b-6b61-47d1-a039-0213a8230ccd';
27
28myMarkCheckoutAsCompletedFunction(checkoutId)
29 .then(() => {
30 console.log('Success! Checkout marked as completed');
31 return;
32 })
33 .catch((error) => {
34 console.error(error);
35 // Handle the error
36 });
37
38