本文整理汇总了PHP中edd_get_payment_user_id函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_payment_user_id函数的具体用法?PHP edd_get_payment_user_id怎么用?PHP edd_get_payment_user_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_payment_user_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trigger
/**
* Trigger the tickets email
*
* @param int $payment_id
*
* @return string
*/
public function trigger($payment_id = 0)
{
global $edd_options;
$payment_data = edd_get_payment_meta($payment_id);
$user_id = edd_get_payment_user_id($payment_id);
$user_info = maybe_unserialize($payment_data['user_info']);
$email = edd_get_payment_user_email($payment_id);
if (isset($user_id) && $user_id > 0) {
$user_data = get_userdata($user_id);
$name = $user_data->display_name;
} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
} else {
$name = $email;
}
$message = $this->get_content_html($payment_id);
$from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
$from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
$subject = !empty($edd_options['ticket_subject']) ? wp_strip_all_tags($edd_options['ticket_subject'], true) : $this->default_subject;
$subject = apply_filters('edd_ticket_receipt_subject', $subject, $payment_id);
$subject = edd_email_template_tags($subject, $payment_data, $payment_id);
$headers = 'From: ' . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
$headers .= 'Reply-To: ' . $from_email . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers = apply_filters('edd_ticket_receipt_headers', $headers, $payment_id, $payment_data);
// Allow add-ons to add file attachments
$attachments = apply_filters('edd_ticket_receipt_attachments', array(), $payment_id, $payment_data);
if (apply_filters('edd_email_ticket_receipt', true)) {
wp_mail($email, $subject, $message, $headers, $attachments);
}
}
示例2: filter_reminder_template_tags
public function filter_reminder_template_tags($text = '', $license_id = 0)
{
$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'];
}
$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 = 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)));
$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;
}
示例3: 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');
}
}
}
示例4: 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');
}
}
示例5: pw_edd_give_subscription_on_purchase
function pw_edd_give_subscription_on_purchase($payment_id)
{
$user_id = edd_get_payment_user_id($payment_id);
if (empty($user_id) || $user_id < 1) {
return;
}
if (!class_exists('EDD_Recurring_Customer')) {
return;
}
$customer = new EDD_Recurring_Customer();
$customer->set_as_subscriber($user_id);
$customer->set_customer_payment_id($payment_id);
$customer->set_customer_status($user_id, 'active');
$customer->set_customer_expiration($user_id, strtotime('+1 year'));
}
示例6: edd_can_view_receipt
/**
* Determines the receipt visibility status
*
* @return bool Whether the receipt is visible or not.
*/
function edd_can_view_receipt($payment_key = '')
{
$return = false;
if (empty($payment_key)) {
return $return;
}
global $edd_receipt_args;
$edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key);
$user_id = (int) edd_get_payment_user_id($edd_receipt_args['id']);
$payment_meta = edd_get_payment_meta($edd_receipt_args['id']);
if (is_user_logged_in()) {
if ($user_id === (int) get_current_user_id()) {
$return = true;
} elseif (wp_get_current_user()->user_email === edd_get_payment_user_email($edd_receipt_args['id'])) {
$return = true;
} elseif (current_user_can('view_shop_sensitive_data')) {
$return = true;
}
}
$session = edd_get_purchase_session();
if (!empty($session) && !is_user_logged_in()) {
if ($session['purchase_key'] === $payment_meta['key']) {
$return = true;
}
}
return (bool) apply_filters('edd_can_view_receipt', $return, $payment_key);
}
示例7: edd_csau_view_order_details_upsells
/**
* Add upsells to order details screen
*
* @since 1.0
*/
function edd_csau_view_order_details_upsells($payment_id)
{
$item = get_post($payment_id);
$payment_meta = edd_get_payment_meta($payment_id);
$cart_items = edd_get_payment_meta_cart_details($payment_id);
$user_info = edd_get_payment_meta_user_info($payment_id);
$user_id = edd_get_payment_user_id($payment_id);
$payment_date = strtotime($item->post_date);
if (!get_post_meta($payment_id, '_edd_payment_upsell_total', true)) {
return;
}
?>
<div id="edd-purchased-files" class="postbox">
<h3 class="hndle"><?php
_e('Upsells included with this payment', 'edd-csau');
?>
</h3>
<div class="inside">
<table class="wp-list-table widefat fixed" cellspacing="0">
<tbody id="the-list">
<?php
if ($cart_items) {
$i = 0;
foreach ($cart_items as $key => $cart_item) {
$id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item;
$price_override = isset($payment_meta['cart_details']) ? $cart_item['price'] : null;
$price = edd_get_download_final_price($id, $user_info, $price_override);
if (!isset($cart_item['item_number']['upsell'])) {
continue;
}
?>
<tr class="<?php
if ($i % 2 == 0) {
echo 'alternate';
}
?>
">
<td class="name column-name">
<?php
echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '">' . get_the_title($id) . '</a>';
if (isset($cart_items[$key]['item_number'])) {
$price_options = $cart_items[$key]['item_number']['options'];
if (isset($price_options['price_id'])) {
echo ' - ' . edd_get_price_option_name($id, $price_options['price_id'], $payment_id);
}
}
?>
</td>
</tr>
<?php
$i++;
}
}
?>
</tbody>
</table>
</div>
</div>
<?php
}
示例8: process_paypal_subscr_eot
/**
* Processes the "end of term (eot)" IPN notice
*
* @since 1.0
* @return void
*/
public static function process_paypal_subscr_eot($ipn_data)
{
$user_id = edd_get_payment_user_id($ipn_data['custom']);
// set the customer status
EDD_Recurring_Customer::set_customer_status($user_id, 'expired');
}
示例9: edd_receipt_shortcode
/**
* Receipt Shortcode
*
* Shows an order receipt.
*
* @since 1.4
* @param array $atts Shortcode attributes
* @param string $content
* @return string
*/
function edd_receipt_shortcode($atts, $content = null)
{
global $edd_receipt_args;
$edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt');
$session = edd_get_purchase_session();
if (isset($_GET['payment_key'])) {
$payment_key = urldecode($_GET['payment_key']);
} elseif ($edd_receipt_args['payment_key']) {
$payment_key = $edd_receipt_args['payment_key'];
} else {
if ($session) {
$payment_key = $session['purchase_key'];
}
}
// No key found
if (!isset($payment_key)) {
return $edd_receipt_args['error'];
}
$edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key);
$customer_id = edd_get_payment_user_id($edd_receipt_args['id']);
/*
* Check if the user has permission to view the receipt
*
* If user is logged in, user ID is compared to user ID of ID stored in payment meta
*
* Or if user is logged out and purchase was made as a guest, the purchase session is checked for
*
* Or if user is logged in and the user can view sensitive shop data
*
*/
$user_can_view = is_user_logged_in() && $customer_id == get_current_user_id() || ($customer_id == 0 || $customer_id == '-1') && !is_user_logged_in() && edd_get_purchase_session() || current_user_can('view_shop_sensitive_data');
if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) {
return $edd_receipt_args['error'];
}
ob_start();
edd_get_template_part('shortcode', 'receipt');
$display = ob_get_clean();
return $display;
}
示例10: 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_the_author_meta('user_email', $user_id);
$payments = edd_get_payments(array('s' => $email));
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'] = $meta['user_info'];
// Store the updated user ID in the payment meta
edd_update_payment_meta($payment->ID, '_edd_payment_meta', $meta);
edd_update_payment_meta($payment->ID, '_edd_payment_user_id', $user_id);
}
}
}
示例11: process_refund
/**
* Process refunds
*
* @access public
* @since 1.0.0
* @param int $payment_id The ID of a payment
* @param string $new_status The new status of the payment
* @param string $old_status The old status of the payment
* @return void
*/
public function process_refund($payment_id, $new_status, $old_status)
{
if ($old_status != 'publish' && $old_status != 'revoked') {
return;
}
if ($new_status != 'refunded') {
return;
}
if (edd_get_payment_gateway($payment_id) !== 'wallet') {
return;
}
$user_id = edd_get_payment_user_id($payment_id);
$refund_amount = edd_get_payment_amount($payment_id);
// Deposit the funds
edd_wallet()->wallet->deposit($user_id, $refund_amount, 'refund');
// Insert payment note
edd_insert_payment_note($payment_id, __('Refund completed to Wallet.', 'edd-wallet'));
}
示例12: edd_wallet_add_funds
/**
* Add the deposited amount to the wallet after payment
*
* @since 1.0.0
* @param int $payment_id The ID of the payment
* @return void
*/
function edd_wallet_add_funds($payment_id)
{
$fees = edd_get_payment_fees($payment_id);
if ($fees && count($fees) == 1) {
if ($fees[0]['id'] == 'edd-wallet-deposit') {
// Disable purchase receipts... we send our own emails
remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999);
// Send our custom emails
edd_wallet_send_email('user', $payment_id);
// Get the ID of the purchaser
$user_id = edd_get_payment_user_id($payment_id);
// Deposit the funds
edd_wallet()->wallet->deposit($user_id, $fees[0]['amount'], 'deposit', $payment_id);
// Tag the payment so we can find it later
edd_update_payment_meta($payment_id, '_edd_wallet_deposit', $user_id);
}
}
}
示例13: edd_is_guest_payment
/**
* Is the payment provided associated with a user account
*
* @since 2.4.4
* @param int $payment_id The payment ID
* @return bool If the payment is associted with a user (false) or not (true)
*/
function edd_is_guest_payment($payment_id)
{
$payment_user_id = edd_get_payment_user_id($payment_id);
$is_guest_payment = !empty($payment_user_id) && $payment_user_id > 0 ? false : true;
return (bool) apply_filters('edd_is_guest_payment', $is_guest_payment, $payment_id);
}
示例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);
}
}
}
示例15: find_old_abandoned_carts
/**
* Find old pending carts and consider them abandoned.
* @return null
*/
public static function find_old_abandoned_carts()
{
$time = time();
$thirty_mins_ago = $time - apply_filters('find_old_abandoned_carts_mins_ago', 1800);
// a half hour
$args = array('status' => array('abandoned', 'pending'), 'start_date' => $thirty_mins_ago, 'end_date' => $time);
$pending_payments = new EDD_Payments_Query($args);
$payments = $pending_payments->get_payments();
if (empty($payments)) {
return;
}
foreach ($payments as $payment) {
$payment_id = $payment->ID;
$user_id = edd_get_payment_user_id($payment_id);
$uid = EDD_Segment_Identity::get_uid_from_user_id($user_id);
$meta = edd_get_payment_meta($payment_id);
// Adding an event for each item
foreach ($meta['cart_details'] as $key => $item_details) {
$item_details = array_merge($item_details, array('time' => time()));
do_action('edd_segment_track', $uid, 'Abandoned Cart', $item_details);
}
}
}