Customers
/loyalty-program/v1/customers
The admin customers API allows you to search for customers, view a specific customers data (status, sources and history) and adjust their unclaimed points (increase or decrease).
GET: /wp-json/loyalty-program/v1/customers
Search customers based on id, first name, last name, email, meta values, etc.
Requirements:
Logged-in user
user role with
manage_woocommerceuser capability
Method
Endpoint
GET
/wp-json/loyalty-program/v1/customers
Query Parameters
Required
Type
Description
search
true
string
search keyword
Get all customers
GET: http://example.com/wp-json/loyalty-program/v1/customersSearching for customers
GET: http://example.com/wp-json/loyalty-program/v1/customers?search=dummyStatus: 200 OK
Get all customers / Searching for customers
[
...
{
"id": 17,
"name": "John Smith",
"email": "johnsmith@example.com",
},
...
}Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}GET: /wp-json-loyalty-program/v1/customers/status/{user_id}
Get customer's points status and sources data.
Requirements:
Logged-in user
user role with
manage_woocommerceuser capability
Method
Endpoint
GET
/wp-json-loyalty-program/v1/customers/status/{user_id}
Get customer points status data
GET: http://example.com/wp-json/loyalty-program/v1/customers/status/17Status: 200 OK
{
"status": [
{
"label": "Total Points (All Time)",
"points": 61,
"value": "$6.10"
},
{
"label": "Unclaimed Points",
"points": 61,
"value": "$6.10"
},
{
"label": "Claimed Points",
"points": 0,
"value": "$0.00"
},
{
"label": "Expired Points",
"points": 0,
"value": "$0.00"
}
],
"sources": [
{
"label": "Purchasing products",
"points": 61
},
{
"label": "Leaving a product review",
"points": 0
},
{
"label": "Commenting on a blog post",
"points": 0
},
{
"label": "Registering as a user/customer",
"points": 0
},
{
"label": "After completing first order",
"points": 0
},
{
"label": "Spending over a certain amount",
"points": 0
},
{
"label": "Extra points during a period",
"points": 0
}
]
}Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}GET: /wp-json/loyalty-program/v1/customers/history/{user_id}
Get customer's points history data.
Requirements:
Logged-in user
user role with
manage_woocommerceuser capability
Method
Endpoint
GET
/wp-json/loyalty-program/v1/customers/history/{user_id}
Query Parameters
Required
Type
Description
page
false
number
Page number
Custom Response Headers
Type
Description
X-TOTAL
number
Total number of history entries
Get customer's most recent points history (10 entries)
GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17Get next page of history entries
GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17?page=2Status: 200 OK
Headers:
{
...
X-TOTAL: 15
}
JSON Body:
[
...
{
"id": 101,
"object_id": 258,
"action": "buy_product",
"date": "01/27/2021 08:55:54",
"activity": "Purchasing products",
"points": 61,
"rel_link": "http://acfw.test/wp-admin/post.php?post=258&action=edit",
"rel_label": "View Order"
}
...
]Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}POST: /wp-json/loyalty-program/v1/customers/points/{user_id}
Adjust customer's unclaimed points.
Requirements:
Logged-in user
user role with
manage_woocommerceuser capability
Method
Endpoint
POST
/wp-json/loyalty-program/v1/customers/points/{user_id}
Query Parameters
Required
Type
Description
type
true
string
increase or decrease
points
true
integer
Number of points to increase/decrease
Increase customer's points
POST: http://example.com/wp-json/loyalty-program/v1/customers/points/17
JSON Body:
{
"type": "increase",
"points": 50
}Decrease customer's points
POST: http://example.com/wp-json/loyalty-program/v1/customers/points/17
JSON Body:
{
"type": "decrease",
"points": 50
}Status: 200 OK
Increase customer's points
{
"message": "Successfully adjusted points for customer.",
"status": [
{
"label": "Total Points (All Time)",
"points": 111,
"value": "$11.10"
},
{
"label": "Unclaimed Points",
"points": 111,
"value": "$11.10"
},
{
"label": "Claimed Points",
"points": 0,
"value": "$0.00"
},
{
"label": "Expired Points",
"points": 0,
"value": "$0.00"
}
],
"sources": [
{
"label": "Purchasing products",
"points": 61
},
{
"label": "Leaving a product review",
"points": 0
},
{
"label": "Commenting on a blog post",
"points": 0
},
{
"label": "Registering as a user/customer",
"points": 0
},
{
"label": "After completing first order",
"points": 0
},
{
"label": "Spending over a certain amount",
"points": 0
},
{
"label": "Extra points during a period",
"points": 0
}
]
}Status: 200 OK
Decrease customer's points
{
"message": "Successfully adjusted points for customer.",
"status": [
{
"label": "Total Points (All Time)",
"points": 1,
"value": "$0.10"
},
{
"label": "Unclaimed Points",
"points": 1,
"value": "$0.10"
},
{
"label": "Claimed Points",
"points": 0,
"value": "$0.00"
},
{
"label": "Expired Points",
"points": 0,
"value": "$0.00"
}
],
"sources": [
{
"label": "Purchasing products",
"points": 61
},
{
"label": "Leaving a product review",
"points": 0
},
{
"label": "Commenting on a blog post",
"points": 0
},
{
"label": "Registering as a user/customer",
"points": 0
},
{
"label": "After completing first order",
"points": 0
},
{
"label": "Spending over a certain amount",
"points": 0
},
{
"label": "Extra points during a period",
"points": 0
}
]
}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?