Query a list of virtual coupons
GET: /wp-json/coupons/v1/virtualcoupons
Requirements:
Logged-in user
user role with
manage_woocommerceuser capability
Method
Endpoint
GET
/wp-json/coupons/v1/virtualcoupons
Query Parameters
Required
Type
Default
Description
search
no
string
Search for virtual codes by name
status
no
string
Valid virtual coupon status (used|pending)
coupon_id
no
integer | integer[]
0
Coupon ID(s)
user_id
no
integer | integer[]
0
Customer ID(s)
date_created
no
string
A valid date text in mysql format. Y-m-d H:i:s
page
no
integer
1
Current page to load in query.
per_page
no
integer
10
Number of virtual coupons to list in a single page.
sort_by
no
string
date_created
Value to be based for sorting. (code|date_created|id|user_id|status|date_expire)
sort_order
no
string
desc
Order of sorting: desc or asc
codes_only
no
boolean
false
Return list of codes only when set to true.
date_format
no
string
F j, Y g:i a
Date format of virtual coupon date values. See here: https://www.php.net/manual/en/datetime.format.php
Get virtual coupons for coupon with id of 207
GET: http://example.com/wp-json/coupons1/v1/virtualcoupons?coupon_id=207Get all virtual coupon, but coupon code's only for the main coupon with id of 207
GET: http://example.com/wp-json/coupons1/v1/virtualcoupons?coupon_id=207&codes_only=1&page=-1Status: 200 OK
Get virtual coupons
Headers:
{
...
X-TOTAL: 100
}
[
...
{
"key": "116",
"id": 116,
"code": "67FQRYUYCT",
"main_code": "bogo1",
"coupon_code": "bogo1-67fqryuyct",
"status": "pending",
"coupon_id": 207,
"user_id": 0,
"user_fullname": "",
"user_email": "",
"date_created": "June 25, 2021 8:45 am",
"date_expire": ""
},
...
]Get virtual coupon codes only
[
"bogo1-67fqryuyct",
"bogo1-wuujfbsk44",
"bogo1-cje5svg862",
"bogo1-pmd8ukcuep",
"bogo1-m7w4zwbanp",
"bogo1-n8ywtbjywy",
"bogo1-2xagjdntw3",
"bogo1-75hp7usjc5",
...
]Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}Last updated
Was this helpful?