Example #1
0
/**
 * Calculates the total amount spent by a user
 *
 * @access      public
 * @since       1.0
 *
 * @param       $user mixed - ID or email
 *
 * @return      float - the total amount the user has spent
 */
function give_purchase_total_of_user($user = null)
{
    $stats = give_get_purchase_stats_by_user($user);
    return $stats['total_spent'];
}
Example #2
0
 public function test_get_purchase_stats_by_user()
 {
     $purchase_stats = give_get_purchase_stats_by_user($this->_user_id);
     $this->assertInternalType('array', $purchase_stats);
     $this->assertEquals(2, count($purchase_stats));
     $this->assertTrue(isset($purchase_stats['purchases']));
     $this->assertTrue(isset($purchase_stats['total_spent']));
 }