本文整理汇总了PHP中edd_get_payment_meta_downloads函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_payment_meta_downloads函数的具体用法?PHP edd_get_payment_meta_downloads怎么用?PHP edd_get_payment_meta_downloads使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_payment_meta_downloads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pw_edd_add_customer_to_level
/**
* Add member to an RCP subscription level when they purchase a specific product
*
*/
function pw_edd_add_customer_to_level($payment_id = 0)
{
$user_id = edd_get_payment_user_id($payment_id);
if ($user_id <= 0) {
return;
}
$downloads = edd_get_payment_meta_downloads($payment_id);
if ($downloads) {
$level = false;
foreach ($downloads as $download) {
// Set the subscription level based on the product ID(s) purchased
switch ($download['id']) {
case 45:
// Set the subscription level to add the user to
$level = 4;
break;
case 742:
break;
}
}
if (!empty($level) && function_exists('rcp_set_status')) {
// Give user one month of access
$expiration = date('Y-m-d H:i:s', strtotime('+1 month'));
update_user_meta($user_id, 'rcp_subscription_level', $level);
update_user_meta($user_id, 'rcp_expiration', $expiration);
rcp_set_status($user_id, 'active');
}
}
}
示例2: edd_has_user_purchased
/**
* Has User Purchased
*
* Checks to see if a user has purchased a download.
*
* @access public
* @since 1.0
* @param int $user_id - the ID of the user to check
* @param array $downloads - Array of IDs to check if purchased. If an int is passed, it will be converted to an array
* @param int $variable_price_id - the variable price ID to check for
* @return boolean - true if has purchased, false otherwise
*/
function edd_has_user_purchased($user_id, $downloads, $variable_price_id = null)
{
if (!is_user_logged_in()) {
return false;
}
// At some point this should support email checking
$users_purchases = edd_get_users_purchases($user_id);
$return = false;
if (!is_array($downloads)) {
$downloads = array($downloads);
}
if ($users_purchases) {
foreach ($users_purchases as $purchase) {
$purchased_files = edd_get_payment_meta_downloads($purchase->ID);
if (is_array($purchased_files)) {
foreach ($purchased_files as $download) {
if (in_array($download['id'], $downloads)) {
$variable_prices = edd_has_variable_prices($download['id']);
if ($variable_prices && !is_null($variable_price_id) && $variable_price_id !== false) {
if (isset($download['options']['price_id']) && $variable_price_id == $download['options']['price_id']) {
return true;
} else {
$return = false;
}
} else {
$return = true;
}
}
}
}
}
}
return $return;
}
示例3: ao_edd_set_customer_role
function ao_edd_set_customer_role($payment_id)
{
$email = edd_get_payment_user_email($payment_id);
$downloads = edd_get_payment_meta_downloads($payment_id);
$user_id = edd_get_payment_user_id($payment_id);
if ($user_id) {
$user = new WP_User($user_id);
// Add role
$user->add_role('buyer');
}
}
示例4: edd_sl_site_management_links
/**
* Displays a Manage Licenses link in purchase history
*
* @since 2.7
*/
function edd_sl_site_management_links($payment_id, $purchase_data)
{
$licensing = edd_software_licensing();
$downloads = edd_get_payment_meta_downloads($payment_id);
if ($downloads) {
$manage_licenses_url = esc_url(add_query_arg(array('action' => 'manage_licenses', 'payment_id' => $payment_id)));
echo '<td class="edd_license_key">';
if (edd_is_payment_complete($payment_id)) {
echo '<a href="' . esc_url($manage_licenses_url) . '">' . __('View Licenses', 'edd_sl') . '</a>';
} else {
echo '-';
}
echo '</td>';
}
}
示例5: edd_resend_purchase_receipt
/**
* Resend the Email Purchase Receipt. (This can be done from the Payment History page)
*
* @since 1.0
* @param array $data Payment Data
* @return void
*/
function edd_resend_purchase_receipt($data)
{
$purchase_id = $data['purchase_id'];
edd_email_purchase_receipt($purchase_id, false);
// Grab all downloads of the purchase and update their file download limits, if needed
// This allows admins to resend purchase receipts to grant additional file downloads
$downloads = edd_get_payment_meta_downloads($purchase_id);
if (is_array($downloads)) {
foreach ($downloads as $download) {
$limit = edd_get_file_download_limit($download['id']);
if (!empty($limit)) {
edd_set_file_download_limit_override($download['id'], $purchase_id);
}
}
}
wp_redirect(add_query_arg(array('edd-message' => 'email_sent', 'edd-action' => false, 'purchase_id' => false)));
exit;
}
示例6: resend_purchase_receipt
/**
* Resends a purchase receipt
*/
function resend_purchase_receipt()
{
authorize_request();
$payment_id = absint($_GET['payment_id']);
edd_email_purchase_receipt($payment_id, false);
// Grab all downloads of the purchase and update their file download limits, if needed
// This allows admins to resend purchase receipts to grant additional file downloads
$downloads = edd_get_payment_meta_downloads($payment_id);
if (is_array($downloads)) {
foreach ($downloads as $download) {
$limit = edd_get_file_download_limit($download['id']);
if (!empty($limit)) {
edd_set_file_download_limit_override($download['id'], $payment_id);
}
}
}
die('<script>window.close();</script>');
}
示例7: edd_cr_get_restricted_pages
/**
* Get posts/pages restricted to the purchased files
*
* @since 1.3.0
* @param int $payment_id The ID of this payment
* @return array $meta The list of accessible files
*/
function edd_cr_get_restricted_pages($payment_id = 0)
{
if (empty($payment_id)) {
return false;
}
$posts = array();
$post_ids = array();
$files = edd_get_payment_meta_downloads($payment_id);
$ids = array_unique(wp_list_pluck($files, 'id'));
foreach ($ids as $download_id) {
$meta = get_post_meta($download_id, '_edd_cr_protected_post');
if ($meta) {
$post_ids = array_merge($post_ids, $meta);
}
}
$post_ids = array_unique(array_map('absint', $post_ids));
if (!empty($post_ids)) {
$args = array('post_type' => 'any', 'nopaging' => true, 'post__in' => $post_ids);
$query = new WP_Query($args);
$posts = $query->posts;
}
return $posts;
}
示例8: edd_pl_get_user_purchase_count
/**
* Get user purchase count for download
*
* @since 1.0.1
* @param int $user_id the ID of the user to check
* @param int $download_id the download ID to check
* @param int $variable_price_id the variable price ID to check
* @return int $count the number of times the product has been purchased
*/
function edd_pl_get_user_purchase_count($user_id, $download_id, $variable_price_id = null)
{
if (!is_user_logged_in()) {
return 0;
}
$users_purchases = edd_get_users_purchases($user_id, 999);
$count = 0;
$download_id = array($download_id);
if ($users_purchases) {
foreach ($users_purchases as $purchase) {
$purchased_files = edd_get_payment_meta_downloads($purchase->ID);
if (is_array($purchased_files)) {
foreach ($purchased_files as $download) {
if (isset($download['id']) && in_array($download['id'], $download_id)) {
$count++;
}
}
}
}
}
return $count;
}
示例9: wi_bbp_sidebar
/**
* 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
}
示例10: atcf_gateway_pap_log_payments_per_user
/**
* Track number or purchases by a registered user.
*
* @since Astoundify Crowdfunding 1.3
*
* @param int $payment the ID number of the payment
* @param string $new_status
* @param string $old_status
* @return void
*/
function atcf_gateway_pap_log_payments_per_user($payment_id, $new_status, $old_status)
{
global $edd_options;
if (!atcf_is_gatweay_active('paypal_adaptive_payments')) {
return;
}
if (!isset($edd_options['epap_payments_per_user'])) {
return;
}
if ($old_status != 'pending') {
return;
}
if (in_array($new_status, array('refunded', 'failed', 'revoked'))) {
return;
}
$gateway = get_post_meta($payment_id, '_edd_payment_gateway', true);
if ('paypal_adaptive_payments' != $gateway) {
return;
}
$user_id = get_post_meta($payment_id, '_edd_payment_user_id', true);
$user = get_userdata($user_id);
$downloads = edd_get_payment_meta_downloads($payment_id);
if (!is_array($downloads)) {
return;
}
$contributed_to = $user->get('atcf_contributed_to');
foreach ($downloads as $download) {
if (isset($contributed_to[$download['id']])) {
$contributed_to[$download['id']] = $contributed_to[$download['id']] + 1;
} else {
$contributed_to[$download['id']] = 1;
}
}
update_user_meta($user->ID, 'atcf_contributed_to', $contributed_to);
}
示例11: get_download_logs
/**
* Process Get Downloads API Request to retrieve download logs
*
* @access public
* @since 2.5
* @author Daniel J Griffiths
*
* @param int $customer_id The customer ID you wish to retrieve download logs for
* @return array Multidimensional array of the download logs
*/
public function get_download_logs($customer_id = 0)
{
global $edd_logs;
$downloads = array();
$errors = array();
$paged = $this->get_paged();
$per_page = $this->per_page();
$offset = $per_page * ($paged - 1);
$meta_query = array();
if (!empty($customer_id)) {
$customer = new EDD_Customer($customer_id);
$invalid_customer = false;
if ($customer->id > 0) {
$meta_query['relation'] = 'OR';
if ($customer->id > 0) {
// Based on customer->user_id
$meta_query[] = array('key' => '_edd_log_user_id', 'value' => $customer->user_id);
}
// Based on customer->email
$meta_query[] = array('key' => '_edd_log_user_info', 'value' => $customer->email, 'compare' => 'LIKE');
} else {
$invalid_customer = true;
}
}
$query = array('log_type' => 'file_download', 'paged' => $paged, 'meta_query' => $meta_query, 'posts_per_page' => $per_page, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
$logs = array();
if (!$invalid_customer) {
$logs = $edd_logs->get_connected_logs($query);
}
if (empty($logs)) {
$error['error'] = __('No download logs found!', 'easy-digital-downloads');
return $error;
}
foreach ($logs as $log) {
$item = array();
$log_meta = get_post_custom($log->ID);
$user_info = isset($log_meta['_edd_log_user_info']) ? maybe_unserialize($log_meta['_edd_log_user_info'][0]) : array();
$payment_id = isset($log_meta['_edd_log_payment_id']) ? $log_meta['_edd_log_payment_id'][0] : false;
$payment_customer_id = edd_get_payment_customer_id($payment_id);
$payment_customer = new EDD_Customer($payment_customer_id);
$user_id = $payment_customer->user_id > 0 ? $payment_customer->user_id : false;
$ip = $log_meta['_edd_log_ip'][0];
$files = edd_get_payment_meta_downloads($payment_id);
$files = edd_get_download_files($files[0]['id']);
$file_id = (int) $log_meta['_edd_log_file_id'][0];
$file_id = $file_id !== false ? $file_id : 0;
$file_name = isset($files[$file_id]['name']) ? $files[$file_id]['name'] : null;
$item = array('ID' => $log->ID, 'user_id' => $user_id, 'product_id' => $log->post_parent, 'product_name' => get_the_title($log->post_parent), 'customer_id' => $payment_customer_id, 'payment_id' => $payment_id, 'file' => $file_name, 'ip' => $ip, 'date' => $log->post_date);
$item = apply_filters('edd_api_download_log_item', $item, $log, $log_meta);
$downloads['download_logs'][] = $item;
}
return $downloads;
}
示例12: widget
/**
* 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;
}
示例13: dwqa_siteinfo_has_user_purchased
/**
* Has User Purchased
*
* Checks to see if a user has purchased a download.
*
* @access public
* @since 1.0
* @param int $user_id - the ID of the user to check
* @param array $downloads - Array of IDs to check if purchased. If an int is passed, it will be converted to an array
* @param int $variable_price_id - the variable price ID to check for
* @return boolean - true if has purchased and license is active, false otherwise
*/
function dwqa_siteinfo_has_user_purchased($user_id, $downloads, $variable_price_id = null, $verify_purchase = false)
{
$users_purchases = edd_get_users_purchases($user_id);
$return = false;
if (!is_array($downloads) && $downloads !== NULL) {
$downloads = array($downloads);
}
$now = strtotime(date('Y-m-d H:i:s'));
if ($users_purchases) {
foreach ($users_purchases as $purchase) {
$purchased_files = edd_get_payment_meta_downloads($purchase->ID);
$licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
$licenses_products = array();
if (is_array($licenses)) {
foreach ($licenses as $license) {
$download_id = get_post_meta($license->ID, '_edd_sl_download_id', true);
$status = get_post_meta($license->ID, '_edd_sl_status', true);
$expire = get_post_meta($license->ID, '_edd_sl_expiration', true);
$licenses_products[$download_id] = array();
$licenses_products[$download_id]['status'] = $status;
$licenses_products[$download_id]['expire'] = $expire;
}
} else {
return false;
}
if (is_array($purchased_files)) {
foreach ($purchased_files as $download) {
if ($downloads === NULL || in_array($download['id'], $downloads)) {
//check to see if the license is active
//echo $licenses_products[$download['id']]['expire'] . ">" . $now . "==========";
if (isset($licenses_products[$download['id']]['expire']) && $now > $licenses_products[$download['id']]['expire']) {
// || $licenses_products[$download['id']]['status'] == 'inactive'
if ($verify_purchase) {
return "purchased_expired";
} else {
return false;
}
}
$variable_prices = edd_has_variable_prices($download['id']);
if ($variable_prices && !is_null($variable_price_id) && $variable_price_id !== false) {
if (isset($download['options']['price_id']) && $variable_price_id == $download['options']['price_id']) {
return true;
} else {
return false;
}
} else {
return true;
}
}
}
}
}
}
return false;
}
示例14: edd_email_template_tags
/**
* Email Template Tags
*
* @param string $message
* @param array $payment_data
* @param int $payment_id
*
* @access private
* @since 1.0
* @return string
*/
function edd_email_template_tags($message, $payment_data, $payment_id)
{
$user_info = maybe_unserialize($payment_data['user_info']);
$fullname = '';
if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
$user_data = get_userdata($user_info['id']);
$name = $user_info['first_name'];
$fullname = $user_info['first_name'] . ' ' . $user_info['last_name'];
$username = $user_data->user_login;
} elseif (isset($user_info['first_name'])) {
$name = $user_info['first_name'];
$fullname = $user_info['first_name'] . ' ' . $user_info['last_name'];
$username = $user_info['first_name'];
} else {
$name = $user_info['email'];
$username = $user_info['email'];
}
$file_urls = '';
$download_list = '<ul>';
$downloads = edd_get_payment_meta_downloads($payment_id);
if ($downloads) {
$show_names = apply_filters('edd_email_show_names', true);
foreach ($downloads as $download) {
$id = isset($payment_data['cart_details']) ? $download['id'] : $download;
if ($show_names) {
$download_list .= '<li>' . get_the_title($id) . '<br/>';
$download_list .= '<ul>';
}
$price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
$files = edd_get_download_files($id, $price_id);
if ($files) {
foreach ($files as $filekey => $file) {
$download_list .= '<li>';
$file_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $filekey, $id);
$download_list .= '<a href="' . esc_url($file_url) . '">' . $file['name'] . '</a>';
$download_list .= '</li>';
$file_urls .= esc_html($file_url) . '<br/>';
}
}
if ($show_names) {
$download_list .= '</ul>';
}
if ('' != edd_get_product_notes($id)) {
$download_list .= ' — <small>' . edd_get_product_notes($id) . '</small>';
}
if ($show_names) {
$download_list .= '</li>';
}
}
}
$download_list .= '</ul>';
$subtotal = isset($payment_data['subtotal']) ? $payment_data['subtotal'] : $payment_data['amount'];
$subtotal = edd_currency_filter(edd_format_amount($subtotal));
$tax = isset($payment_data['tax']) ? $payment_data['tax'] : 0;
$tax = edd_currency_filter(edd_format_amount($tax));
$price = edd_currency_filter(edd_format_amount($payment_data['amount']));
$gateway = edd_get_gateway_checkout_label(get_post_meta($payment_id, '_edd_payment_gateway', true));
$receipt_id = $payment_data['key'];
$message = str_replace('{name}', $name, $message);
$message = str_replace('{fullname}', $fullname, $message);
$message = str_replace('{username}', $username, $message);
$message = str_replace('{download_list}', $download_list, $message);
$message = str_replace('{file_urls}', $file_urls, $message);
$message = str_replace('{date}', date_i18n(get_option('date_format'), strtotime($payment_data['date'])), $message);
$message = str_replace('{sitename}', get_bloginfo('name'), $message);
$message = str_replace('{subtotal}', $subtotal, $message);
$message = str_replace('{tax}', $tax, $message);
$message = str_replace('{price}', $price, $message);
$message = str_replace('{payment_method}', $gateway, $message);
$message = str_replace('{receipt_id}', $receipt_id, $message);
$message = apply_filters('edd_email_template_tags', $message, $payment_data, $payment_id);
return $message;
}
示例15: calc_user_expiration
/**
* Calculate a new expiration date
*
* @since 1.0
* @param $_customer_or_user_id INT depending on EDD Version, this is a customer or User ID
* @param $payment_id INT The original payment ID
* @return int
*/
public static function calc_user_expiration($_customer_or_user_id = 0, $payment_id = 0)
{
$edd_version = get_option('edd_version');
if (version_compare($edd_version, '2.3', '<')) {
$user_id = $_customer_or_user_id;
} else {
$user_id = self::get_user_id_from_customer_id($_customer_or_user_id);
}
// Retrieve the items purchased from the original payment
$downloads = edd_get_payment_meta_downloads($payment_id);
$download = $downloads[0];
// We only care about the first (and only) item
$period = $download['options']['recurring']['period'];
$expiration = strtotime('+ 1 ' . $period . ' 23:59:59');
return apply_filters('edd_recurring_calc_expiration', $expiration, $user_id, $payment_id, $period);
}