Advanced Coupons API
  • REST API
  • coupons/v1
    • Virtual Coupons (Premium)
      • Query a list of virtual coupons
      • Fetch virtual coupon stats
      • Create a virtual coupon
      • Retrieve a virtual coupon
      • Update a virtual coupon
      • Delete a virtual coupon
      • Bulk create virtual coupons
      • Bulk delete virtual coupons
    • Search Customers (Premium)
    • Settings
  • loyalty-program/v1
    • Dashboard
    • Customers
    • Settings
    • My Points
  • wc-loyalty-program/v1
    • Dashboard
    • Customers
    • Settings
  • wc-store-credits/v1
    • Entries
      • Query a list of store credit entries
      • Create a store credit entry
      • Fetch a single store credit entry
      • Update store credit entry
      • Delete store credit entry
    • Customers
      • Get dashboard statistics data
      • Query list of customers with store credits balance
      • Get single customer statistics and sources
Powered by GitBook
On this page
  • GET: /wp-json/loyalty-program/v1/customers
  • GET: /wp-json-loyalty-program/v1/customers/status/{user_id}
  • ​GET: /wp-json/loyalty-program/v1/customers/history/{user_id}
  • POST: /wp-json/loyalty-program/v1/customers/points/{user_id}

Was this helpful?

  1. loyalty-program/v1

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_woocommerce user 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/customers

Searching for customers

GET: http://example.com/wp-json/loyalty-program/v1/customers?search=dummy

Status: 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_woocommerce user 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/17

Status: 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_woocommerce user 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/17

Get next page of history entries

GET: http://example.com/wp-json/loyalty-program/v1/customers/history/17?page=2

Status: 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_woocommerce user 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
    }
}

PreviousDashboardNextSettings

Last updated 3 years ago

Was this helpful?