function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'rate':
             $download = get_post_meta($item['ID'], '_download_id', true);
             $type = eddc_get_commission_type($download);
             if ('percentage' == $type) {
                 return $item[$column_name] . '%';
             } else {
                 return edd_currency_filter(edd_sanitize_amount($item[$column_name]));
             }
         case 'status':
             return $item[$column_name];
         case 'amount':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'date':
             return date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $item['ID'])));
         case 'download':
             $download = !empty($item['download']) ? $item['download'] : false;
             return $download ? '<a href="' . esc_url(add_query_arg('download', $download)) . '" title="' . __('View all commissions for this item', 'eddc') . '">' . get_the_title($download) . '</a>' . (!empty($item['variation']) ? ' - ' . $item['variation'] : '') : '';
         case 'payment':
             $payment = get_post_meta($item['ID'], '_edd_commission_payment_id', true);
             return $payment ? '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '" title="' . __('View payment details', 'eddc') . '">#' . $payment . '</a> - ' . edd_get_payment_status(get_post($payment), true) : '';
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
function pw_edd_pdf_invoices_for_pending($show_invoice, $payment_id)
{
    $status = edd_get_payment_status($payment_id);
    if ('pending' === $status) {
        $show_invoice = true;
    }
    return $show_invoice;
}
Пример #3
0
 /**
  * Update the status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  * @param boolean			  $can_redirect (optional, defaults to false)
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $source_id = $payment->get_source_id();
     $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array());
     // Only update if order is not completed
     $should_update = edd_get_payment_status($source_id) !== Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH;
     // Defaults
     $status = null;
     $note = null;
     $url = $data->get_normal_return_url();
     $status = $payment->get_status();
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $url = $data->get_cancel_url();
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             if ($should_update) {
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_ABANDONED);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             if ($should_update) {
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_FAILED);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment completed.', 'pronamic_ideal'));
                 /*
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L36
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L199-L206
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/payments/functions.php#L1312-L1332
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/gateways/paypal-standard.php#L555-L576
                  */
             }
             edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH);
             edd_empty_cart();
             $url = $data->get_success_url();
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment open.', 'pronamic_ideal'));
             }
             break;
         default:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment unknown.', 'pronamic_ideal'));
             }
             break;
     }
     if ($can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
 /**
  * Get the data being exported
  *
  * @return array $data
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $campaign = $this->campaign;
     $campaign = atcf_get_campaign($campaign);
     $backers = $campaign->backers();
     if (empty($backers)) {
         return $data;
     }
     foreach ($backers as $log) {
         $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true);
         $payment = get_post($payment_id);
         $payment_meta = edd_get_payment_meta($payment_id);
         $user_info = edd_get_payment_meta_user_info($payment_id);
         $downloads = edd_get_payment_meta_cart_details($payment_id);
         $total = edd_get_payment_amount($payment_id);
         $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
         $products = '';
         if ($downloads) {
             foreach ($downloads as $key => $download) {
                 // Download ID
                 $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                 // If the download has variable prices, override the default price
                 $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                 $price = edd_get_download_final_price($id, $user_info, $price_override);
                 // Display the Downoad Name
                 $products .= get_the_title($id) . ' - ';
                 if (isset($downloads[$key]['item_number'])) {
                     $price_options = $downloads[$key]['item_number']['options'];
                     if (isset($price_options['price_id'])) {
                         $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - ';
                     }
                 }
                 $products .= html_entity_decode(edd_currency_filter($price));
                 if ($key != count($downloads) - 1) {
                     $products .= ' / ';
                 }
             }
         }
         if (is_numeric($user_id)) {
             $user = get_userdata($user_id);
         } else {
             $user = false;
         }
         $shipping = isset($payment_meta['shipping']) ? $payment_meta['shipping'] : null;
         $data[] = apply_filters('atcf_csv_cols_values', array('id' => $payment_id, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'shipping' => isset($shipping) ? implode("\n", $shipping) : '', 'products' => $products, 'amount' => html_entity_decode(edd_currency_filter(edd_format_amount($total))), 'tax' => html_entity_decode(edd_payment_tax($payment_id, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'atcf'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => date_i18n(get_option('date_format'), strtotime($payment->post_date)), 'user' => $user ? $user->display_name : __('guest', 'atcf'), 'status' => edd_get_payment_status($payment, true)), $payment_id);
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
/**
 * EDD Forum Sidebar
 *
 * @since		1.0.0
 * @return		void
 */
function edd_bbp_sidebar()
{
    global $post;
    $user_id = get_the_author_meta('ID');
    $user_data = get_userdata($user_id);
    ?>
	<div class="box">

		<?php 
    do_action('edd_bbp_sidebar');
    ?>

		<h3><?php 
    echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
    ?>
</h3>
		<p class="bbp-user-forum-role"><?php 
    printf('Forum Role: %s', bbp_get_user_display_role($user_id));
    ?>
</p>
		<p class="bbp-user-topic-count"><?php 
    printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
    ?>
</p>
		<p class="bbp-user-reply-count"><?php 
    printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
    ?>
</p>

		<div class="rcp_support_status">
			<h4>Priority Support Access</h4>
			<?php 
    if (function_exists('rcp_is_active')) {
        if (rcp_is_active($user_id)) {
            ?>
				<p>Has <strong>Priority Support</strong> access.</p>
			<?php 
        } elseif (rcp_is_expired($user_id)) {
            ?>
				<p><strong>Priority Support</strong> access has <span style="color:red;">expired</span>.</p>
			<?php 
        } else {
            ?>
				<p>Has no priority support accesss</p>
			<?php 
        }
    }
    ?>
		</div><!-- /.rcp_support_status -->

		<div class="edd_users_purchases">
			<h4>User's Purchases:</h4>
			<?php 
    $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
    if ($purchases) {
        echo '<ul>';
        foreach ($purchases as $purchase) {
            echo '<li>';
            echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
            $downloads = edd_get_payment_meta_downloads($purchase->ID);
            foreach ($downloads as $download) {
                echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
            }
            if (function_exists('edd_software_licensing')) {
                $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                if ($licenses) {
                    echo '<strong>Licenses:</strong><br/>';
                    foreach ($licenses as $license) {
                        $key = edd_software_licensing()->get_license_key($license->ID);
                        echo '<a href="' . admin_url('edit.php?post_type=download&page=edd-licenses&s=' . $key) . '">' . $key . '</a>';
                        echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                        echo '<br/>';
                    }
                }
                echo '<hr/>';
            }
            echo '</li>';
        }
        echo '</ul>';
    } else {
        echo '<p>This user has never purchased anything.</p>';
    }
    ?>
		</div>
	</div>
	<?php 
}
Пример #6
0
</td>
                                                        					<td class="edd_purchase_amount">
                                                        						<span class="edd_purchase_amount"><?php 
                        echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($post->ID)));
                        ?>
</span>
                                                        					</td>
                                                        					<td class="edd_purchase_details">
                                                        						<?php 
                        if ($post->post_status != 'publish') {
                            ?>
                                                        						<span class="edd_purchase_status <?php 
                            echo $post->post_status;
                            ?>
"><?php 
                            echo edd_get_payment_status($post, true);
                            ?>
</span>
                                                        						<a href="<?php 
                            echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                            ?>
">&raquo;</a>
                                                        						<?php 
                        } else {
                            ?>
                                                        						<a href="<?php 
                            echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                            ?>
"><?php 
                            _e('View Details and Downloads', 'edd');
                            ?>
function edd_userpro_embed_profile_fields($hook_args)
{
    if (!current_user_can('edit_user', $hook_args['user_id'])) {
        return;
    }
    echo '<div class="userpro-section userpro-column userpro-collapsible-1 userpro-collapsed-1">' . __('Purchase History', 'edd-userpro-embed') . '</div>';
    echo '<div class="userpro-field userpro-field-edd-purchase-history userpro-field-view" data-key="edd-purchase-history">';
    $purchases = edd_get_users_purchases($hook_args['user_id'], 99999, true, 'any');
    if ($purchases) {
        do_action('edd_before_purchase_history');
        ?>
		<table id="edd_user_history">
			<thead>
				<tr class="edd_purchase_row">
					<?php 
        do_action('edd_purchase_history_header_before');
        ?>
					<th class="edd_purchase_id"><?php 
        _e('ID', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_date"><?php 
        _e('Date', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_amount"><?php 
        _e('Amount', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_details"><?php 
        _e('Details', 'easy-digital-downloads');
        ?>
</th>
					<?php 
        do_action('edd_purchase_history_header_after');
        ?>
				</tr>
			</thead>
			<?php 
        foreach ($purchases as $post) {
            setup_postdata($post);
            ?>
				<?php 
            $purchase_data = edd_get_payment_meta($post->ID);
            ?>
				<tr class="edd_purchase_row">
					<?php 
            do_action('edd_purchase_history_row_start', $post->ID, $purchase_data);
            ?>
					<td class="edd_purchase_id">#<?php 
            echo edd_get_payment_number($post->ID);
            ?>
</td>
					<td class="edd_purchase_date"><?php 
            echo date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $post->ID)));
            ?>
</td>
					<td class="edd_purchase_amount">
						<span class="edd_purchase_amount"><?php 
            echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($post->ID)));
            ?>
</span>
					</td>
					<td class="edd_purchase_details">
						<?php 
            if ($post->post_status != 'publish') {
                ?>
						<span class="edd_purchase_status <?php 
                echo $post->post_status;
                ?>
"><?php 
                echo edd_get_payment_status($post, true);
                ?>
</span>
						<a href="<?php 
                echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                ?>
">&raquo;</a>
						<?php 
            } else {
                ?>
						<a href="<?php 
                echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                ?>
"><?php 
                _e('View Details', 'edd-userpro-embed');
                ?>
</a>
						<?php 
            }
            ?>
					</td>
					<?php 
            do_action('edd_purchase_history_row_end', $post->ID, $purchase_data);
            ?>
				</tr>
			<?php 
        }
        ?>
		</table>
		<?php 
        do_action('edd_after_purchase_history');
        ?>
		<?php 
        wp_reset_postdata();
        ?>
	<?php 
    } else {
        ?>
		<p class="edd-no-purchases"><?php 
        _e('You have not made any purchases', 'edd-userpro-embed');
        ?>
</p>
	<?php 
    }
    echo '</div>';
}
Пример #8
0
/**
 * View a customer
 *
 * @since  2.3
 * @param  $customer The Customer object being displayed
 * @return void
 */
function edd_customers_view($customer)
{
    $customer_edit_role = apply_filters('edd_edit_customers_role', 'edit_shop_payments');
    ?>

	<?php 
    do_action('edd_customer_card_top', $customer);
    ?>

	<div class="info-wrapper customer-section">

		<form id="edit-customer-info" method="post" action="<?php 
    echo admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . $customer->id);
    ?>
">

			<div class="customer-info">

				<div class="avatar-wrap left" id="customer-avatar">
					<?php 
    echo get_avatar($customer->email);
    ?>
<br />
					<?php 
    if (current_user_can($customer_edit_role)) {
        ?>
						<span class="info-item editable customer-edit-link"><a title="<?php 
        _e('Edit Customer', 'edd');
        ?>
" href="#" id="edit-customer"><?php 
        _e('Edit Customer', 'edd');
        ?>
</a></span>
					<?php 
    }
    ?>
				</div>

				<div class="customer-id right">
					#<?php 
    echo $customer->id;
    ?>
				</div>

				<div class="customer-address-wrapper right">
				<?php 
    if (isset($customer->user_id) && $customer->user_id > 0) {
        ?>

					<?php 
        $address = get_user_meta($customer->user_id, '_edd_user_address', true);
        $defaults = array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'country' => '', 'zip' => '');
        $address = wp_parse_args($address, $defaults);
        ?>

					<?php 
        if (!empty($address)) {
            ?>
					<strong><?php 
            _e('Customer Address', 'edd');
            ?>
</strong>
					<span class="customer-address info-item editable">
						<span class="info-item" data-key="line1"><?php 
            echo $address['line1'];
            ?>
</span>
						<span class="info-item" data-key="line2"><?php 
            echo $address['line2'];
            ?>
</span>
						<span class="info-item" data-key="city"><?php 
            echo $address['city'];
            ?>
</span>
						<span class="info-item" data-key="state"><?php 
            echo $address['state'];
            ?>
</span>
						<span class="info-item" data-key="country"><?php 
            echo $address['country'];
            ?>
</span>
						<span class="info-item" data-key="zip"><?php 
            echo $address['zip'];
            ?>
</span>
					</span>
					<?php 
        }
        ?>
					<span class="customer-address info-item edit-item">
						<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php 
        _e('Address 1', 'edd');
        ?>
" value="<?php 
        echo $address['line1'];
        ?>
" />
						<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php 
        _e('Address 2', 'edd');
        ?>
" value="<?php 
        echo $address['line2'];
        ?>
" />
						<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php 
        _e('City', 'edd');
        ?>
" value="<?php 
        echo $address['city'];
        ?>
" />
						<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country edd-select edit-item">
							<?php 
        $selected_country = $address['country'];
        $countries = edd_get_country_list();
        foreach ($countries as $country_code => $country) {
            echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
        }
        ?>
						</select>
						<?php 
        $selected_state = edd_get_shop_state();
        $states = edd_get_shop_states($selected_country);
        $selected_state = isset($address['state']) ? $address['state'] : $selected_state;
        if (!empty($states)) {
            ?>
						<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state edd-select info-item">
							<?php 
            foreach ($states as $state_code => $state) {
                echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
            }
            ?>
						</select>
						<?php 
        } else {
            ?>
						<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state edd-input info-item" placeholder="<?php 
            _e('State / Province', 'edd');
            ?>
"/>
						<?php 
        }
        ?>
						<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php 
        _e('Postal', 'edd');
        ?>
" value="<?php 
        echo $address['zip'];
        ?>
" />
					</span>
				<?php 
    }
    ?>
				</div>

				<div class="customer-main-wrapper left">

					<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php 
    echo esc_attr($customer->name);
    ?>
" placeholder="<?php 
    _e('Customer Name', 'edd');
    ?>
" /></span>
					<span class="customer-name info-item editable"><span data-key="name"><?php 
    echo $customer->name;
    ?>
</span></span>
					<span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php 
    echo $customer->email;
    ?>
" placeholder="<?php 
    _e('Customer Email', 'edd');
    ?>
" /></span>
					<span class="customer-email info-item editable" data-key="email"><?php 
    echo $customer->email;
    ?>
</span>
					<span class="customer-since info-item">
						<?php 
    _e('Customer since', 'edd');
    ?>
						<?php 
    echo date_i18n(get_option('date_format'), strtotime($customer->date_created));
    ?>
					</span>
					<span class="customer-user-id info-item edit-item">
						<?php 
    $user_id = $customer->user_id > 0 ? $customer->user_id : '';
    $data_atts = array('key' => 'user_login', 'exclude' => $user_id);
    $user_args = array('name' => 'customerinfo[user_login]', 'class' => 'edd-user-dropdown', 'data' => $data_atts);
    if (!empty($user_id)) {
        $userdata = get_userdata($user_id);
        $user_args['value'] = $userdata->user_login;
    }
    echo EDD()->html->ajax_user_search($user_args);
    ?>
						<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php 
    echo $customer->user_id;
    ?>
" />
					</span>

					<span class="customer-user-id info-item editable">
						<?php 
    _e('User ID', 'edd');
    ?>
:&nbsp;
						<?php 
    if (intval($customer->user_id) > 0) {
        ?>
							<span data-key="user_id"><?php 
        echo $customer->user_id;
        ?>
</span>
						<?php 
    } else {
        ?>
							<span data-key="user_id"><?php 
        _e('none', 'edd');
        ?>
</span>
						<?php 
    }
    ?>
						<?php 
    if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) {
        ?>
							<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php 
        _e('Disconnects the current user ID from this customer record', 'edd');
        ?>
"><?php 
        _e('Disconnect User', 'edd');
        ?>
</a></span>
						<?php 
    }
    ?>
					</span>

				</div>

			</div>

			<span id="customer-edit-actions" class="edit-item">
				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php 
    echo $customer->id;
    ?>
" />
				<?php 
    wp_nonce_field('edit-customer', '_wpnonce', false, true);
    ?>
				<input type="hidden" name="edd_action" value="edit-customer" />
				<input type="submit" id="edd-edit-customer-save" class="button-secondary" value="<?php 
    _e('Update Customer', 'edd');
    ?>
" />
				<a id="edd-edit-customer-cancel" href="" class="delete"><?php 
    _e('Cancel', 'edd');
    ?>
</a>
			</span>

		</form>
	</div>

	<?php 
    do_action('edd_customer_before_stats', $customer);
    ?>

	<div id="customer-stats-wrapper" class="customer-section">
		<ul>
			<li>
				<a title="<?php 
    _e('View All Purchases', 'edd');
    ?>
" href="<?php 
    echo admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'%d Completed Sale', '%d Completed Sales', $customer->purchase_count, 'edd'), $customer->purchase_count);
    ?>
				</a>
			</li>
			<li>
				<span class="dashicons dashicons-chart-area"></span>
				<?php 
    echo edd_currency_filter(edd_format_amount($customer->purchase_value));
    ?>
 <?php 
    _e('Lifetime Value', 'edd');
    ?>
			</li>
			<?php 
    do_action('edd_customer_stats_list', $customer);
    ?>
		</ul>
	</div>

	<?php 
    do_action('edd_customer_before_tables_wrapper', $customer);
    ?>

	<div id="customer-tables-wrapper" class="customer-section">

		<?php 
    do_action('edd_customer_before_tables', $customer);
    ?>

		<h3><?php 
    _e('Recent Payments', 'edd');
    ?>
</h3>
		<?php 
    $payment_ids = explode(',', $customer->payment_ids);
    $payments = edd_get_payments(array('post__in' => $payment_ids));
    $payments = array_slice($payments, 0, 10);
    ?>
		<table class="wp-list-table widefat striped payments">
			<thead>
				<tr>
					<th><?php 
    _e('ID', 'edd');
    ?>
</th>
					<th><?php 
    _e('Amount', 'edd');
    ?>
</th>
					<th><?php 
    _e('Date', 'edd');
    ?>
</th>
					<th><?php 
    _e('Status', 'edd');
    ?>
</th>
					<th><?php 
    _e('Actions', 'edd');
    ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
    if (!empty($payments)) {
        ?>
					<?php 
        foreach ($payments as $payment) {
            ?>
						<tr>
							<td><?php 
            echo $payment->ID;
            ?>
</td>
							<td><?php 
            echo edd_payment_amount($payment->ID);
            ?>
</td>
							<td><?php 
            echo date_i18n(get_option('date_format'), strtotime($payment->post_date));
            ?>
</td>
							<td><?php 
            echo edd_get_payment_status($payment, true);
            ?>
</td>
							<td>
								<a title="<?php 
            _e('View Details for Payment', 'edd');
            echo ' ' . $payment->ID;
            ?>
" href="<?php 
            echo admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment->ID);
            ?>
">
									<?php 
            _e('View Details', 'edd');
            ?>
								</a>
								<?php 
            do_action('edd_customer_recent_purcahses_actions', $customer, $payment);
            ?>
							</td>
						</tr>
					<?php 
        }
        ?>
				<?php 
    } else {
        ?>
					<tr><td colspan="5"><?php 
        _e('No Payments Found', 'edd');
        ?>
</td></tr>
				<?php 
    }
    ?>
			</tbody>
		</table>

		<h3><?php 
    printf(__('Purchased %s', 'edd'), edd_get_label_plural());
    ?>
</h3>
		<?php 
    $downloads = edd_get_users_purchased_products($customer->email);
    ?>
		<table class="wp-list-table widefat striped downloads">
			<thead>
				<tr>
					<th><?php 
    echo edd_get_label_singular();
    ?>
</th>
					<th width="120px"><?php 
    _e('Actions', 'edd');
    ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
    if (!empty($downloads)) {
        ?>
					<?php 
        foreach ($downloads as $download) {
            ?>
						<tr>
							<td><?php 
            echo $download->post_title;
            ?>
</td>
							<td>
								<a title="<?php 
            echo esc_attr(sprintf(__('View %s', 'edd'), $download->post_title));
            ?>
" href="<?php 
            echo esc_url(admin_url('post.php?action=edit&post=' . $download->ID));
            ?>
">
									<?php 
            printf(__('View %s', 'edd'), edd_get_label_singular());
            ?>
								</a>
							</td>
						</tr>
					<?php 
        }
        ?>
				<?php 
    } else {
        ?>
					<tr><td colspan="2"><?php 
        printf(__('No %s Found', 'edd'), edd_get_label_plural());
        ?>
</td></tr>
				<?php 
    }
    ?>
			</tbody>
		</table>

		<?php 
    do_action('edd_customer_after_tables', $customer);
    ?>

	</div>

	<?php 
    do_action('edd_customer_card_bottom', $customer);
    ?>

	<?php 
}
/**
 * Payment History Page
 *
 * Renders the payment history page contents.
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_payment_history_page()
{
    global $edd_options;
    if (isset($_GET['edd-action']) && $_GET['edd-action'] == 'edit-payment') {
        include_once EDD_PLUGIN_DIR . '/includes/admin-pages/forms/edit-payment.php';
    } else {
        $current_page = admin_url('edit.php?post_type=download&page=edd-payment-history');
        ?>
		<div class="wrap">
			<?php 
        if (isset($_GET['p'])) {
            $page = $_GET['p'];
        } else {
            $page = 1;
        }
        $per_page = 20;
        if (isset($_GET['show']) && $_GET['show'] > 0) {
            $per_page = intval($_GET['show']);
        }
        $total_pages = 1;
        $offset = $per_page * ($page - 1);
        $mode = isset($_GET['mode']) ? $_GET['mode'] : 'live';
        if (edd_is_test_mode() && !isset($_GET['mode'])) {
            $mode = 'test';
        }
        $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'ID';
        $order = isset($_GET['order']) ? $_GET['order'] : 'DESC';
        $order_inverse = $order == 'DESC' ? 'ASC' : 'DESC';
        $order_class = strtolower($order_inverse);
        $user = isset($_GET['user']) ? $_GET['user'] : null;
        $status = isset($_GET['status']) ? $_GET['status'] : 'any';
        $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
        $payments = edd_get_payments(array('offset' => $offset, 'number' => $per_page, 'mode' => $mode, 'orderby' => $orderby, 'order' => $order, 'user' => $user, 'status' => $status, 'meta_key' => $meta_key));
        $payment_count = wp_count_posts('edd_payment');
        $total_count = $payment_count->publish + $payment_count->pending + $payment_count->refunded + $payment_count->trash;
        switch ($status) {
            case 'publish':
                $current_count = $payment_count->publish;
                break;
            case 'pending':
                $current_count = $payment_count->pending;
                break;
            case 'refunded':
                $current_count = $payment_count->refunded;
                break;
            case 'any':
                $current_count = $total_count;
                break;
        }
        $total_pages = ceil($current_count / $per_page);
        ?>
			<h2><?php 
        _e('Payment History', 'edd');
        ?>
</h2>
			<?php 
        do_action('edd_payments_page_top');
        ?>
			<ul class="subsubsub">
				<li class="all">
					<a href="<?php 
        echo remove_query_arg('status');
        ?>
" <?php 
        echo !isset($_GET['status']) ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('All', 'edd');
        ?>
 
						<span class="count">(<?php 
        echo $total_count;
        ?>
)</span>
					</a> |
				</li>
				<li class="publish">
					<a href="<?php 
        echo add_query_arg('status', 'publish');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'publish' ? 'class="current"' : '';
        ?>
><?php 
        _e('Completed', 'edd');
        ?>
 <span class="count">(<?php 
        echo $payment_count->publish;
        ?>
)</span></a> |
				</li>
				<li class="pending">
					<a href="<?php 
        echo add_query_arg('status', 'pending');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : '';
        ?>
><?php 
        _e('Pending', 'edd');
        ?>
 <span class="count">(<?php 
        echo $payment_count->pending;
        ?>
)</span></a> |
				</li>
				<li class="refunded">
					<a href="<?php 
        echo add_query_arg('status', 'refunded');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'refunded' ? 'class="current"' : '';
        ?>
><?php 
        _e('Refunded', 'edd');
        ?>
 <span class="count">(<?php 
        echo $payment_count->refunded;
        ?>
)</span></a> |
				</li>
				<?php 
        do_action('edd_payments_page_statuses');
        ?>
			</ul>
			<ul class="subsubsub edd-export-payments">
				<li>&nbsp;<?php 
        _e('Export', 'edd');
        ?>
: <a href="<?php 
        echo add_query_arg('export', 'csv');
        ?>
">CSV</a></li>
				<?php 
        do_action('edd_payments_page_export_options');
        ?>
			</ul>	
			<form id="payments-filter" action="<?php 
        echo admin_url('edit.php');
        ?>
" method="get" style="float: right; margin-bottom: 5px;">
				<label for="edd-mode"><?php 
        _e('Payment mode', 'edd');
        ?>
</label>
				<select name="mode" id="edd-mode">
					<option value="live" <?php 
        selected('live', $mode);
        ?>
><?php 
        _e('Live', 'edd');
        ?>
</option>
					<option value="test" <?php 
        selected('test', $mode);
        ?>
><?php 
        _e('Test', 'edd');
        ?>
</option>
				</select>
				<input type="hidden" name="page" value="edd-payment-history"/>
				<input type="hidden" name="post_type" value="download"/>
				<?php 
        if (isset($_GET['user'])) {
            ?>
					<input type="hidden" name="user" value="<?php 
            echo $_GET['user'];
            ?>
"/>
				<?php 
        }
        ?>
				<?php 
        if (isset($_GET['status'])) {
            ?>
					<input type="hidden" name="status" value="<?php 
            echo $_GET['status'];
            ?>
"/>
				<?php 
        }
        ?>
				<label for="edd_show"><?php 
        _e('Payments per page', 'edd');
        ?>
</label>
				<input type="text" class="regular-text" style="width:30px;" id="edd_show" name="show" value="<?php 
        echo isset($_GET['show']) ? $_GET['show'] : '';
        ?>
"/>
				<input type="submit" class="button-secondary" value="<?php 
        _e('Show', 'edd');
        ?>
"/>
			</form>
			<?php 
        if (isset($_GET['user'])) {
            $user = is_numeric($user) ? get_userdata($user) : $user;
            $user = is_object($user) ? $user->display_name : $user;
            ?>
				<p class="clear"><?php 
            echo __('Showing payments for: ', 'edd') . '&nbsp' . $user;
            ?>
&nbsp;-&nbsp;<a href="<?php 
            echo remove_query_arg('user');
            ?>
"><?php 
            _e('clear', 'edd');
            ?>
</a></div>
			<?php 
        }
        ?>
			<table class="wp-list-table widefat fixed posts edd-payments">
				<thead>
					<tr>
						<th style="width: 60px;" class="manage-column column-title sortable <?php 
        echo $order_class;
        echo $orderby == 'ID' ? ' sorted' : '';
        ?>
">
						    <a href="<?php 
        echo add_query_arg(array('orderby' => 'ID', 'order' => $order_inverse));
        ?>
" title="<?php 
        _e('ID', 'edd');
        ?>
"><span><?php 
        _e('ID', 'edd');
        ?>
</span> <span class="sorting-indicator"></span></a>
						</th>
						<th style="width: 250px;"><?php 
        _e('Email', 'edd');
        ?>
</th>
						<th><?php 
        _e('Products', 'edd');
        ?>
</th>
						<th>
							<a href="<?php 
        echo add_query_arg(array('meta_key' => '_edd_payment_total', 'order' => $order_inverse, 'orderby' => 'meta_value_num'));
        ?>
" title="<?php 
        _e('Price', 'edd');
        ?>
"><span><?php 
        _e('Price', 'edd');
        ?>
</span> <span class="sorting-indicator"></span></a>
						</th>
						<th class="manage-column column-title sortable <?php 
        echo $order_class;
        echo $orderby == 'Date' ? ' sorted' : '';
        ?>
">
						    <a href="<?php 
        echo add_query_arg(array('orderby' => 'post_date', 'order' => $order_inverse));
        ?>
" title="<?php 
        _e('Date', 'edd');
        ?>
"><span><?php 
        _e('Date', 'edd');
        ?>
</span> <span class="sorting-indicator"></span></a>
						</th>
						<th><?php 
        _e('User', 'edd');
        ?>
</span></th>
						<th class="manage-column column-title sortable <?php 
        echo $order_class;
        echo $orderby == 'Status' ? ' sorted' : '';
        ?>
">
						    <a href="<?php 
        echo add_query_arg(array('orderby' => 'post_status', 'order' => $order_inverse));
        ?>
" title="<?php 
        _e('Status', 'edd');
        ?>
"><span><?php 
        _e('Status', 'edd');
        ?>
</span> <span class="sorting-indicator"></span></a>
						</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th style="width: 40px;"><?php 
        _e('ID', 'edd');
        ?>
</th>
						<th style="width: 250px;"><?php 
        _e('Email', 'edd');
        ?>
</th>
						<th><?php 
        _e('Products', 'edd');
        ?>
</th>
						<th><?php 
        _e('Price', 'edd');
        ?>
</th>
						<th><?php 
        _e('Date', 'edd');
        ?>
</th>
						<th><?php 
        _e('User', 'edd');
        ?>
</th>
						<th><?php 
        _e('Status', 'edd');
        ?>
</th>
					</tr>
				</tfoot>
				<tbody>
					<?php 
        if ($payments) {
            $i = 0;
            foreach ($payments as $payment) {
                ?>
							
								<?php 
                $payment_meta = get_post_meta($payment->ID, '_edd_payment_meta', true);
                $user_info = maybe_unserialize($payment_meta['user_info']);
                $classes = array();
                $classes[] = edd_is_odd($i) ? 'alternate' : '';
                $payment_classes = get_post_class(apply_filters('edd_payment_row_classes', $classes), $payment->ID);
                ?>
								<tr class="edd_payment <?php 
                echo implode(' ', $payment_classes);
                ?>
">
									<td>
										<?php 
                echo $payment->ID;
                ?>
									</td>
									<td>
										<?php 
                echo $payment_meta['email'];
                ?>
										<div class="row-actions">
											<?php 
                $row_actions = array('edit' => '<a href="' . add_query_arg(array('edd-action' => 'edit-payment', 'purchase_id' => $payment->ID)) . '">' . __('Edit', 'edd') . '</a>', 'email_links' => edd_is_payment_complete($payment->ID) ? '<a href="' . add_query_arg(array('edd-action' => 'email_links', 'purchase_id' => $payment->ID)) . '">' . __('Resend Purchase Receipt', 'edd') . '</a>' : NULL, 'delete' => '<a href="' . wp_nonce_url(add_query_arg(array('edd-action' => 'delete_payment', 'purchase_id' => $payment->ID)), 'edd_payment_nonce') . '">' . __('Delete', 'edd') . '</a>');
                $row_actions = apply_filters('edd_payment_row_actions', $row_actions, $payment);
                $action_count = count($row_actions);
                $i = 1;
                foreach ($row_actions as $key => $action) {
                    if ($action_count == $i) {
                        $sep = '';
                    } else {
                        $sep = ' | ';
                    }
                    echo !is_null($action) ? '<span class="' . $key . '">' . $action . '</span>' . $sep : '';
                    $i++;
                }
                ?>
										</div>
									</td>
									<td><a href="#TB_inline?width=640&amp;inlineId=purchased-files-<?php 
                echo $payment->ID;
                ?>
" class="thickbox" title="<?php 
                printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID);
                ?>
 "><?php 
                _e('View Order Details', 'edd');
                ?>
</a>
										<div id="purchased-files-<?php 
                echo $payment->ID;
                ?>
" style="display:none;">
											<?php 
                $downloads = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
                if (empty($downloads) || !$downloads) {
                    $downloads = maybe_unserialize($payment_meta['downloads']);
                }
                ?>
											<h4><?php 
                echo _n(__('Purchased File', 'edd'), __('Purchased Files', 'edd'), count($downloads));
                ?>
</h4>
											<ul class="purchased-files-list">
											<?php 
                if ($downloads) {
                    foreach ($downloads as $key => $download) {
                        echo '<li>';
                        // retrieve the ID of the download
                        $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                        // if download has variable prices, override the default price
                        $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                        $user_info = unserialize($payment_meta['user_info']);
                        // calculate the final price
                        $price = edd_get_download_final_price($id, $user_info, $price_override);
                        // show name of download
                        echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '" target="_blank">' . get_the_title($id) . '</a>';
                        echo ' - ';
                        if (isset($downloads[$key]['item_number'])) {
                            $price_options = $downloads[$key]['item_number']['options'];
                            if (isset($price_options['price_id'])) {
                                echo edd_get_price_option_name($id, $price_options['price_id']);
                                echo ' - ';
                            }
                        }
                        // show price
                        echo edd_currency_filter($price);
                        echo '</li>';
                    }
                }
                ?>
											</ul>
											<p><?php 
                echo __('Discount used:', 'edd') . ' ';
                if (isset($user_info['discount']) && $user_info['discount'] != 'none') {
                    echo $user_info['discount'];
                } else {
                    _e('none', 'edd');
                }
                ?>
											<p><?php 
                echo __('Total:', 'edd') . ' ' . edd_currency_filter($payment_meta['amount']);
                ?>
</p>
											
											<div class="purcase-personal-details">
												<h4><?php 
                _e('Buyer\'s Personal Details:', 'edd');
                ?>
</h4>
												<ul>
													<li><?php 
                echo __('Name:', 'edd') . ' ' . $user_info['first_name'] . ' ' . $user_info['last_name'];
                ?>
</li>
													<li><?php 
                echo __('Email:', 'edd') . ' ' . $payment_meta['email'];
                ?>
</li>
													<?php 
                do_action('edd_payment_personal_details_list', $payment_meta, $user_info);
                ?>
												</ul>
											</div>
											
											<?php 
                $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true);
                if ($gateway) {
                    ?>
											<div class="payment-method">
												<h4><?php 
                    _e('Payment Method:', 'edd');
                    ?>
</h4>
												<span class="payment-method-name"><?php 
                    echo edd_get_gateway_admin_label($gateway);
                    ?>
</span>
											</div>
											<?php 
                }
                ?>
											<div class="purchase-key-wrap">
												<h4><?php 
                _e('Purchase Key', 'edd');
                ?>
</h4>
												<span class="purchase-key"><?php 
                echo $payment_meta['key'];
                ?>
</span>
											</div>
											<p><a id="edd-close-purchase-details" class="button-secondary" onclick="tb_remove();" title="<?php 
                _e('Close', 'edd');
                ?>
"><?php 
                _e('Close', 'edd');
                ?>
</a></p>
										</div>
									</td>
									<td style="text-transform:uppercase;"><?php 
                echo edd_currency_filter($payment_meta['amount']);
                ?>
</td>
									<td><?php 
                echo date(apply_filters('edd_payments_page_date_format', get_option('date_format')), strtotime($payment->post_date));
                ?>
</td>
									<td>
										<?php 
                $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
                ?>
										<a href="<?php 
                echo remove_query_arg('p', add_query_arg('user', $user_id));
                ?>
">
											<?php 
                if (is_numeric($user_id)) {
                    $user = get_user_by('id', $user_id);
                    echo is_object($user) ? $user->display_name : __('guest', 'edd');
                } else {
                    echo __('guest', 'edd');
                }
                ?>
										</a>
									</td>
									<td><?php 
                echo edd_get_payment_status($payment, true);
                ?>
</td>
								</tr>
							<?php 
                $i++;
            }
        } else {
            ?>
						<tr><td colspan="7"><?php 
            _e('No payments recorded yet', 'edd');
            ?>
</td></tr>
					<?php 
        }
        ?>
				</table>
				<div class="tablenav">

					<div class="left edd-total-earnings">
						<p><?php 
        _e('Total Earnings:', 'edd');
        ?>
&nbsp;<strong><?php 
        echo edd_get_total_earnings();
        ?>
</strong></p>
						<?php 
        do_action('edd_payments_page_earnings');
        ?>
					</div>
					<?php 
        if ($total_pages > 1) {
            ?>
						<div class="tablenav-pages alignright">
							<?php 
            $query_string = $_SERVER['QUERY_STRING'];
            $base = 'edit.php?' . remove_query_arg('p', $query_string) . '%_%';
            echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => '&laquo; ' . __('Previous', 'edd'), 'next_text' => __('Next', 'edd') . ' &raquo;', 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5));
            ?>
	
						</div>
					<?php 
        }
        ?>
				</div><!--end .tablenav-->
				<?php 
        do_action('edd_payments_page_bottom');
        ?>
		</div><!--end wrap-->
		<?php 
    }
}
Пример #10
0
 /**
  * Get all the attendees for an event. It returns an array with the
  * following fields:
  *  'order_id'
  *  'order_status'
  *  'purchaser_name'
  *  'purchaser_email'
  *  'ticket'
  *  'attendee_id'
  *  'security'
  *  'product_id'
  *  'check_in'
  *  'provider'
  *
  * @param $event_id
  *
  * @return array
  */
 protected function get_attendees($event_id)
 {
     $args = array('posts_per_page' => -1, 'post_type' => self::ATTENDEE_OBJECT, 'meta_key' => self::ATTENDEE_EVENT_KEY, 'meta_value' => $event_id, 'orderby' => 'ID', 'order' => 'DESC');
     $attendees_query = new WP_Query($args);
     if (!$attendees_query->have_posts()) {
         return array();
     }
     $attendees = array();
     foreach ($attendees_query->posts as $attendee) {
         $order_id = get_post_meta($attendee->ID, self::ATTENDEE_ORDER_KEY, true);
         $checkin = get_post_meta($attendee->ID, self::$checkin_key, true);
         $security = get_post_meta($attendee->ID, self::$security_code, true);
         $product_id = get_post_meta($attendee->ID, self::ATTENDEE_PRODUCT_KEY, true);
         $user_info = edd_get_payment_meta_user_info($order_id);
         $name = $user_info['first_name'] . ' ' . $user_info['last_name'];
         $email = $user_info['email'];
         $order_status = get_post_field('post_status', $order_id);
         $status_label = edd_get_payment_status(get_post($order_id), true);
         $order_warning = 'publish' !== $order_status;
         if (empty($product_id)) {
             continue;
         }
         $product = get_post($product_id);
         $product_title = !empty($product) ? $product->post_title : get_post_meta($attendee->ID, $this->deleted_product, true) . ' ' . __('(deleted)', 'eddtickets');
         $attendees[] = array('order_id' => $order_id, 'order_status' => $status_label, 'order_warning' => $order_warning, 'purchaser_name' => $name, 'purchaser_email' => $email, 'ticket' => $product_title, 'attendee_id' => $attendee->ID, 'security' => $security, 'product_id' => $product_id, 'check_in' => $checkin, 'provider' => __CLASS__);
     }
     return $attendees;
 }
 /**
  * Render most columns
  *
  * @access      private
  * @since       1.3.4
  * @return      string
  */
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'amount':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'date':
             $date = strtotime($item[$column_name]);
             return date_i18n(get_option('date_format'), $date);
         case 'status':
             $payment = get_post($item['ID']);
             return edd_get_payment_status($payment, true);
         default:
             return $item[$column_name];
     }
 }
/**
 * Undos a purchase, including the decrease of sale and earning stats
 *
 * Used for when refunding or deleting a purchase
 *
 * @access      public
 * @since       1.0.8.1
 * @param       int $download_id - the ID number of the download
 * @param       int $payment_id - the ID number of the purchase
 * @return      
*/
function edd_undo_purchase($download_id, $payment_id)
{
    $payment = get_post($payment_id);
    if (edd_get_payment_status($payment) == 'refunded') {
        return;
    }
    // payment has already been reversed
    edd_decrease_purchase_count($download_id);
    $purchase_meta = edd_get_payment_meta($payment_id);
    $user_purchase_info = maybe_unserialize($purchase_meta['user_info']);
    $cart_details = maybe_unserialize($purchase_meta['cart_details']);
    $amount = null;
    if (is_array($cart_details)) {
        $cart_item_id = array_search($download_id, $cart_details);
        $amount = isset($cart_details[$cart_item_id]['price']) ? $cart_details[$cart_item_id]['price'] : null;
    }
    $amount = edd_get_download_final_price($download_id, $user_purchase_info, $amount);
    edd_decrease_earnings($download_id, $amount);
}
/**
 * Export all Payment History to CSV
 *
 * @access      private
 * @since       1.2
 * @return      void
 */
function edd_export_payment_history()
{
    global $edd_options;
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $mode = edd_is_test_mode() ? 'test' : 'live';
    header('Content-Type: text/csv; charset=utf-8');
    header('Content-Disposition: attachment; filename=edd-payment-history-' . date('m-d-Y') . '.csv');
    header("Pragma: no-cache");
    header("Expires: 0");
    $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode));
    if ($payments) {
        $i = 0;
        echo '"' . __('ID', 'edd') . '",';
        echo '"' . __('Email', 'edd') . '",';
        echo '"' . __('First Name', 'edd') . '",';
        echo '"' . __('Last Name', 'edd') . '",';
        echo '"' . __('Products', 'edd') . '",';
        echo '"' . __('Discounts,', 'edd') . '",';
        echo '"' . __('Amount paid', 'edd') . '",';
        if (edd_use_taxes()) {
            echo '"' . __('Amount taxed', 'edd') . '",';
        }
        echo '"' . __('Payment method', 'edd') . '",';
        echo '"' . __('Key', 'edd') . '",';
        echo '"' . __('Date', 'edd') . '",';
        echo '"' . __('User', 'edd') . '",';
        echo '"' . __('Status', 'edd') . '"';
        echo "\r\n";
        foreach ($payments as $payment) {
            $payment_meta = edd_get_payment_meta($payment->ID);
            $user_info = edd_get_payment_meta_user_info($payment->ID);
            echo '"' . $payment->ID . '",';
            echo '"' . $payment_meta['email'] . '",';
            echo '"' . $user_info['first_name'] . '",';
            echo '"' . $user_info['last_name'] . '",';
            $downloads = edd_get_payment_meta_cart_details($payment->ID);
            if (empty($downloads) || !$downloads) {
                $downloads = maybe_unserialize($payment_meta['downloads']);
            }
            if ($downloads) {
                foreach ($downloads as $key => $download) {
                    // Download ID
                    $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                    // If the download has variable prices, override the default price
                    $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                    $user_info = unserialize($payment_meta['user_info']);
                    $price = edd_get_download_final_price($id, $user_info, $price_override);
                    // Display the Downoad Name
                    echo '"' . get_the_title($id);
                    echo ' - ';
                    if (isset($downloads[$key]['item_number'])) {
                        $price_options = $downloads[$key]['item_number']['options'];
                        if (isset($price_options['price_id'])) {
                            echo edd_get_price_option_name($id, $price_options['price_id']);
                            echo ' - ';
                        }
                    }
                    echo html_entity_decode(edd_currency_filter($price));
                    if ($key != count($downloads) - 1) {
                        echo ' / ';
                    }
                }
                echo '",';
            }
            if (isset($user_info['discount']) && $user_info['discount'] != 'none') {
                echo '"' . $user_info['discount'] . '",';
            } else {
                echo '"' . __('none', 'edd') . '",';
            }
            echo '"' . html_entity_decode(edd_currency_filter(edd_format_amount($payment_meta['amount']))) . '",';
            if (edd_use_taxes()) {
                echo '"' . html_entity_decode(edd_payment_tax($payment->ID, $payment_meta)) . '",';
            }
            $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true);
            if ($gateway) {
                echo '"' . edd_get_gateway_admin_label($gateway) . '",';
            } else {
                echo '"' . __('none', 'edd') . '",';
            }
            echo '"' . $payment_meta['key'] . '",';
            echo '"' . date_i18n(get_option('date_format'), strtotime($payment->post_date)) . '",';
            $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
            echo '"' . is_numeric($user_id) ? get_user_by('id', $user_id)->display_name : __('guest', 'edd') . '",';
            echo '"' . edd_get_payment_status($payment, true) . '"';
            echo "\r\n";
            $i++;
        }
    } else {
        echo __('No payments recorded yet', 'edd');
    }
    die;
}
Пример #14
0
 /**
  * Output customer purchase history.
  *
  * @since 1.5.0
  *
  * @param object $order Order post object.
  */
 public function render_purchase_history($payment_id = 0)
 {
     // If no order object is available, bail here
     if (empty($payment_id)) {
         return false;
     }
     // Get relevant payment details
     $payment_meta = edd_get_payment_meta($payment_id);
     // Setup important variables
     $lifetime_total = 0;
     $payments = get_posts(array('numberposts' => -1, 'meta_key' => '_edd_payment_user_email', 'meta_value' => $payment_meta['email'], 'post_type' => 'edd_payment', 'order' => 'ASC', 'post_status' => 'any'));
     // Initialize output
     $output = '';
     $output .= '<div class="products-header spacing-wrapper clearfix"></div>';
     $output .= '<div class="spacing-wrapper clearfix">';
     // Include a header
     $output .= sprintf('<p>%s</p>', __('Below is every order this customer has completed, including this one (highlighted).', 'edduh'));
     // Output purhcase history table
     $output .= '<table style="width:100%; border:1px solid #eee;" cellpadding="0" cellspacing="0" border="0">';
     $output .= '<tr>';
     $output .= '<th style="background:#333; color:#fff; text-align:left; padding:10px;">' . __('Order Number', 'edduh') . '</th>';
     $output .= '<th style="background:#333; color:#fff; text-align:left; padding:10px;">' . __('Order Date', 'edduh') . '</th>';
     $output .= '<th style="background:#333; color:#fff; text-align:left; padding:10px;">' . __('Order Status', 'edduh') . '</th>';
     $output .= '<th style="background:#333; color:#fff; text-align: right; padding:10px;">' . __('Order Total', 'edduh') . '</th>';
     $output .= '</tr>';
     if (!empty($payments)) {
         foreach ($payments as $key => $payment) {
             $payment = get_post($payment->ID);
             $alt = $key % 2 ? ' style="background: #f7f7f7;"' : '';
             $current = $payment->ID == $payment_id ? ' style="background: #ffc; font-weight: bold"' : $alt;
             $output .= '<tr' . $current . '>';
             $output .= '<td style="text-align:left; padding:10px;">' . ($key + 1) . '. <a href="' . admin_url("edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id={$payment->ID}") . '">' . sprintf(__('Order #%d', 'edduh'), $payment->ID) . '</a></td>';
             $output .= '<td style="text-align:left; padding:10px;">' . date('Y-m-d h:ia', strtotime($payment->post_date)) . '</td>';
             $output .= '<td style="text-align:left; padding:10px;">' . edd_get_payment_status($payment, true) . '</td>';
             $output .= '<td style="text-align:right; padding:10px;">' . edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment->ID))) . '</td>';
             $output .= '</tr>';
             if ('publish' == $payment->post_status) {
                 $lifetime_total += edd_get_payment_amount($payment->ID);
             }
         }
     }
     $output .= '</table>';
     // Output total lifetime value
     $output .= '<p>';
     $output .= sprintf(__('<strong>Actual Lifetime Customer Value:</strong> %s', 'edduh'), '<span style="color:#7EB03B; font-size: 1.2em;">' . edd_currency_filter(edd_format_amount($lifetime_total)) . '</span>');
     $output .= '</p>';
     // Close out the container
     $output .= '</div>';
     return $output;
 }
                                ?>
												</a>
											</div>

											<?php 
                                do_action('edd_download_history_files', $filekey, $file, $id, $payment->ID, $purchase_data);
                            }
                        } else {
                            _e('No downloadable files found.', 'edd');
                        }
                        // End if payment complete
                    } else {
                        ?>
									<span class="edd_download_payment_status">
										<?php 
                        printf(__('Payment status is %s', 'edd'), edd_get_payment_status($payment, true));
                        ?>
									</span>
									<?php 
                    }
                    // End if $download_files
                    ?>
							</td>
						<?php 
                }
                // End if ! edd_no_redownload()
                do_action('edd_download_history_row_end', $payment->ID, $download['id']);
                ?>
					</tr>
					<?php 
            }
/**
 * Forum Sidebar
 *
 * @since        1.0.0
 * @return        void
 */
function wi_bbp_sidebar()
{
    global $post;
    $user_id = get_the_author_meta('ID');
    $user_data = get_userdata($user_id);
    ?>
	<div class="box">

		<?php 
    do_action('wi_bbp_sidebar');
    ?>

		<h3><?php 
    echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
    ?>
</h3>

		<p class="bbp-user-forum-role"><?php 
    printf('Forum Role: %s', bbp_get_user_display_role($user_id));
    ?>
</p>

		<p class="bbp-user-topic-count"><?php 
    printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
    ?>
</p>

		<p class="bbp-user-reply-count"><?php 
    printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
    ?>
</p>


		<div class="wi_users_purchases">
			<h3><?php 
    _e('User\'s Purchases:', 'wi_bbp');
    ?>
</h3>
			<?php 
    $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
    if ($purchases) {
        echo '<ul>';
        foreach ($purchases as $purchase) {
            echo '<li>';
            echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
            $downloads = edd_get_payment_meta_downloads($purchase->ID);
            foreach ($downloads as $download) {
                echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
            }
            //Check license key
            if (function_exists('edd_software_licensing')) {
                $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                if ($licenses) {
                    echo '<strong>Licenses:</strong><br/>';
                    foreach ($licenses as $license) {
                        $key = edd_software_licensing()->get_license_key($license->ID);
                        echo '<a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>';
                        echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                        echo '<br/>';
                    }
                }
                echo '<hr/>';
            }
            echo '</li>';
        }
        echo '</ul>';
    } else {
        echo '<p>This user has never purchased anything.</p>';
    }
    ?>
		</div>
	</div>
	<?php 
}
 /**
  * Get the Export Data
  *
  * @access public
  * @since 1.4.4
  * @global object $wpdb Used to query the database using the WordPress
  *   Database API
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     global $wpdb, $edd_options;
     $data = array();
     $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => edd_is_test_mode() ? 'test' : 'live', 'status' => isset($_POST['edd_export_payment_status']) ? $_POST['edd_export_payment_status'] : 'any', 'month' => isset($_POST['month']) ? absint($_POST['month']) : date('n'), 'year' => isset($_POST['year']) ? absint($_POST['year']) : date('Y')));
     foreach ($payments as $payment) {
         // skip over payments that don't have upsells in them
         if (!get_post_meta($payment->ID, '_edd_payment_upsell_total', true)) {
             continue;
         }
         $payment_meta = edd_get_payment_meta($payment->ID);
         $user_info = edd_get_payment_meta_user_info($payment->ID);
         $downloads = edd_get_payment_meta_cart_details($payment->ID);
         $total = edd_csau_get_payment_amount($payment->ID, 'upsell');
         $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
         $products = '';
         $skus = '';
         if ($downloads) {
             foreach ($downloads as $key => $download) {
                 // skip over downloads which aren't upsells
                 if (!isset($download['item_number']['upsell'])) {
                     continue;
                 }
                 // Download ID
                 $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                 // If the download has variable prices, override the default price
                 $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                 $price = edd_get_download_final_price($id, $user_info, $price_override);
                 // Display the Downoad Name
                 $products .= get_the_title($id) . ' - ';
                 if (edd_use_skus()) {
                     $sku = edd_get_download_sku($id);
                     if (!empty($sku)) {
                         $skus .= $sku;
                     }
                 }
                 if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) {
                     $price_options = $downloads[$key]['item_number']['options'];
                     if (isset($price_options['price_id'])) {
                         $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - ';
                     }
                 }
                 $products .= html_entity_decode(edd_currency_filter($price));
                 if ($key != count($downloads) - 1) {
                     $products .= ' / ';
                     if (edd_use_skus()) {
                         $skus .= ' / ';
                     }
                 }
             }
         }
         if (is_numeric($user_id)) {
             $user = get_userdata($user_id);
         } else {
             $user = false;
         }
         $data[] = array('id' => $payment->ID, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'products' => $products, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(edd_get_payment_tax($payment->ID, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'edd'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment->ID, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'edd'), 'status' => edd_get_payment_status($payment, true));
         if (!edd_use_skus()) {
             unset($data['skus']);
         }
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
 /**
  * Update the status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $source_id = $payment->get_source_id();
     $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array());
     // Only update if order is not completed
     $should_update = edd_get_payment_status($source_id) !== Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH;
     if ($should_update) {
         switch ($payment->get_status()) {
             case Pronamic_WP_Pay_Statuses::CANCELLED:
                 // Nothing to do?
                 break;
             case Pronamic_WP_Pay_Statuses::EXPIRED:
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_ABANDONED);
                 break;
             case Pronamic_WP_Pay_Statuses::FAILURE:
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_FAILED);
                 break;
             case Pronamic_WP_Pay_Statuses::SUCCESS:
                 edd_insert_payment_note($source_id, __('Payment completed.', 'pronamic_ideal'));
                 /*
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L36
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L199-L206
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/payments/functions.php#L1312-L1332
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/gateways/paypal-standard.php#L555-L576
                  */
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH);
                 edd_empty_cart();
                 break;
             case Pronamic_WP_Pay_Statuses::OPEN:
                 edd_insert_payment_note($source_id, __('Payment open.', 'pronamic_ideal'));
                 break;
             default:
                 edd_insert_payment_note($source_id, __('Payment unknown.', 'pronamic_ideal'));
                 break;
         }
     }
 }
 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.4
  * @global object $wpdb Used to query the database using the WordPress
  *   Database API
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $args = array('number' => 30, 'page' => $this->step, 'status' => $this->status);
     if (!empty($this->start) || !empty($this->end)) {
         $args['date_query'] = array(array('after' => date('Y-n-d H:i:s', strtotime($this->start)), 'before' => date('Y-n-d H:i:s', strtotime($this->end)), 'inclusive' => true));
     }
     //echo json_encode($args ); exit;
     $payments = edd_get_payments($args);
     if ($payments) {
         foreach ($payments as $payment) {
             $payment_meta = edd_get_payment_meta($payment->ID);
             $user_info = edd_get_payment_meta_user_info($payment->ID);
             $downloads = edd_get_payment_meta_cart_details($payment->ID);
             $total = edd_get_payment_amount($payment->ID);
             $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
             $products = '';
             $skus = '';
             if ($downloads) {
                 foreach ($downloads as $key => $download) {
                     // Download ID
                     $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                     // If the download has variable prices, override the default price
                     $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                     $price = edd_get_download_final_price($id, $user_info, $price_override);
                     // Display the Downoad Name
                     $products .= get_the_title($id) . ' - ';
                     if (edd_use_skus()) {
                         $sku = edd_get_download_sku($id);
                         if (!empty($sku)) {
                             $skus .= $sku;
                         }
                     }
                     if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) {
                         $price_options = $downloads[$key]['item_number']['options'];
                         if (isset($price_options['price_id'])) {
                             $products .= edd_get_price_option_name($id, $price_options['price_id'], $payment->ID) . ' - ';
                         }
                     }
                     $products .= html_entity_decode(edd_currency_filter($price));
                     if ($key != count($downloads) - 1) {
                         $products .= ' / ';
                         if (edd_use_skus()) {
                             $skus .= ' / ';
                         }
                     }
                 }
             }
             if (is_numeric($user_id)) {
                 $user = get_userdata($user_id);
             } else {
                 $user = false;
             }
             $data[] = array('id' => $payment->ID, 'seq_id' => edd_get_payment_number($payment->ID), 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'products' => $products, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(edd_format_amount(edd_get_payment_tax($payment->ID, $payment_meta))), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'edd'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment->ID, '_edd_payment_gateway', true)), 'trans_id' => edd_get_payment_transaction_id($payment->ID), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'edd'), 'status' => edd_get_payment_status($payment, true));
         }
         $data = apply_filters('edd_export_get_data', $data);
         $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
Пример #20
0
/**
 * Mark payments as Failed when returning to the Failed Transaction page
 *
 * @access      public
 * @since       1.9.9
 * @return      void
*/
function edd_listen_for_failed_payments()
{
    $failed_page = edd_get_option('failure_page', 0);
    if (!empty($failed_page) && is_page($failed_page) && !empty($_GET['payment-id'])) {
        $payment_id = absint($_GET['payment-id']);
        $payment = get_post($payment_id);
        $status = edd_get_payment_status($payment);
        if ($status && 'pending' === strtolower($status)) {
            edd_update_payment_status($payment_id, 'failed');
        }
    }
}
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        //No EDD? Bail
        if (!class_exists('Easy_Digital_Downloads')) {
            return false;
        }
        //Not EDD admin? Bail
        if (!current_user_can('view_shop_sensitive_data')) {
            return false;
        }
        //Handle before_widget args
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
        }
        $user_id = get_the_author_meta('ID');
        $user_data = get_userdata($user_id);
        ?>
		<div class="box">

			<?php 
        do_action('wi_bbp_sidebar');
        ?>

			<h3><?php 
        echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
        ?>
</h3>

			<p class="bbp-user-forum-role"><?php 
        printf('Forum Role: %s', bbp_get_user_display_role($user_id));
        ?>
</p>

			<p class="bbp-user-topic-count"><?php 
        printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
        ?>
</p>

			<p class="bbp-user-reply-count"><?php 
        printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
        ?>
</p>


			<div class="wi_users_purchases">
				<h3><?php 
        _e('User\'s Purchases:', 'wi_bbp');
        ?>
</h3>
				<?php 
        $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
        if ($purchases) {
            echo '<ul>';
            foreach ($purchases as $purchase) {
                echo '<li>';
                echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
                $downloads = edd_get_payment_meta_downloads($purchase->ID);
                foreach ($downloads as $download) {
                    echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
                }
                //Check license key
                if (function_exists('edd_software_licensing')) {
                    $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                    if ($licenses) {
                        echo '<strong>' . __('Licenses:', 'edd') . '</strong><br/>';
                        foreach ($licenses as $license) {
                            $key = edd_software_licensing()->get_license_key($license->ID);
                            $download_id = edd_software_licensing()->get_download_by_license($key);
                            $title = get_the_title($download_id);
                            //output license URL
                            echo $title . ' - <a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>';
                            echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                            echo '<br/>';
                        }
                    }
                    echo '<hr/>';
                }
                echo '</li>';
            }
            echo '</ul>';
        } else {
            echo '<p>' . __('This user has never purchased anything.', 'wi_bbp') . '</p>';
        }
        ?>
			</div>
		</div>
		<?php 
        //After widget args
        echo $args['after_widget'];
        return false;
    }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.4
  *
  * @param array $payment Contains all the data of the payment
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($payment, $column_name)
 {
     switch ($column_name) {
         case 'amount':
             $amount = $payment->total;
             $amount = !empty($amount) ? $amount : 0;
             $value = edd_currency_filter(edd_format_amount($amount), edd_get_payment_currency_code($payment->ID));
             break;
         case 'date':
             $date = strtotime($payment->date);
             $value = date_i18n(get_option('date_format'), $date);
             break;
         case 'status':
             $payment = get_post($payment->ID);
             $value = edd_get_payment_status($payment, true);
             break;
         case 'details':
             $value = '<a href="' . add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')) . '">' . __('View Order Details', 'easy-digital-downloads') . '</a>';
             break;
         default:
             $value = isset($payment->{$column_name}) ? $payment->{$column_name} : '';
             break;
     }
     return apply_filters('edd_payments_table_column', $value, $payment->ID, $column_name);
 }
Пример #23
0
/**
 * View the wallet of a customer
 *
 * @since       1.0.0
 * @param       object $customer The customer being displayed
 * @return      void
 */
function edd_customer_wallet_view($customer)
{
    settings_errors('edd-notices');
    ?>
	<div id="wallet-header-wrapper" class="customer-section">
		<?php 
    echo get_avatar($customer->email, 30);
    ?>
 <span><?php 
    echo sprintf(__('%s - Wallet', 'edd-wallet'), $customer->name);
    ?>
</span>
	</div>

	<?php 
    if ($customer->user_id < 1) {
        ?>
		<div class="error"><p><?php 
        _e('This customer must be attached to a user account in order to edit their wallet', 'edd-wallet');
        ?>
</p></div>
	<?php 
    }
    ?>

	<?php 
    do_action('edd_customer_wallet_before_stats', $customer);
    ?>

	<?php 
    if ($customer->user_id >= 1) {
        ?>

		<?php 
        $value = edd_wallet()->wallet->balance($customer->user_id);
        ?>

		<div id="wallet-stats-wrapper" class="customer-section">
			<ul>
				<li>
					<span class="dashicons dashicons-money"></span>&nbsp;<?php 
        echo sprintf(__('%s Available', 'edd-wallet'), edd_currency_filter(edd_format_amount($value)));
        ?>
				</li>
			</ul>
		</div>

		<?php 
        do_action('edd_customer_wallet_before_tables_wrapper', $customer);
        ?>

		<div id="wallet-tables-wrapper" class="customer-section">

			<?php 
        do_action('edd_customer_wallet_before_tables', $customer);
        ?>

			<h3><?php 
        _e('Recent Activity', 'edd-wallet');
        ?>
</h3>

			<?php 
        $activity = edd_wallet_get_activity($customer->user_id);
        ?>

			<table class="wp-list-table widefat striped activity">
				<thead>
					<tr>
						<th><?php 
        _e('ID', 'edd-wallet');
        ?>
</th>
						<th><?php 
        _e('Type', 'edd-wallet');
        ?>
</th>
						<th><?php 
        _e('Amount', 'edd-wallet');
        ?>
</th>
						<th><?php 
        _e('Date', 'edd-wallet');
        ?>
</th>
						<th><?php 
        _e('Status', 'edd-wallet');
        ?>
</th>
						<th><?php 
        _e('Actions', 'edd-wallet');
        ?>
</th>
					</tr>
				</thead>
				<tbody>

				<?php 
        if ($activity) {
            foreach ($activity as $item) {
                // Setup item type
                switch ($item->type) {
                    case 'deposit':
                        $type = __('Deposit', 'edd-wallet');
                        $item_id = $item->id . ' (' . $item->payment_id . ')';
                        $actions = '<a title="' . __('View Details for Payment', 'edd-wallet') . ' ' . $item->payment_id . '" href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item->payment_id) . '">' . __('View Details', 'edd-wallet') . '</a>';
                        $status = edd_get_payment_status(get_post($item->payment_id), true);
                        break;
                    case 'withdrawal':
                        $type = __('Withdraw', 'edd-wallet');
                        $item_id = $item->id . ' (' . $item->payment_id . ')';
                        $actions = '<a title="' . __('View Details for Payment', 'edd-wallet') . ' ' . $item->payment_id . '" href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item->payment_id) . '">' . __('View Details', 'edd-wallet') . '</a>';
                        $status = edd_get_payment_status(get_post($item->payment_id), true);
                        break;
                    case 'admin-deposit':
                        $type = __('Admin Deposit', 'edd-wallet');
                        $item_id = $item->id;
                        $actions = '';
                        $status = __('Complete', 'edd-wallet');
                        break;
                    case 'admin-withdraw':
                        $type = __('Admin Withdraw', 'edd-wallet');
                        $item_id = $item->id;
                        $actions = '';
                        $status = __('Complete', 'edd-wallet');
                        break;
                    case 'refund':
                        $type = __('Refund', 'edd-wallet');
                        $item_id = $item->id;
                        $actions = '';
                        $status = __('Complete', 'edd-wallet');
                        break;
                    default:
                        $type = apply_filters('edd_wallet_activity_type', $item->type, $item);
                        $item_id = apply_filters('edd_wallet_activity_item_id', $item->id, $item);
                        $actions = apply_filters('edd_wallet_activity_actions', '', $item);
                        $status = apply_filters('edd_wallet_activity_status', __('Complete', 'edd-wallet'), $item);
                        break;
                }
                ?>
						<tr>
							<td><?php 
                echo $item_id;
                ?>
</td>
							<td><?php 
                echo $type;
                ?>
</td>
							<td><?php 
                echo edd_currency_filter(edd_format_amount($item->amount));
                ?>
</td>
							<td><?php 
                echo $item->date_created;
                ?>
</td>
							<td><?php 
                echo $status;
                ?>
</td>
							<td>
								<?php 
                echo $actions;
                ?>
								<?php 
                do_action('edd_wallet_recent_history_actions', $customer, $item);
                ?>
							</td>
						</tr>
						<?php 
            }
        } else {
            echo '<tr><td colspan="6">' . __('No Activity Found', 'edd-wallet') . '</td></tr>';
        }
        ?>

				</tbody>
			</table>

			<div class="edd-wallet-edit-wallet">
				<a class="button-secondary" href="<?php 
        echo esc_url(add_query_arg(array('page' => 'edd-wallet-edit', 'id' => $customer->id, 'edd-message' => false), admin_url('options.php')));
        ?>
"><?php 
        _e('Edit Wallet', 'edd-wallet');
        ?>
</a>
			</div>

		<?php 
    }
    ?>

		<?php 
    do_action('edd_customer_wallet_after_tables', $customer);
    ?>

	</div>
	<?php 
    do_action('edd_customer_wallet_card_bottom', $customer);
}
Пример #24
0
                                ?>
												</a>
											</div>

											<?php 
                                do_action('edd_download_history_files', $filekey, $file, $id, $payment->ID, $purchase_data);
                            }
                        } else {
                            esc_html_e('No downloadable files found.', 'helium');
                        }
                        // End if payment complete
                    } else {
                        ?>
									<span class="edd_download_payment_status">
										<?php 
                        printf(esc_html__('Payment status is %s', 'helium'), edd_get_payment_status($payment, true));
                        ?>
									</span>
									<?php 
                    }
                    // End if $download_files
                    ?>
							</td>
						<?php 
                }
                // End if ! edd_no_redownload()
                do_action('edd_download_history_row_end', $payment->ID, $download['id']);
                ?>
					</tr>
					<?php 
            }
										<div class="edd-admin-box-inside">
											<p>
												<span class="label"><?php 
_e('Status:', 'edd');
?>
</span>&nbsp;
												<select name="edd-payment-status" class="medium-text">
													<?php 
foreach (edd_get_payment_statuses() as $key => $status) {
    ?>
														<option value="<?php 
    echo esc_attr($key);
    ?>
"<?php 
    selected(edd_get_payment_status($item, true), $status);
    ?>
><?php 
    echo esc_html($status);
    ?>
</option>
													<?php 
}
?>
												</select>
											</p>
										</div>

										<div class="edd-admin-box-inside">
											<p>
												<span class="label"><?php 
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.4
  *
  * @param array $item Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'amount':
             $value = edd_currency_filter(edd_format_amount($item[$column_name]));
             break;
         case 'date':
             $date = strtotime($item[$column_name]);
             $value = date_i18n(get_option('date_format'), $date);
             break;
         case 'status':
             $payment = get_post($item['ID']);
             $value = edd_get_payment_status($payment, true);
             break;
         case 'details':
             $value = '<a href="' . add_query_arg('id', $item['ID'], admin_url('edit.php?post_type=download&page=edd-payment-history&edd-action=view-order-details')) . '">' . __('View Order Details', 'edd') . '</a>';
             break;
         default:
             $value = isset($item[$column_name]) ? $item[$column_name] : '';
             break;
     }
     return apply_filters('edd_payments_table_column', $value, $item['ID'], $column_name);
 }
                                ?>
												</a>
											</div>

											<?php 
                                do_action('edd_download_history_files', $filekey, $file, $id, $payment->ID, $purchase_data);
                            }
                        } else {
                            _e('No downloadable files found.', 'easy-digital-downloads');
                        }
                        // End if payment complete
                    } else {
                        ?>
									<span class="edd_download_payment_status">
										<?php 
                        printf(__('Payment status is %s', 'easy-digital-downloads'), edd_get_payment_status($payment, true));
                        ?>
									</span>
									<?php 
                    }
                    // End if $download_files
                    ?>
							</td>
						<?php 
                }
                // End if ! edd_no_redownload()
                do_action('edd_download_history_row_end', $payment->ID, $download['id']);
                ?>
					</tr>
					<?php 
            }
function edd_export_payment_history()
{
    global $edd_options;
    if (!isset($_GET['export'])) {
        return;
    }
    // get out quick if not required.
    $mode = isset($_GET['mode']) ? $_GET['mode'] : 'live';
    if (edd_is_test_mode() && !isset($_GET['mode'])) {
        $mode = 'test';
    }
    $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'ID';
    $order = isset($_GET['order']) ? $_GET['order'] : 'DESC';
    $order_inverse = $order == 'DESC' ? 'ASC' : 'DESC';
    $order_class = strtolower($order_inverse);
    $user = isset($_GET['user']) ? $_GET['user'] : null;
    $status = isset($_GET['status']) ? $_GET['status'] : null;
    $export = isset($_GET['export']) ? $_GET['export'] : null;
    if ($export == 'csv') {
        // extensible for other formats in future
        header('Content-Type: text/csv; charset=utf-8');
        header('Content-Disposition: attachment; filename=edd-payment-history-' . date('m-d-Y') . '.csv');
        header("Pragma: no-cache");
        header("Expires: 0");
        $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode, 'orderby' => $orderby, 'order' => $order, 'user' => $user, 'status' => $status));
        if ($payments) {
            $i = 0;
            echo '"' . __('ID', 'edd') . '",';
            echo '"' . __('Email', 'edd') . '",';
            echo '"' . __('First Name', 'edd') . '",';
            echo '"' . __('Last Name', 'edd') . '",';
            echo '"' . __('Products', 'edd') . '",';
            echo '"' . __('Discounts,', 'edd') . '",';
            echo '"' . __('Amount paid', 'edd') . '",';
            echo '"' . __('Payment method', 'edd') . '",';
            echo '"' . __('Key', 'edd') . '",';
            echo '"' . __('Date', 'edd') . '",';
            echo '"' . __('User', 'edd') . '",';
            echo '"' . __('Status', 'edd') . '"';
            echo "\r\n";
            foreach ($payments as $payment) {
                $payment_meta = edd_get_payment_meta($payment->ID);
                $user_info = maybe_unserialize($payment_meta['user_info']);
                echo '"' . $payment->ID . '",';
                echo '"' . $payment_meta['email'] . '",';
                echo '"' . $user_info['first_name'] . '",';
                echo '"' . $user_info['last_name'] . '",';
                $downloads = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
                if (empty($downloads) || !$downloads) {
                    $downloads = maybe_unserialize($payment_meta['downloads']);
                }
                if ($downloads) {
                    foreach ($downloads as $key => $download) {
                        // retrieve the ID of the download
                        $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                        // if download has variable prices, override the default price
                        $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                        $user_info = unserialize($payment_meta['user_info']);
                        // calculate the final price
                        $price = edd_get_download_final_price($id, $user_info, $price_override);
                        // show name of download
                        echo get_the_title($id);
                        echo ' - ';
                        if (isset($downloads[$key]['item_number'])) {
                            $price_options = $downloads[$key]['item_number']['options'];
                            if (isset($price_options['price_id'])) {
                                echo edd_get_price_option_name($id, $price_options['price_id']);
                                echo ' - ';
                            }
                        }
                        echo html_entity_decode(edd_currency_filter($price));
                        if ($key != count($downloads) - 1) {
                            echo ' / ';
                        }
                    }
                    echo ',';
                }
                if (isset($user_info['discount']) && $user_info['discount'] != 'none') {
                    echo '"' . $user_info['discount'] . '",';
                } else {
                    echo '"' . __('none', 'edd') . '",';
                }
                echo '"' . html_entity_decode(edd_currency_filter($payment_meta['amount'])) . '",';
                $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true);
                if ($gateway) {
                    echo '"' . edd_get_gateway_admin_label($gateway) . '",';
                } else {
                    echo '"' . __('none', 'edd') . '",';
                }
                echo '"' . $payment_meta['key'] . '",';
                echo '"' . date(get_option('date_format'), strtotime($payment->post_date)) . '",';
                $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
                echo '"';
                echo is_numeric($user_id) ? get_user_by('id', $user_id)->display_name : __('guest', 'edd');
                echo '",';
                echo '"' . edd_get_payment_status($payment, true) . '"';
                echo "\r\n";
                $i++;
            }
        } else {
            echo __('No payments recorded yet', 'edd');
        }
    }
    die;
}
    ?>

	<div class="edd_errors edd-alert edd-alert-error">
		<?php 
    _e('The specified receipt ID appears to be invalid', 'easy-digital-downloads');
    ?>
	</div>

<?php 
    return;
}
$meta = edd_get_payment_meta($payment->ID);
$cart = edd_get_payment_meta_cart_details($payment->ID, true);
$user = edd_get_payment_meta_user_info($payment->ID);
$email = edd_get_payment_user_email($payment->ID);
$status = edd_get_payment_status($payment, true);
?>
<table id="edd_purchase_receipt">
	<thead>
		<?php 
do_action('edd_payment_receipt_before', $payment, $edd_receipt_args);
?>

		<?php 
if ($edd_receipt_args['payment_id']) {
    ?>
		<tr>
			<th><strong><?php 
    _e('Payment', 'easy-digital-downloads');
    ?>
:</strong></th>
						<h3 class="hndle"><?php 
_e('Order Details', 'edd');
?>
</h3>
						<div class="inside">
							<div class="column-container">
								<div class="order-data-column">
									<h4><?php 
_e('General Details', 'edd');
?>
</h4>
									<p class="data"><span><?php 
_e('Status:', 'edd');
?>
</span> <?php 
echo edd_get_payment_status($item, true);
?>
</p>
									<p class="data"><span><?php 
_e('Date:', 'edd');
?>
</span> <?php 
echo date_i18n(get_option('date_format'), $payment_date);
?>
</p>
									<p class="data"><span><?php 
_e('Time:', 'edd');
?>
</span> <?php 
echo date_i18n(get_option('time_format'), $payment_date);
?>