Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $year = 2020;
- $year_to_compare = $year - 1;
- $args = array(
- 'number' => -1,
- 'date_query' => array(
- array(
- 'year' => $year,
- ),
- ),
- );
- $customers = new EDD_Customer_Query( $args );
- $total = count( $customers->items );
- for ( $i = 0; $i < 5; $i++ ) {
- $args = array(
- 'number' => -1,
- 'date_query' => array(
- array(
- 'year' => $year_to_compare,
- ),
- ),
- );
- $customers = new EDD_Customer_Query( $args );
- $total = count( $customers->items );
- $renewed = 0;
- foreach ( $customers->items as $customer ) {
- $args = array(
- 'customer' => $customer->id,
- 'year' => $year,
- 'meta_key' => '_edd_sl_is_renewal',
- 'meta_value' => true,
- );
- $payments = new EDD_Payments_Query( $args );
- $payments = $payments->get_payments();
- if ( ! empty( $payments ) ) {
- $renewed++;
- }
- }
- error_log( 'YEAR ' . $year_to_compare . ' vs ' . $year );
- error_log( 'Total customers: ' . $total . '. Renewed in ' . $year . ': ' . $renewed );
- error_log( 'Renewal rate: ' . ( $renewed / $total ) * 100 . '%' );
- $year_to_compare--;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement