コード例 #1
0
 /**
  * Generate the default sales stats returned by the 'stats' endpoint
  *
  * @access private
  * @since  1.1
  * @return array default sales statistics
  */
 private function get_default_sales_stats()
 {
     // Default sales return
     $sales = array();
     $sales['donations']['today'] = $this->stats->get_sales(0, 'today');
     $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
     $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month');
     $sales['donations']['totals'] = give_get_total_sales();
     return $sales;
 }
コード例 #2
0
 /**
  * Test Pending without Affecting Stats
  */
 public function test_pending_without_affecting_stats()
 {
     add_filter('give_decrease_earnings_on_undo', '__return_false');
     add_filter('give_decrease_sales_on_undo', '__return_false');
     add_filter('give_decrease_customer_value_on_pending', '__return_false');
     add_filter('give_decrease_customer_purchase_count_on_pending', '__return_false');
     add_filter('give_decrease_store_earnings_on_pending', '__return_false');
     $payment = new Give_Payment($this->_payment_id);
     $payment->status = 'complete';
     $payment->save();
     $customer = new Give_Customer($payment->customer_id);
     $form = new Give_Donate_Form($payment->form_id);
     $customer_sales = $customer->purchase_count;
     $customer_earnings = $customer->purchase_value;
     $form_sales = $form->sales;
     $form_earnings = $form->earnings;
     $site_earnings = give_get_total_earnings();
     $site_sales = give_get_total_sales();
     $payment->status = 'pending';
     $payment->save();
     wp_cache_flush();
     $payment = new Give_Payment($this->_payment_id);
     $this->assertEmpty($payment->completed_date);
     $customer = new Give_Customer($payment->customer_id);
     $form = new Give_Donate_Form($payment->form_id);
     $this->assertEquals($customer_earnings, $customer->purchase_value);
     $this->assertEquals($customer_sales, $customer->purchase_count);
     $this->assertEquals($form_earnings, $form->earnings);
     $this->assertEquals($form_sales, $form->sales);
     $this->assertEquals($site_earnings, give_get_total_earnings());
     // Store sales are based off 'publish' & 'revoked' status. So it reduces this count
     $this->assertEquals($site_sales - 1, give_get_total_sales());
     remove_filter('give_decrease_earnings_on_undo', '__return_false');
     remove_filter('give_decrease_sales_on_undo', '__return_false');
     remove_filter('give_decrease_customer_value_on_pending', '__return_false');
     remove_filter('give_decrease_customer_purchase_count_on_pending', '__return_false');
     remove_filter('give_decrease_store_earnings_on_pending', '__return_false ');
 }