customer_id ); if ( $customer ) { $customer->recalculate_stats(); $this->result_data = array( 'purchase_count' => (int) $customer->purchase_count, 'purchase_value' => esc_html( edd_currency_filter( edd_format_amount( $customer->purchase_value ) ) ), ); return true; } return false; } /** * Return the calculated completion percentage * * @since 2.5 * @return int */ public function get_percentage_complete() { $total = edd_count_orders( array( 'customer_id' => $this->customer_id, ) ); $percentage = 100; if ( $total > 0 ) { $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; } if ( $percentage > 100 ) { $percentage = 100; } return $percentage; } /** * Set the properties specific to the payments export * * @since 2.5 * @param array $request The Form Data passed into the batch processing */ public function set_properties( $request ) { $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; } /** * Process a step * * @since 2.5 * @return bool */ public function process_step() { if ( ! $this->can_export() ) { wp_die( esc_html__( 'You do not have permission to modify this data.', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); } $had_data = $this->get_data(); if ( ! $had_data ) { $this->done = false; return true; } $this->done = true; $this->message = esc_html__( 'Customer stats successfully recounted.', 'easy-digital-downloads' ); return false; } public function headers() { edd_set_time_limit(); } /** * Perform the export * * @since 2.5 * @return void */ public function export() { // Set headers $this->headers(); edd_die(); } }