La
EDD REST API fornisce un endpoint chiamato /customers/. L'endpoint clienti ti consente di interrogare il database e recuperare un elenco di clienti che hanno acquistato articoli dal tuo negozio. Una query di base per i clienti si presenta così:
https://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&number=25
Per ogni cliente restituito, vengono fornite le seguenti informazioni per ciascun cliente:
- id – L'ID utente di WordPress. Se il cliente ha acquistato come ospite, questo restituirà -1.
- username – Il nome di accesso dell'utente di WordPress. Se il cliente ha acquistato come ospite, questo non restituirà nulla.
- display_name – Il nome visualizzato dell'utente di WordPress. Se il cliente ha acquistato come ospite, questo non restituirà nulla.
- first_name – Il nome del cliente.
- last_name – Il cognome del cliente.
- email – L'indirizzo email del cliente.
- total_purchases – Il numero totale di acquisti effettuati dal cliente.
- total_spent – L'importo totale speso dal cliente.
- total_downloads – Il numero totale di file scaricati dal cliente.
Insieme ai dati restituiti per ogni cliente c'è un oggetto
stats che mostra il numero totale di clienti nel database.
Una risposta di query per i clienti si presenta così:
{
"customers": [
{
"info": {
"id": -1,
"username": "Guest",
"display_name": "Guest",
"first_name": "Guest",
"last_name": "Guest",
"email": "[email protected]"
},
"stats": {
"total_purchases": 2,
"total_spent": "20",
"total_downloads": 0
}
},
{
"info": {
"id": -1,
"username": "Guest",
"display_name": "Guest",
"first_name": "Guest",
"last_name": "Guest",
"email": "[email protected]"
},
"stats": {
"total_purchases": 0,
"total_spent": "0",
"total_downloads": 0
}
}
]
}
Se desideri recuperare le informazioni per un cliente specifico, puoi aggiungere il
parametro &customer={identifier}, così:
https://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&customer=1
o
https://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&[email protected]
La risposta per un singolo cliente sarà così:
{
"customers": [
{
"info": {
"id": 1,
"username": "pippin",
"display_name": "Pippin Williamson",
"first_name": "Pippin",
"last_name": "Williamson",
"email": "[email protected]"
},
"stats": {
"total_purchases": 61,
"total_spent": 1139.68,
"total_downloads": 31
}
}
]
}
