function x_donation_by_user_id($user_id)
{
    $donations = give_get_users_purchases($user_id, 20, true, 'any');
    $doanttion_per_user[0] = 0;
    if ($donations) {
        foreach ($donations as $post) {
            setup_postdata($post);
            $doanttion_per_user[] = give_get_payment_amount($post->ID);
        }
        wp_reset_postdata();
    }
    return array_sum($doanttion_per_user);
}
Esempio n. 2
0
/**
 * Has Purchases
 *
 * Checks to see if a user has donated to at least one form.
 *
 * @access      public
 * @since       1.0
 *
 * @param       $user_id int - the ID of the user to check
 *
 * @return      bool - true if has purchased, false other wise.
 */
function give_has_purchases($user_id = null)
{
    if (empty($user_id)) {
        $user_id = get_current_user_id();
    }
    if (give_get_users_purchases($user_id, 1)) {
        return true;
        // User has at least one purchase
    }
    return false;
    // User has never purchased anything
}
<?php

/**
 * This template is used to display the donation history of the current user.
 */
$donations = give_get_users_purchases(get_current_user_id(), 20, true, 'any');
if ($donations) {
    ?>
	<table id="give_user_history">
		<thead>
		<tr class="give_purchase_row">
			<?php 
    do_action('give_purchase_history_header_before');
    ?>
			<th class="give_purchase_id"><?php 
    _e('ID', 'give');
    ?>
</th>
			<th class="give_purchase_date"><?php 
    _e('Date', 'give');
    ?>
</th>
			<th class="give_purchase_amount"><?php 
    _e('Amount', 'give');
    ?>
</th>
			<th class="give_purchase_details"><?php 
    _e('Details', 'give');
    ?>
</th>
			<?php 
Esempio n. 4
0
 public function test_users_purchases()
 {
     $out = give_get_users_purchases($this->_user_id);
     $this->assertInternalType('object', $out[0]);
     $this->assertEquals('give_payment', $out[0]->post_type);
     $this->assertTrue(give_has_purchases($this->_user_id));
     $this->assertEquals(1, give_count_purchases_of_customer($this->_user_id));
     $no_user = give_get_users_purchases(0);
     $this->assertFalse($no_user);
 }
Esempio n. 5
0
<?php

/**
 * This template is used to display the donation history of the current user.
 */
//User's Donations
$donations = give_get_users_purchases(get_current_user_id(), 20, true, 'any');
//Email Access Token?
if (Give()->email_access->token_exists) {
    $donations = give_get_users_purchases(0, 20, true, 'any');
}
if ($donations) {
    ?>
	<table id="give_user_history" class="give-table">
		<thead>
		<tr class="give_purchase_row">
			<?php 
    do_action('give_purchase_history_header_before');
    ?>
			<th class="give_purchase_id"><?php 
    _e('ID', 'give');
    ?>
</th>
			<th class="give_purchase_date"><?php 
    _e('Date', 'give');
    ?>
</th>
			<th class="give_purchase_amount"><?php 
    _e('Amount', 'give');
    ?>
</th>