La classe
EDD_Payment_Stats è progettata per fornire un modo semplice per recuperare statistiche di guadagni e vendite per l'intero negozio, o prodotti specifici, per periodi di tempo designati, come questa settimana, il mese scorso, oggi, l'anno scorso, ecc.
Per usare
EDD_Payment_Stats, devi istanziare una nuova istanza della classe:
$stats = new EDD_Payment_Stats;
Una volta che la classe è istanziata, puoi usare una qualsiasi delle seguenti funzioni membro:
// Retrieve earnings $stats->get_earnings( $download_id = 0, $start_date = false, $end_date = false ); // Retrieve sales $stats->get_sales( $download_id = 0, $start_date = false, $end_date = false ); // Retrieve a list of the best selling Download products $stats->get_best_selling( $number = 10 );
Sia per
get_sales() che per get_earnings(), i seguenti parametri possono essere passati:
$download_id – L'ID numerico del prodotto per cui recuperare le statistiche. Se viene passato 0 o qualsiasi altro valore vuoto, le statistiche verranno recuperate per l'intero negozio.
$start_date – La data di inizio per cui recuperare le statistiche. Se vuoi recuperare le statistiche per uno dei periodi predefiniti, passa semplicemente il periodo, come "oggi" o "ieri". Questo parametro può essere una stringa di data, un timestamp o una data formattata in qualsiasi formato standard.
$end_date – La data di fine per cui recuperare le statistiche. Se vuoi recuperare le statistiche per uno dei periodi predefiniti, lascia questo campo vuoto. Questo parametro può essere una stringa di data, un timestamp o una data formattata in qualsiasi formato standard.
Le statistiche possono essere recuperate per qualsiasi periodo di tempo predefinito. Queste opzioni includono:
- oggi
- ieri
- questa_settimana
- settimana_scorsa
- questo_mese
- mese_scorso
- questo_trimestre
- trimestre_scorso
- quest_anno
- anno_scorso
Esempi
// Store-wide sales for this month: echo $stats->get_sales( 0, 'this_month' ); Returns an integer, the sum of sales in the given time span
// Store-wide earnings for August 2, 2013 echo $stats->get_earnings( 0, 'August 2, 2013' ); Returns an integer if earnings are a whole number, a float rounded to 2 if a fractional number, like 42.73
// Sales for download ID 44 from July 2 to August 5, 2013 echo $stats->get_sales( 44, 'July 2, 2013', 'August 5, 2013' );
// Earnings for download ID 52 for December 5, 2012 echo $stats->get_earnings( 52, '12-05-2012' )
$best_selling = $stats->get_best_selling( '10' );
Returns an array of the 10 best selling products, like this:
Array
(
[0] => stdClass Object
(
[download_id] => 68
[sales] => 3
)
[1] => stdClass Object
(
[download_id] => 120
[sales] => 2
)
)
