本文整理汇总了PHP中edd_get_payment_customer_id函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_payment_customer_id函数的具体用法?PHP edd_get_payment_customer_id怎么用?PHP edd_get_payment_customer_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_payment_customer_id函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 = absint($data['purchase_id']);
if (empty($purchase_id)) {
return;
}
if (!current_user_can('edit_shop_payments')) {
wp_die(__('You do not have permission to edit this payment record', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
}
$email = !empty($_GET['email']) ? sanitize_text_field($_GET['email']) : '';
if (empty($email)) {
$customer = new EDD_Customer(edd_get_payment_customer_id($purchase_id));
$email = $customer->email;
}
edd_email_purchase_receipt($purchase_id, false, $email);
// 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_cart_details($purchase_id, true);
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;
}
示例2: send_renewal_reminder
public function send_renewal_reminder($license_id = 0, $notice_id = 0)
{
global $edd_options;
if (empty($license_id)) {
return;
}
$send = true;
$license = get_post($license_id);
$send = apply_filters('edd_sl_send_renewal_reminder', $send, $license_id, $notice_id);
if (!$license || 'edd_license' != $license->post_type || !$send || !empty($license->post_parent)) {
return;
}
$customer = false;
if (class_exists('EDD_Customer')) {
$payment_id = get_post_meta($license->ID, '_edd_sl_payment_id', true);
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
}
if (empty($customer->id)) {
// Remove the post title to get just the email
$title = $license->post_title;
$title_pos = strpos($title, '-') + 1;
$length = strlen($title);
$email_to = substr($title, $title_pos, $length);
}
$email_to = !empty($customer->id) ? $customer->email : $email_to;
$notice = edd_sl_get_renewal_notice($notice_id);
$message = !empty($notice['message']) ? $notice['message'] : __("Hello {name},\n\nYour license key for {product_name} is about to expire.\n\nIf you wish to renew your license, simply click the link below and follow the instructions.\n\nYour license expires on: {expiration}.\n\nYour expiring license key is: {license_key}.\n\nRenew now: {renewal_link}.", "edd_sl");
$message = $this->filter_reminder_template_tags($message, $license_id);
$subject = !empty($notice['subject']) ? $notice['subject'] : __('Your License Key is About to Expire', 'edd_sl');
$subject = $this->filter_reminder_template_tags($subject, $license_id);
$message = stripslashes($message);
$subject = stripslashes($subject);
if (class_exists('EDD_Emails')) {
$sent = EDD()->emails->send($email_to, $subject, $message);
} else {
$from_name = get_bloginfo('name');
$from_email = get_bloginfo('admin_email');
$headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
$headers .= "Reply-To: " . $from_email . "\r\n";
$sent = wp_mail($email_to, $subject, $message, $headers);
}
if ($sent) {
$log_id = wp_insert_post(array('post_title' => __('LOG - Renewal Notice Sent', 'edd_sl'), 'post_name' => 'log-notice-sent-' . $license_id . '-' . md5(time()), 'post_type' => 'edd_license_log', 'post_status' => 'publish'));
add_post_meta($log_id, '_edd_sl_log_license_id', $license_id);
add_post_meta($log_id, '_edd_sl_renewal_notice_id', (int) $notice_id);
wp_set_object_terms($log_id, 'renewal_notice', 'edd_log_type', false);
add_post_meta($license_id, sanitize_key('_edd_sl_renewal_sent_' . $notice['send_period']), time());
// Prevent renewal notices from being sent more than once
}
}
示例3: get_data
/**
* Get the Export Data
*
* @access public
* @since 2.4
* Database API
* @global object $edd_logs EDD Logs Object
* @return array $data The data for the CSV file
*/
public function get_data()
{
$data = array();
if (!empty($this->download)) {
// Export customers of a specific product
global $edd_logs;
$args = array('post_parent' => absint($this->download), 'log_type' => 'sale', 'posts_per_page' => 30, 'paged' => $this->step);
if (null !== $this->price_id) {
$args['meta_query'] = array(array('key' => '_edd_log_price_id', 'value' => (int) $this->price_id));
}
$logs = $edd_logs->get_connected_logs($args);
if ($logs) {
foreach ($logs as $log) {
$payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true);
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
$data[] = array('id' => $customer->id, 'name' => $customer->name, 'email' => $customer->email, 'purchases' => $customer->purchase_count, 'amount' => edd_format_amount($customer->purchase_value));
}
}
} else {
// Export all customers
$offset = 30 * ($this->step - 1);
$customers = EDD()->customers->get_customers(array('number' => 30, 'offset' => $offset));
$i = 0;
foreach ($customers as $customer) {
$data[$i]['id'] = $customer->id;
$data[$i]['name'] = $customer->name;
$data[$i]['email'] = $customer->email;
$data[$i]['purchases'] = $customer->purchase_count;
$data[$i]['amount'] = edd_format_amount($customer->purchase_value);
$i++;
}
}
$data = apply_filters('edd_export_get_data', $data);
$data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
return $data;
}
示例4: column_customer
/**
* Render the Customer Column
*
* @access public
* @since 2.4.3
* @param array $payment Contains all the data of the payment
* @return string Data shown in the User column
*/
public function column_customer($payment)
{
$customer_id = edd_get_payment_customer_id($payment->ID);
if (!empty($customer_id)) {
$customer = new EDD_Customer($customer_id);
$value = '<a href="' . esc_url(admin_url("edit.php?post_type=download&page=edd-customers&view=overview&id={$customer_id}")) . '">' . $customer->name . '</a>';
} else {
$email = edd_get_payment_user_email($payment->ID);
$value = '<a href="' . esc_url(admin_url("edit.php?post_type=download&page=edd-payment-history&s={$email}")) . '">' . __('(customer missing)', 'easy-digital-downloads') . '</a>';
}
return apply_filters('edd_payments_table_column', $value, $payment->ID, 'user');
}
示例5: do_action
<?php
do_action('edd_view_order_details_billing_before', $payment_id);
?>
<div id="edd-customer-details" class="postbox">
<h3 class="hndle">
<span><?php
_e('Customer Details', 'edd');
?>
</span>
</h3>
<div class="inside edd-clearfix">
<?php
$customer = new EDD_Customer(edd_get_payment_customer_id($payment_id));
?>
<div class="column-container customer-info">
<div class="column">
<?php
echo EDD()->html->customer_dropdown(array('selected' => $customer->id, 'name' => 'customer-id'));
?>
</div>
<div class="column">
<input type="hidden" name="edd-current-customer" value="<?php
echo $customer->id;
?>
" />
</div>
<div class="column">
示例6: edd_undo_purchase_on_refund
/**
* Reduces earnings and sales stats when a purchase is refunded
*
* @since 1.8.2
* @param $data Arguments passed
* @return void
*/
function edd_undo_purchase_on_refund($payment_id, $new_status, $old_status)
{
if ('publish' != $old_status && 'revoked' != $old_status) {
return;
}
if ('refunded' != $new_status) {
return;
}
$downloads = edd_get_payment_meta_cart_details($payment_id);
if ($downloads) {
foreach ($downloads as $download) {
edd_undo_purchase($download['id'], $payment_id);
}
}
// Decrease store earnings
$amount = edd_get_payment_amount($payment_id);
edd_decrease_total_earnings($amount);
// Decrement the stats for the customer
$customer_id = edd_get_payment_customer_id($payment_id);
if ($customer_id) {
$customer = new EDD_Customer($customer_id);
$customer->decrease_value($amount);
$customer->decrease_purchase_count();
}
// Clear the This Month earnings (this_monththis_month is NOT a typo)
delete_transient(md5('edd_earnings_this_monththis_month'));
}
示例7: update_licenses_on_payment_update
/**
* Updates license details when a payment is updated
*
* @param int $payment_id
* @return void
*/
public function update_licenses_on_payment_update($payment_id)
{
if (version_compare(EDD_VERSION, '2.3', '>=')) {
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
$user_id = $customer->user_id;
$new_email = $customer->email;
} else {
$user_id = intval($_POST['edd-payment-user-id']);
$new_email = sanitize_text_field($_POST['edd-payment-user-email']);
}
$licenses = self::get_licenses_of_purchase($payment_id);
if ($licenses) {
foreach ($licenses as $license) {
// Update our user IDs
update_post_meta($license->ID, '_edd_sl_user_id', $user_id);
// Update the email address
$title = $license->post_title;
$args = array_map('trim', explode('-', $title));
$title_pos = strpos($title, '-') + 1;
$length = strlen($title);
$email = substr($title, $title_pos, $length);
if (!$email || $email != $new_email) {
$new_title = $args[0] . ' - ' . $new_email;
$post_args = array('ID' => $license->ID, 'post_title' => $new_title);
wp_update_post($post_args);
}
}
}
}
示例8: 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;
}
示例9: edd_delete_purchase
/**
* Deletes a Purchase
*
* @since 1.0
* @global $edd_logs
*
* @uses EDD_Logging::delete_logs()
*
* @param int $payment_id Payment ID (default: 0)
* @param bool $update_customer If we should update the customer stats (default:true)
* @param bool $delete_download_logs If we should remove all file download logs associated with the payment (default:false)
*
* @return void
*/
function edd_delete_purchase($payment_id = 0, $update_customer = true, $delete_download_logs = false)
{
global $edd_logs;
$post = get_post($payment_id);
if (!$post) {
return;
}
$downloads = edd_get_payment_meta_downloads($payment_id);
if (is_array($downloads)) {
// Update sale counts and earnings for all purchased products
foreach ($downloads as $download) {
edd_undo_purchase($download['id'], $payment_id);
}
}
$amount = edd_get_payment_amount($payment_id);
$status = $post->post_status;
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
if ($status == 'revoked' || $status == 'publish') {
// Only decrease earnings if they haven't already been decreased (or were never increased for this payment)
edd_decrease_total_earnings($amount);
// Clear the This Month earnings (this_monththis_month is NOT a typo)
delete_transient(md5('edd_earnings_this_monththis_month'));
if ($customer->id && $update_customer) {
// Decrement the stats for the customer
$customer->decrease_purchase_count();
$customer->decrease_value($amount);
}
}
do_action('edd_payment_delete', $payment_id);
if ($customer->id && $update_customer) {
// Remove the payment ID from the customer
$customer->remove_payment($payment_id);
}
// Remove the payment
wp_delete_post($payment_id, true);
// Remove related sale log entries
$edd_logs->delete_logs(null, 'sale', array(array('key' => '_edd_log_payment_id', 'value' => $payment_id)));
if ($delete_download_logs) {
$edd_logs->delete_logs(null, 'file_download', array(array('key' => '_edd_log_payment_id', 'value' => $payment_id)));
}
do_action('edd_payment_deleted', $payment_id);
}
示例10: fire_drip_expired_event
public function fire_drip_expired_event($license_id = 0, $period = null)
{
// global $edd_options;
if (empty($license_id) || empty($period) || !class_exists('edd_software_licensing')) {
return;
}
//fetch the license
$license = get_post($license_id);
if (!$license || 'edd_license' != $license->post_type || !empty($license->post_parent)) {
return;
}
//error_log(var_export($license,true));
$customer = false;
if (class_exists('EDD_Customer')) {
$payment_id = get_post_meta($license->ID, '_edd_sl_payment_id', true);
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
}
//error_log(var_export($customer,true));
//IF the customer ID is empty then use the payment to get the email info
if (empty($customer->id)) {
// Remove the post title to get just the email
$title = $license->post_title;
$title_pos = strpos($title, '-') + 1;
$length = strlen($title);
$email_to = substr($title, $title_pos, $length);
}
//Get the email.
$customer_email = !empty($customer->id) ? $customer->email : $email_to;
$customer_name = !empty($customer->id) ? $customer->name : null;
//default to null
// $payment_id = get_post_meta( $license_id, '_edd_sl_payment_id', true );
// $user_info = edd_get_payment_meta_user_info( $payment_id );
// $user_id = edd_get_payment_user_id( $payment_id );
//
// // Retrieve the customer name
// if ( $user_id ) {
// $user_data = get_userdata( $user_id );
// $customer_name = $user_data->display_name;
// } elseif ( isset( $user_info['first_name'] ) ) {
// $customer_name = $user_info['first_name'];
// } else {
// $customer_name = $user_info['email'];
// }
//These are custom fields on customer
$license_key = edd_software_licensing()->get_license_key($license_id);
$download_id = get_post_meta($license_id, '_edd_sl_download_id', true);
$product_name = get_the_title($download_id);
$expiration = edd_software_licensing()->get_license_expiration($license_id);
$expiration = date(get_option('date_format'), $expiration);
$discount_percent = edd_sl_get_renewal_discount_percentage($license_id);
$renewal_link = apply_filters('edd_sl_renewal_link', edd_get_checkout_uri(array('edd_license_key' => $license_key, 'download_id' => $download_id)));
//Fire the event
error_log('FIRE DRIP EVENT:' . $period . '-' . $license_id);
error_log($customer_name);
error_log($license_key);
error_log($product_name);
error_log($expiration);
error_log($discount_percent);
error_log($renewal_link);
return true;
$text = str_replace('{name}', $customer_name, $text);
$text = str_replace('{license_key}', $license_key, $text);
$text = str_replace('{product_name}', $product_name, $text);
$text = str_replace('{expiration}', $expiration, $text);
if (!empty($discount)) {
$text = str_replace('{renewal_discount}', $discount . '%', $text);
}
$text = str_replace('{renewal_link}', $renewal_link, $text);
return $text;
return false;
// $message = $this->filter_reminder_template_tags( $message, $license_id );
//
// $subject = ! empty( $notice['subject'] ) ? $notice['subject'] : __( 'Your License Key is About to Expire', 'edd_sl' );
// $subject = $this->filter_reminder_template_tags( $subject, $license_id );
if ($sent) {
$log_id = wp_insert_post(array('post_title' => __('LOG - Renewal Drip Event Fired', 'edd_sl'), 'post_name' => 'log-notice-sent-' . $license_id . '-' . md5(time()), 'post_type' => 'edd_license_log', 'post_status' => 'publish'));
//'_edd_drip_sl_renewal_sent_
add_post_meta($log_id, '_edd_sl_log_license_id', $license_id);
add_post_meta($log_id, '_edd_sl_renewal_notice_id', (int) $notice_id);
wp_set_object_terms($log_id, 'renewal_notice', 'edd_log_type', false);
add_post_meta($license_id, sanitize_key('_edd_drip_sl_renewal_sent_' . $notice['send_period']), time());
// Prevent renewal notices from being sent more than once
}
}
示例11: column_customer
/**
* Render the Customer Column
*
* @access public
* @since 2.4.3
* @param array $payment Contains all the data of the payment
* @return string Data shown in the User column
*/
public function column_customer($payment)
{
$customer_id = edd_get_payment_customer_id($payment->ID);
$customer = new EDD_Customer($customer_id);
$value = '<a href="' . esc_url(add_query_arg(array('user' => urlencode($customer->email), 'paged' => false))) . '">' . $customer->name . '</a>';
return apply_filters('edd_payments_table_column', $value, $payment->ID, 'user');
}
示例12: edd_get_payment_user_id
/**
* Get the user ID associated with a payment
*
* @since 1.5.1
* @param int $payment_id Payment ID
* @return string $user_id User ID
*/
function edd_get_payment_user_id($payment_id)
{
$user_id = -1;
// check the customer record first
$customer_id = edd_get_payment_customer_id($payment_id);
$customer = new EDD_Customer($customer_id);
if (!empty($customer->user_id) && $customer->user_id > 0) {
$user_id = $customer->user_id;
}
// check the payment meta if we're still not finding a user with the customer record
if (empty($user_id) || $user_id < 1) {
$payment_meta_user_id = edd_get_payment_meta($payment_id, '_edd_payment_user_id', true);
if (!empty($payment_meta_user_id)) {
$user_id = $payment_meta_user_id;
}
}
// Last ditch effort is to connect payment email with a user in the user table
if (empty($user_id) || $user_id < 1) {
$payment_email = edd_get_payment_user_email($payment_id);
$user = get_user_by('email', $payment_email);
if (false !== $user) {
$user_id = $user->ID;
}
}
return apply_filters('edd_payment_user_id', (int) $user_id);
}
示例13: new_purchase
/**
* Runs once a purchase is completed.
*
* If NOD is enabled, store the purchase details into an array we can use during the offer email schedule
*
* @hook edd_complete_download_purchase
* @params int $payment_id Required: Payment ID
*
* @return void
*/
public function new_purchase($payment_id)
{
// Exit here if the plugin is not enabled
if (empty(EDD_NOD()->settings) || empty(EDD_NOD()->settings->enable)) {
return;
}
$downloads = edd_get_payment_meta_downloads($payment_id);
$payment_data = edd_get_payment_meta($payment_id);
// Check for download and payment data
if (empty($downloads) || empty($payment_data)) {
return;
}
// If this purchase is not eligible for NOD offers, exit
if (!edd_nod_download_is_eligible($downloads)) {
return;
}
// If we do not apply offers to free downloads, check here
$price = get_post_meta($payment_id, '_edd_payment_total', true);
if (empty(EDD_NOD()->settings->free)) {
if (empty($price) || $price < '1') {
return;
}
}
// If there is a minimum spend, check here
$min = EDD_NOD()->settings->min_spend;
if (!empty($min) && $min < get_post_meta($payment_id, '_edd_payment_total', true)) {
return;
}
// Check if the customer is eligible for a NOD offer.
$customer_id = edd_get_payment_customer_id($payment_id);
if (empty($customer_id)) {
return;
}
$customer = new EDD_Customer($customer_id);
if (!$customer || !edd_nod_purchase_qualifies($customer->purchase_count)) {
return;
}
// Before adding the new NOD
do_action('nod_before_register', $payment_id, $customer_id, $downloads);
// Add this download to our pending offers array
$valid_from = date('Y-m-d H:i:s', strtotime("+" . EDD_NOD()->settings->send_after));
$this->add_nod(array('download_id' => $downloads, 'payment_id' => $payment_id, 'customer_id' => $customer_id, 'total_cost' => edd_get_payment_amount($payment_id), 'send_offer' => date('Y-m-d H:i:s', strtotime("+" . EDD_NOD()->settings->send_after))));
// After adding the new NOD
do_action('nod_after_register', $payment_id, $customer_id, $downloads);
}