Search.../

getCoupon( )

Retrieves a coupon by ID.

Description

The getCoupon() function returns a Promise that resolves when the specified coupon is retrieved.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getCoupon(_id: string): Promise<Coupon>

getCoupon Parameters

NAME
TYPE
DESCRIPTION
_id
string

ID of the coupon to retrieve.

Returns

Retrieved coupon.

Return Type:

Promise<
Coupon
>
NAME
TYPE
DESCRIPTION
_id
string

Coupon ID.

appId
string

ID of the app that created the coupon. Empty if created by the site owner.

dateCreated
string

Time the coupon was created (UNIX Epoch time in milliseconds).

displayData
DisplayData

Coupon display information.

expired
boolean

Whether the coupon is expired.

numberOfUsages
number

How many times this coupon has been used.

specification
Specification

Basic coupon info.

Was this helpful?

getCoupon example

Copy Code
1import { coupons } from 'wix-marketing.v2';
2
3 async function getCoupon(id) {
4 try {
5 const result = await coupons.getCoupon(id);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13