当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_get_payments函数代码示例

本文整理汇总了PHP中edd_get_payments函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_payments函数的具体用法?PHP edd_get_payments怎么用?PHP edd_get_payments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_get_payments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.5
  * @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()
 {
     $args = array('number' => $this->per_step, 'offset' => $this->per_step * ($this->step - 1), 'orderby' => 'id', 'order' => 'DESC');
     $customers = EDD()->customers->get_customers($args);
     if ($customers) {
         foreach ($customers as $customer) {
             $attached_payment_ids = explode(',', $customer->payment_ids);
             $attached_args = array('post__in' => $attached_payment_ids, 'number' => -1);
             $attached_payments = edd_get_payments($attached_args);
             $unattached_args = array('post__not_in' => $attached_payment_ids, 'number' => -1, 'meta_query' => array(array('key' => '_edd_payment_user_email', 'value' => $customer->email, 'compare' => '=')));
             $unattached_payments = edd_get_payments($unattached_args);
             $payments = array_merge($attached_payments, $unattached_payments);
             $purchase_value = 0.0;
             $purchase_count = 0;
             $payment_ids = array();
             if ($payments) {
                 foreach ($payments as $payment) {
                     if ('publish' == $payment->post_status || 'revoked' == $payment->post_status) {
                         $purchase_value += edd_get_payment_amount($payment->ID);
                         $purchase_count++;
                     }
                     $payment_ids[] = $payment->ID;
                 }
             }
             $payment_ids = implode(',', $payment_ids);
             $customer_update_data = array('purchase_count' => $purchase_count, 'purchase_value' => $purchase_value, 'payment_ids' => $payment_ids);
             $customer_instance = new EDD_Customer($customer->id);
             $customer_instance->update($customer_update_data);
         }
         return true;
     }
     return false;
 }
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:42,代码来源:class-edd-tools-recount-customer-stats.php

示例2: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.5
  * @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()
 {
     if ($this->step == 1) {
         $this->delete_data('edd_temp_recount_earnings');
     }
     $total = get_option('edd_temp_recount_earnings', false);
     if (false === $total) {
         $total = (double) 0;
         $this->store_data('edd_temp_recount_earnings', $total);
     }
     $accepted_statuses = apply_filters('edd_recount_accepted_statuses', array('publish', 'revoked'));
     $args = apply_filters('edd_recount_earnings_args', array('number' => $this->per_step, 'page' => $this->step, 'status' => $accepted_statuses, 'fields' => 'ids'));
     $payments = edd_get_payments($args);
     if (!empty($payments)) {
         foreach ($payments as $payment) {
             $total += edd_get_payment_amount($payment);
         }
         if ($total < 0) {
             $totals = 0;
         }
         $total = round($total, edd_currency_decimal_filter());
         $this->store_data('edd_temp_recount_earnings', $total);
         return true;
     }
     update_option('edd_earnings_total', $total);
     set_transient('edd_earnings_total', $total, 86400);
     return false;
 }
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:class-edd-tools-recount-store-earnings.php

示例3: get_data

 /**
  * 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) {
         $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 = isset($payment_meta['amount']) ? $payment_meta['amount'] : 0.0;
         $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']) . ' - ';
                     }
                 }
                 $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;
 }
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:66,代码来源:class-export-payments.php

示例4: edd_count_payments

/**
 * Count Payments
 *
 * Returns the total number of payments recorded.
 *
 * @access      public
 * @since       1.0 
 * @return      integer
*/
function edd_count_payments($mode, $user = null)
{
    $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode, 'orderby' => 'ID', 'order' => 'DESC', 'user' => $user));
    $count = 0;
    if ($payments) {
        $count = count($payments);
    }
    return $count;
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:18,代码来源:deprecated-functions.php

示例5: edd_count_payments

/**
 * Count Payments
 *
 * Returns the total number of payments recorded.
 *
 * @access      public
 * @since       1.0
 * @deprecated 	1.2
 * @return      integer
*/
function edd_count_payments($mode, $user = null)
{
    _edd_deprecated_function(__FUNCTION__, '1.2');
    $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode, 'orderby' => 'ID', 'order' => 'DESC', 'user' => $user));
    $count = 0;
    if ($payments) {
        $count = count($payments);
    }
    return $count;
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:20,代码来源:deprecated-functions.php

示例6: send_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.5.3
  * @global object $wpdb Used to query the database using the WordPress
  *   Database API
  * @return array $data The data for the CSV file
  */
 public function send_data()
 {
     $data = array();
     $args = array('number' => 30, 'page' => $this->step, 'status' => 'publish');
     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));
     }
     $payments = edd_get_payments($args);
     if ($payments) {
         $mailchimp_ecommerce = new EDD_MC_Ecommerce_360();
         foreach ($payments as $payment) {
             $mailchimp_ecommerce->record_ecommerce360_purchase($payment->ID);
         }
         return true;
     }
     return false;
 }
开发者ID:katzwebservices,项目名称:edd-mail-chimp,代码行数:26,代码来源:class-edd-mailchimp-batch-processor.php

示例7: edd_show_upgrade_notices

/**
 * Display Upgrade Notices
 *
 * @since 1.3.1
 * @return void
*/
function edd_show_upgrade_notices()
{
    if (isset($_GET['page']) && $_GET['page'] == 'edd-upgrades') {
        return;
    }
    // Don't show notices on the upgrades page
    $edd_version = get_option('edd_version');
    if (!$edd_version) {
        // 1.3 is the first version to use this option so we must add it
        $edd_version = '1.3';
    }
    $edd_version = preg_replace('/[^0-9.].*/', '', $edd_version);
    if (!get_option('edd_payment_totals_upgraded') && !get_option('edd_version')) {
        if (wp_count_posts('edd_payment')->publish < 1) {
            return;
        }
        // No payment exist yet
        // The payment history needs updated for version 1.2
        $url = add_query_arg('edd-action', 'upgrade_payments');
        $upgrade_notice = sprintf(__('The Payment History needs to be updated. %s', 'edd'), '<a href="' . wp_nonce_url($url, 'edd_upgrade_payments_nonce') . '">' . __('Click to Upgrade', 'edd') . '</a>');
        add_settings_error('edd-notices', 'edd-payments-upgrade', $upgrade_notice, 'error');
    }
    if (version_compare($edd_version, '1.3.2', '<') && !get_option('edd_logs_upgraded')) {
        printf('<div class="updated"><p>' . esc_html__('The Purchase and File Download History in Easy Digital Downloads needs to be upgraded, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '1.3.4', '<') || version_compare($edd_version, '1.4', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the plugin pages, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '1.5', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '2.0', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (EDD()->session->get('upgrade_sequential') && edd_get_payments()) {
        printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade past order numbers to make them sequential, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_sequential_payment_numbers'));
    }
    if (version_compare($edd_version, '2.1', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the customer database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_customers_db')) . '">', '</a>');
    }
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:47,代码来源:upgrade-functions.php

示例8: edd_remove_refunded_sale_logs

/**
 * Remove sale logs from refunded orders
 *
 * @since  2.4.3
 * @return void
 */
function edd_remove_refunded_sale_logs()
{
    global $wpdb, $edd_logs;
    if (!current_user_can('manage_shop_settings')) {
        wp_die(__('You do not have permission to do shop upgrades', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        @set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $total = isset($_GET['total']) ? absint($_GET['total']) : edd_count_payments()->refunded;
    $refunds = edd_get_payments(array('status' => 'refunded', 'number' => 20, 'page' => $step));
    if (!empty($refunds)) {
        // Refunded Payments found so process them
        foreach ($refunds as $refund) {
            if ('refunded' !== $refund->post_status) {
                continue;
                // Just to be safe
            }
            // Remove related sale log entries
            $edd_logs->delete_logs(null, 'sale', array(array('key' => '_edd_log_payment_id', 'value' => $refund->ID)));
        }
        $step++;
        $redirect = add_query_arg(array('page' => 'edd-upgrades', 'edd-upgrade' => 'remove_refunded_sale_logs', 'step' => $step, 'total' => $total), admin_url('index.php'));
        wp_redirect($redirect);
        exit;
    } else {
        // No more refunded payments found, finish up
        update_option('edd_version', preg_replace('/[^0-9.].*/', '', EDD_VERSION));
        edd_set_upgrade_complete('remove_refunded_sale_logs');
        delete_option('edd_doing_upgrade');
        wp_redirect(admin_url());
        exit;
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:42,代码来源:upgrade-functions.php

示例9: pre_fetch

 /**
  * Zero out the data on step one
  *
  * @access public
  * @since 2.5
  * @return void
  */
 public function pre_fetch()
 {
     if ($this->step === 1) {
         // Before we start, let's zero out the customer's data
         $customer = new EDD_Customer($this->customer_id);
         $customer->update(array('purchase_value' => edd_format_amount(0), 'purchase_count' => 0));
         $attached_payment_ids = explode(',', $customer->payment_ids);
         $attached_args = array('post__in' => $attached_payment_ids, 'number' => -1);
         $attached_payments = edd_get_payments($attached_args);
         $unattached_args = array('post__not_in' => $attached_payment_ids, 'number' => -1, 'meta_query' => array(array('key' => '_edd_payment_user_email', 'value' => $customer->email)));
         $unattached_payments = edd_get_payments($unattached_args);
         $payments = array_merge($attached_payments, $unattached_payments);
         $this->store_data('edd_recount_customer_payments_' . $customer->id, $payments);
     }
 }
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:22,代码来源:class-edd-tools-recount-single-customer-stats.php

示例10: payments_data

 /**
  * Retrieve all the data for all the payments
  *
  * @access public
  * @since 1.4
  * @return array $payment_data Array of all the data for the payments
  */
 public function payments_data()
 {
     $payments_data = array();
     if (isset($_GET['paged'])) {
         $page = $_GET['paged'];
     } else {
         $page = 1;
     }
     $per_page = $this->per_page;
     $mode = edd_is_test_mode() ? 'test' : 'live';
     $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;
     $year = isset($_GET['year']) ? $_GET['year'] : null;
     $month = isset($_GET['m']) ? $_GET['m'] : null;
     $day = isset($_GET['day']) ? $_GET['day'] : null;
     $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
     $payments = edd_get_payments(array('number' => $per_page, 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, 'mode' => $mode, 'orderby' => $orderby, 'order' => $order, 'user' => $user, 'status' => $status, 'meta_key' => $meta_key, 'year' => $year, 'month' => $month, 'day' => $day, 's' => $search));
     if ($payments) {
         foreach ($payments as $payment) {
             $user_info = edd_get_payment_meta_user_info($payment->ID);
             $cart_details = edd_get_payment_meta_cart_details($payment->ID);
             $user_id = isset($user_info['ID']) && $user_info['ID'] != -1 ? $user_info['ID'] : $user_info['email'];
             $payments_data[] = array('ID' => $payment->ID, 'email' => edd_get_payment_user_email($payment->ID), 'products' => $cart_details, 'amount' => edd_get_payment_amount($payment->ID), 'date' => $payment->post_date, 'user' => $user_id, 'status' => $payment->post_status);
         }
     }
     return $payments_data;
 }
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:39,代码来源:class-payments-table.php

示例11: edd_dashboard_sales_widget


//.........这里部分代码省略.........
</td>
					<td class="last t sales"><?php 
    _e('Total Sales', 'edd');
    ?>
</td>
				</tr>
			</tbody>
		</table>
		<?php 
    if ($top_selling) {
        foreach ($top_selling as $list) {
            ?>
				<p class="lifetime_best_selling label_heading"><?php 
            _e('Lifetime Best Selling', 'edd');
            ?>
</p>
				<p><span class="lifetime_best_selling_label"><?php 
            echo edd_get_download_sales_stats($list->ID);
            ?>
</span> <a href="<?php 
            echo get_permalink($list->ID);
            ?>
"><?php 
            echo get_the_title($list->ID);
            ?>
</a></p>
		<?php 
        }
    }
    ?>
	</div>
	<div style="clear: both"></div>
	<?php 
    $payments = edd_get_payments(array('number' => 5, 'mode' => 'live', 'orderby' => 'post_date', 'order' => 'DESC', 'user' => null, 'status' => 'publish', 'meta_key' => null));
    if ($payments) {
        ?>
	<p class="edd_dashboard_widget_subheading"><?php 
        _e('Recent Purchases', 'edd');
        ?>
</p>
	<div class="table recent_purchases">
		<table>
			<tbody>
				<?php 
        foreach ($payments as $payment) {
            $payment_meta = edd_get_payment_meta($payment->ID);
            ?>
				<tr>
					<td><?php 
            echo get_the_title($payment->ID);
            ?>
 - (<?php 
            echo $payment_meta['email'];
            ?>
) - <span class="edd_price_label"><?php 
            echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment->ID)));
            ?>
</span> - <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');
            ?>
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:67,代码来源:dashboard-widgets.php

示例12: edd_points_apply_for_previous_orders

 /**
  * Apply Points to Previous Orders
  * 
  * Handles to apply points to previous orders
  *
  * @package Easy Digital Downloads - Points and Rewards
  * @since 1.0.0
  */
 public function edd_points_apply_for_previous_orders()
 {
     if (isset($_GET['points_action']) && $_GET['points_action'] == 'apply_points' && isset($_GET['page']) && $_GET['page'] == 'edd-settings') {
         // perform the action in manageable chunks
         $success_count = 0;
         $paymentmode = edd_is_test_mode() ? 'test' : 'live';
         $paymentargs = array('mode' => $paymentmode, 'fields' => 'ids', 'status' => 'publish', 'posts_per_page' => '-1', 'meta_query' => array(array('key' => '_edd_points_order_earned', 'compare' => 'NOT EXISTS')));
         // grab a set of order ids for existing orders with no earned points set
         $payment_ids = edd_get_payments($paymentargs);
         // otherwise go through the results and set the order numbers
         if (is_array($payment_ids)) {
             foreach ($payment_ids as $payment_id) {
                 $payment = get_post($payment_id);
                 $payment_data = edd_get_payment_meta($payment_id);
                 // get cartdata from older order
                 $cartdata = edd_get_payment_meta_cart_details($payment_id);
                 //get cartdata points
                 $checkoutpoints = $this->model->edd_points_get_user_checkout_points($cartdata);
                 //check checkout points should not empty which has redeemed by buyer
                 if (!empty($checkoutpoints)) {
                     //get user points label
                     $pointlable = $this->model->edd_points_get_points_label($checkoutpoints);
                     $post_data = array('post_title' => sprintf(__('%s earned for purchasing the downloads.', 'eddpoints'), $pointlable), 'post_content' => sprintf(__('Get %s for purchasing the downloads.', 'eddpoints'), $pointlable), 'post_author' => $payment->post_author);
                     $log_meta = array('userpoint' => $checkoutpoints, 'events' => 'earned_purchase', 'operation' => 'add');
                     //insert entry in log
                     $this->logs->edd_points_insert_logs($post_data, $log_meta);
                     //update user points
                     edd_points_add_points_to_user($checkoutpoints, $payment->post_author);
                     // set order meta, regardless of whether any points were earned, just so we know the process took place
                     update_post_meta($payment_id, '_edd_points_order_earned', $checkoutpoints);
                 }
                 $success_count++;
             }
             //end foreach loop
         }
         //end if check retrive payment ids are array
         $redirectargs = array('post_type' => 'download', 'page' => 'edd-settings', 'tab' => 'extensions', 'settings-updated' => 'apply_points', 'success_count' => $success_count, 'points_action' => false);
         $redirect_url = add_query_arg($redirectargs, admin_url('edit.php'));
         wp_redirect($redirect_url);
         exit;
     }
     //end if check if there is fulfilling condition proper for applying discount for previous orders
 }
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:51,代码来源:class-edd-points-admin.php

示例13: edd_mark_abandoned_orders

/**
 * Updates week-old+ 'pending' orders to 'abandoned'
 *
 * @since 1.6
 * @return void
*/
function edd_mark_abandoned_orders()
{
    $args = array('status' => 'pending', 'number' => -1);
    add_filter('posts_where', 'edd_filter_where_older_than_week');
    $payments = edd_get_payments($args);
    remove_filter('posts_where', 'edd_filter_where_older_than_week');
    if ($payments) {
        foreach ($payments as $payment) {
            if ('pending' === $payment->post_status) {
                edd_update_payment_status($payment->ID, 'abandoned');
            }
        }
    }
}
开发者ID:harish94,项目名称:Easy-Digital-Downloads,代码行数:20,代码来源:actions.php

示例14: edd_add_past_purchases_to_new_user

/**
 * Looks up purchases by email that match the registering user
 *
 * This is for users that purchased as a guest and then came
 * back and created an account.
 *
 * @access      public
 * @since       1.6
 * @param       $user_id INT - the new user's ID
 * @return      void
 */
function edd_add_past_purchases_to_new_user($user_id)
{
    $email = get_user_meta($user_id, 'user_email', true);
    $mode = edd_is_test_mode() ? 'test' : 'live';
    $payments = edd_get_payments(array('s' => $email, 'mode' => $mode));
    if ($payments) {
        foreach ($payments as $payment) {
            if (intval(edd_get_payment_user_id($payment->ID)) > 0) {
                continue;
            }
            // This payment already associated with an account
            $meta = edd_get_payment_meta($payment->ID);
            $meta['user_info'] = maybe_unserialize($meta['user_info']);
            $meta['user_info']['id'] = $user_id;
            $meta['user_info'] = serialize($meta['user_info']);
            // Store the updated user ID in the payment meta
            update_post_meta($payment->ID, '_edd_payment_meta', $meta);
        }
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:user-functions.php

示例15: get_data

 /**
  * 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;
 }
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:71,代码来源:class-batch-export-payments.php


注:本文中的edd_get_payments函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。