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.
Request Request Example Response Example
Requirements:
user role with manage_woocommerce
user capability
/wp-json/loyalty-program/v1/customers
Get all customers
Copy GET: http://example.com/wp-json/loyalty-program/v1/customers
Searching for customers
Copy GET: http://example.com/wp-json/loyalty-program/v1/customers?search=dummy
Status: 200 OK
Get all customers / Searching for customers
Copy [
...
{
"id": 17,
"name": "John Smith",
"email": "johnsmith@example.com",
},
...
}
Status: 403 Forbidden
Copy {
"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.
Request Request Example Response Example
Requirements:
user role with manage_woocommerce
user capability
/wp-json-loyalty-program/v1/customers/status/{user_id}
Get customer points status data
Copy GET: http://example.com/wp-json/loyalty-program/v1/customers/status/17
Status: 200 OK
Copy {
"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
Copy {
"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.
Request Request Example Response Example
Requirements:
user role with manage_woocommerce
user capability
/wp-json/loyalty-program/v1/customers/history/{user_id}
Total number of history entries
Get customer's most recent points history (10 entries)
Copy GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17
Get next page of history entries
Copy GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17?page=2
Status: 200 OK
Copy 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
Copy {
"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.
Request Request Example Response Example
Requirements:
user role with manage_woocommerce
user capability
/wp-json/loyalty-program/v1/customers/points/{user_id}
Number of points to increase/decrease
Increase customer's points
Copy POST: http://example.com/wp-json/loyalty-program/v1/customers/points/17
JSON Body:
{
"type": "increase",
"points": 50
}
Decrease customer's points
Copy 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
Copy {
"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
Copy {
"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
Copy {
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}