本文整理汇总了PHP中edd_get_price_option_name函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_price_option_name函数的具体用法?PHP edd_get_price_option_name怎么用?PHP edd_get_price_option_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_price_option_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_data
/**
* 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;
}
示例2: licenses_tag
public function licenses_tag($payment_id = 0)
{
$keys_output = '';
$license_keys = edd_software_licensing()->get_licenses_of_purchase($payment_id);
if ($license_keys) {
foreach ($license_keys as $key) {
$price_name = '';
$download_id = edd_software_licensing()->get_download_id($key->ID);
$price_id = edd_software_licensing()->get_price_id($key->ID);
if ($price_id) {
$price_name = " - " . edd_get_price_option_name($download_id, $price_id);
}
$keys_output .= get_the_title($download_id) . $price_name . ": " . get_post_meta($key->ID, '_edd_sl_key', true) . "\n\r";
}
}
return $keys_output;
}
示例3: edd_customerio_connect_register_user
/**
* Track new users
*
* @since 1.0.0
* @param int $payment_id The ID of a given payment
* @return void
*/
function edd_customerio_connect_register_user($payment_id)
{
// Bail if API isn't setup
if (!edd_customerio_connect()->api) {
return;
}
// Setup the request body
$user_info = edd_get_payment_meta_user_info($payment_id);
$payment_meta = edd_get_payment_meta($payment_id);
$cart_items = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
$user_name = false;
if ($payment_meta['user_info']['first_name']) {
$user_name = $payment_meta['user_info']['first_name'];
if ($payment_meta['user_info']['last_name']) {
$user_name .= ' ' . $payment_meta['user_info']['last_name'];
}
}
$body = array('email' => $payment_meta['user_info']['email'], 'created_at' => $payment_meta['date']);
if ($user_name) {
$body['name'] = $user_name;
}
$response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body);
// Track the purchases
if (empty($cart_items) || !$cart_items) {
$cart_items = maybe_unserialize($payment_meta['downloads']);
}
if ($cart_items) {
$body = array('name' => 'purchased', 'data' => array('discount' => $payment_meta['user_info']['discount']));
foreach ($cart_items as $key => $cart_item) {
$item_id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item;
$price = $cart_item['price'];
$body['data']['items'][$cart_item['id']] = array('price' => $price, 'product_id' => $cart_item['id'], 'product_name' => esc_attr($cart_item['name']));
if (edd_has_variable_prices($cart_item['id'])) {
$body['data']['items'][$cart_item['id']]['price_id'] = $cart_item['item_number']['options']['price_id'];
$body['data']['items'][$cart_item['id']]['price_name'] = edd_get_price_option_name($cart_item['id'], $cart_item['item_number']['options']['price_id']);
$body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['item_number']['quantity'];
} else {
$body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['quantity'];
}
if (edd_use_taxes()) {
$body['data']['items'][$cart_item['id']]['tax'] = $cart_item['tax'];
}
}
$response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body, 'POST', 'events');
}
}
示例4: edd_sl_show_keys_on_receipt
/**
* Display license keys on the [edd_receipt] short code
*
* @access private
* @since 1.3.6
* @return void
*/
function edd_sl_show_keys_on_receipt($payment, $edd_receipt_args)
{
if (empty($payment) || empty($payment->ID)) {
return;
}
$licensing = edd_software_licensing();
$licenses = $licensing->get_licenses_of_purchase($payment->ID);
if (!empty($licenses)) {
echo '<tr class="edd_license_keys">';
echo '<td colspan="2"><strong>' . __('License Keys:', 'edd_sl') . '</strong></td>';
echo '</tr>';
foreach ($licenses as $license) {
echo '<tr class="edd_license_key">';
$key = $licensing->get_license_key($license->ID);
$download = $licensing->get_download_id($license->ID);
$price_id = $licensing->get_price_id($license->ID);
echo '<td>';
echo '<span class="edd_sl_license_title">' . get_the_title($download) . '</span> ';
if ('' !== $price_id) {
echo '<span class="edd_sl_license_price_option">– ' . edd_get_price_option_name($download, $price_id) . '</span>';
}
if ('expired' == $licensing->get_license_status($license->ID)) {
echo '<span class="edd_sl_license_key_expired"> (' . __('expired', 'edd_sl') . ')</span>';
} elseif ('draft' == $license->post_status) {
echo '<span class="edd_sl_license_key_revoked"> (' . __('revoked', 'edd_sl') . ')</span>';
}
echo '</td>';
if ($license) {
echo '<td>';
echo '<span class="edd_sl_license_key">' . $key . '</span>';
echo '</td>';
} else {
echo '<td><span class="edd_sl_license_key edd_sl_none">' . __('none', 'edd_sl') . '</span></td>';
}
echo '</tr>';
}
}
}
示例5: do_action
?>
<?php
do_action('edd_helpscout_before_order_downloads', $order, $downloads);
?>
<ul class="unstyled">
<?php
foreach ($order['downloads'] as $download) {
?>
<li>
<strong><?php
echo get_the_title($download['id']);
?>
</strong><br />
<?php
echo edd_get_price_option_name($download['id'], $download['options']['price_id']);
?>
<?php
do_action('edd_helpscout_before_order_download_details', $order, $download);
?>
<?php
if (!empty($download['license'])) {
$license = $download['license'];
?>
<?php
do_action('edd_helpscout_before_order_download_license', $order, $download, $license);
?>
示例6: edd_dashboard_sales_widget
//.........这里部分代码省略.........
?>
"><?php
_e('View Order Details', 'edd');
?>
</a>
<div id="purchased-files-<?php
echo $payment->ID;
?>
" style="display:none;">
<?php
$cart_items = edd_get_payment_meta_cart_details($payment->ID);
if (empty($cart_items) || !$cart_items) {
$cart_items = maybe_unserialize($payment_meta['downloads']);
}
?>
<h4><?php
echo _n(__('Purchased File', 'edd'), __('Purchased Files', 'edd'), count($cart_items));
?>
</h4>
<ul class="purchased-files-list">
<?php
if ($cart_items) {
foreach ($cart_items as $key => $cart_item) {
echo '<li>';
$id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item;
$price_override = isset($payment_meta['cart_details']) ? $cart_item['price'] : null;
$user_info = edd_get_payment_meta_user_info($payment->ID);
$price = edd_get_download_final_price($id, $user_info, $price_override);
echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '" target="_blank">' . get_the_title($id) . '</a>';
echo ' - ';
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']);
echo ' - ';
}
}
echo edd_currency_filter(edd_format_amount($price));
echo '</li>';
}
}
?>
</ul>
<?php
$payment_date = strtotime($payment->post_date);
?>
<p><?php
echo __('Date and Time:', 'edd') . ' ' . date_i18n(get_option('date_format'), $payment_date) . ' ' . date_i18n(get_option('time_format'), $payment_date);
?>
<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(edd_format_amount(edd_get_payment_amount($payment->ID)));
?>
</p>
<div class="purcase-personal-details">
<h4><?php
_e('Buyer\'s Personal Details:', 'edd');
?>
示例7: edd_cr_user_can_access
/**
* Check to see if a user has access to a post/page
*
* @since 2.0
* @param int $user_id The ID of the user to check
* @param array $restricted_to The array of downloads for a post/page
* @param int $post_id The ID of the object we are viewing
* @return array $return An array containing the status and optional message
*/
function edd_cr_user_can_access($user_id = false, $restricted_to, $post_id = false)
{
$has_access = false;
$restricted_count = count($restricted_to);
$products = array();
// If no user is given, use the current user
if (!$user_id) {
$user_id = get_current_user_id();
}
// bbPress specific checks. Moderators can see everything
if (class_exists('bbPress') && current_user_can('moderate')) {
$has_access = true;
}
// Admins have full access
if (current_user_can('manage_options')) {
$has_access = true;
}
// The post author can always access
if ($post_id && current_user_can('edit_post', $post_id)) {
$has_access = true;
}
if ($restricted_to && !$has_access) {
foreach ($restricted_to as $item => $data) {
if (empty($data['download'])) {
$has_access = true;
}
// The author of a download always has access
if ((int) get_post_field('post_author', $data['download']) === (int) $user_id && is_user_logged_in()) {
$has_access = true;
break;
}
// If restricted to any customer and user has purchased something
if ('any' === $data['download'] && edd_has_purchases($user_id) && is_user_logged_in()) {
$has_access = true;
break;
} elseif ('any' === $data['download']) {
$products[0] = __('any product', 'edd-cr');
$has_access = false;
break;
}
// Check for variable prices
if (!$has_access) {
if (edd_has_variable_prices($data['download'])) {
if (strtolower($data['price_id']) !== 'all' && !empty($data['price_id'])) {
$products[] = '<a href="' . get_permalink($data['download']) . '">' . get_the_title($data['download']) . ' - ' . edd_get_price_option_name($data['download'], $data['price_id']) . '</a>';
if (edd_has_user_purchased($user_id, $data['download'], $data['price_id'])) {
$has_access = true;
}
} else {
$products[] = '<a href="' . get_permalink($data['download']) . '">' . get_the_title($data['download']) . '</a>';
if (edd_has_user_purchased($user_id, $data['download'])) {
$has_access = true;
}
}
} else {
$products[] = '<a href="' . get_permalink($data['download']) . '">' . get_the_title($data['download']) . '</a>';
if (is_user_logged_in() && edd_has_user_purchased($user_id, $data['download'])) {
$has_access = true;
}
}
}
}
if ($has_access == false) {
if ($restricted_count > 1) {
$message = __('This content is restricted to buyers of:', 'edd-cr');
if (!empty($products)) {
$message .= '<ul>';
foreach ($products as $id => $product) {
$message .= '<li>' . $product . '</li>';
}
$message .= '</ul>';
}
} else {
$message = sprintf(__('This content is restricted to buyers of %s.', 'edd-cr'), $products[0]);
}
}
if (isset($message)) {
$return['message'] = $message;
} else {
$return['message'] = __('This content is restricted to buyers.', 'edd-cr');
}
} else {
// Just in case we're checking something unrestricted...
$has_access = true;
}
// Allow plugins to modify the restriction requirements
$has_access = apply_filters('edd_cr_user_can_access', $has_access, $user_id, $restricted_to);
$return['status'] = $has_access;
return $return;
}
示例8: edd_pre_approval_emails_get_download_list
/**
* Get a list of downloads from the payment meta
*
* @since 1.0
*/
function edd_pre_approval_emails_get_download_list($payment_data = array())
{
$download_list = '';
$downloads = maybe_unserialize($payment_data['downloads']);
if (is_array($downloads)) {
foreach ($downloads as $download) {
$id = isset($payment_data['cart_details']) ? $download['id'] : $download;
$title = get_the_title($id);
if (isset($download['options'])) {
if (isset($download['options']['price_id'])) {
$title .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id);
}
}
$download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n";
}
}
return $download_list;
}
示例9: edd_get_sale_notification_body_content
/**
* Sale Notification Template Body
*
* @since 1.7
* @author Daniel J Griffiths
* @param int $payment_id Payment ID
* @param array $payment_data Payment Data
* @return string $email_body Body of the email
*/
function edd_get_sale_notification_body_content($payment_id = 0, $payment_data = array())
{
global $edd_options;
$user_info = maybe_unserialize($payment_data['user_info']);
$email = edd_get_payment_user_email($payment_id);
if (isset($user_info['id']) && $user_info['id'] > 0) {
$user_data = get_userdata($user_info['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;
}
$download_list = '';
$downloads = maybe_unserialize($payment_data['downloads']);
if (is_array($downloads)) {
foreach ($downloads as $download) {
$id = isset($payment_data['cart_details']) ? $download['id'] : $download;
$title = get_the_title($id);
if (isset($download['options'])) {
if (isset($download['options']['price_id'])) {
$title .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id);
}
}
$download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n";
}
}
$gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true));
$default_email_body = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n";
$default_email_body .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n";
$default_email_body .= $download_list . "\n\n";
$default_email_body .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
$default_email_body .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8') . "\n";
$default_email_body .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n";
$default_email_body .= __('Thank you', 'edd');
$email = isset($edd_options['sale_notification']) ? stripslashes($edd_options['sale_notification']) : $default_email_body;
//$email_body = edd_email_template_tags( $email, $payment_data, $payment_id, true );
$email_body = edd_do_email_tags($email, $payment_id);
return apply_filters('edd_sale_notification', wpautop($email_body), $payment_id, $payment_data);
}
示例10: 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;
}
示例11: get_recent_sales
/**
* Retrieves Recent Sales
*
* @access public
* @since 1.5
* @return array
*/
public function get_recent_sales()
{
$sales = array();
$query = edd_get_payments(array('number' => $this->per_page(), 'page' => $this->get_paged(), 'status' => 'publish'));
if ($query) {
$i = 0;
foreach ($query as $payment) {
$payment_meta = edd_get_payment_meta($payment->ID);
$user_info = edd_get_payment_meta_user_info($payment->ID);
$cart_items = edd_get_payment_meta_cart_details($payment->ID);
$sales['sales'][$i]['ID'] = $payment->ID;
$sales['sales'][$i]['key'] = edd_get_payment_key($payment->ID);
$sales['sales'][$i]['subtotal'] = edd_get_payment_subtotal($payment->ID);
$sales['sales'][$i]['tax'] = edd_get_payment_tax($payment->ID);
$sales['sales'][$i]['fees'] = edd_get_payment_fees($payment->ID);
$sales['sales'][$i]['total'] = edd_get_payment_amount($payment->ID);
$sales['sales'][$i]['gateway'] = edd_get_payment_gateway($payment->ID);
$sales['sales'][$i]['email'] = edd_get_payment_user_email($payment->ID);
$sales['sales'][$i]['date'] = $payment->post_date;
$sales['sales'][$i]['products'] = array();
$c = 0;
foreach ($cart_items as $key => $item) {
$price_override = isset($payment_meta['cart_details']) ? $item['price'] : null;
$price = edd_get_download_final_price($item['id'], $user_info, $price_override);
if (isset($cart_items[$key]['item_number'])) {
$price_name = '';
$price_options = $cart_items[$key]['item_number']['options'];
if (isset($price_options['price_id'])) {
$price_name = edd_get_price_option_name($item['id'], $price_options['price_id'], $payment->ID);
}
}
$sales['sales'][$i]['products'][$c]['name'] = get_the_title($item['id']);
$sales['sales'][$i]['products'][$c]['price'] = $price;
$sales['sales'][$i]['products'][$c]['price_name'] = $price_name;
$c++;
}
$i++;
}
}
return $sales;
}
示例12: email_receipt
public function email_receipt($title, $item_id, $price_id)
{
if ($this->is_osgi_licenced($item_id)) {
$title = get_the_title($item_id);
if ($price_id !== false) {
$title .= " " . edd_get_price_option_name($item_id, $price_id);
}
}
return $title;
}
示例13: edd_sl_process_license_upgrade
//.........这里部分代码省略.........
$bundle_licensing = (bool) get_post_meta($download_id, '_edd_sl_enabled', true);
$parent_license_id = 0;
$activation_limit = false;
$user_info = edd_get_payment_meta_user_info($payment_id);
if ($bundle_licensing) {
$downloads[] = $download_id;
}
$downloads = array_merge($downloads, edd_get_bundled_products($download_id));
if (edd_has_variable_prices($download_id)) {
$activation_limit = edd_software_licensing()->get_price_activation_limit($download_id, $cart_item['item_number']['options']['price_id']);
$is_lifetime = edd_software_licensing()->get_price_is_lifetime($download_id, $cart_item['item_number']['options']['price_id']);
}
foreach ($downloads as $d_id) {
if ((int) $d_id === (int) $old_download_id) {
continue;
}
if (!get_post_meta($d_id, '_edd_sl_enabled', true)) {
continue;
}
$license_title = get_the_title($d_id) . ' - ' . $user_info['email'];
$license_args = array('post_type' => 'edd_license', 'post_title' => $license_title, 'post_status' => 'publish', 'post_date' => get_post_field('post_date', $payment_id, 'raw'));
if ($parent_license_id) {
$license_args['post_parent'] = $parent_license_id;
}
$l_id = wp_insert_post(apply_filters('edd_sl_insert_license_args', $license_args));
if ($bundle_licensing && $download_id == $d_id && !$parent_license_id) {
$parent_license_id = $l_id;
}
$license_key = edd_software_licensing()->get_new_download_license_key($d_id);
if (!$license_key) {
// No predefined license key available, generate a random one
$license_key = edd_software_licensing()->generate_license_key($l_id, $d_id, $payment_id, $cart_index);
}
$price_id = isset($cart_item['item_number']['options']['price_id']) ? (int) $cart_item['item_number']['options']['price_id'] : false;
add_post_meta($l_id, '_edd_sl_download_id', $d_id);
if (false !== $price_id) {
add_post_meta($l_id, '_edd_sl_download_price_id', $price_id);
}
add_post_meta($l_id, '_edd_sl_cart_index', $cart_index);
add_post_meta($l_id, '_edd_sl_payment_id', $payment_id);
add_post_meta($l_id, '_edd_sl_key', $license_key);
add_post_meta($l_id, '_edd_sl_user_id', $user_info['id']);
add_post_meta($l_id, '_edd_sl_status', 'inactive');
add_post_meta($l_id, '_edd_sl_site_count', 0);
if ($parent_license_id && !empty($activation_limit)) {
add_post_meta($l_id, '_edd_sl_limit', $activation_limit);
}
// Get license length
$license_length = edd_software_licensing()->get_license_length($l_id, $payment_id, $d_id);
if (empty($is_lifetime) && 'lifetime' !== $license_length) {
// Set license expiration date
delete_post_meta($l_id, '_edd_sl_is_lifetime');
edd_software_licensing()->set_license_expiration($l_id, strtotime($license_length, strtotime($purchase_date)));
} else {
edd_software_licensing()->set_license_as_lifetime($l_id);
}
do_action('edd_sl_store_license', $l_id, $d_id, $payment_id, $type);
}
// Now update the original license
wp_update_post(array('ID' => $license_id, 'post_parent' => $parent_license_id));
update_post_meta($license_id, '_edd_sl_cart_index', $cart_index);
add_post_meta($license_id, '_edd_sl_payment_id', $payment_id);
} else {
// Standard license upgrade
$new_title = get_the_title($download_id) . ' - ' . edd_get_payment_user_email($payment_id);
wp_update_post(array('ID' => $license_id, 'post_title' => $new_title));
update_post_meta($license_id, '_edd_sl_cart_index', $cart_index);
add_post_meta($license_id, '_edd_sl_payment_id', $payment_id);
update_post_meta($license_id, '_edd_sl_download_id', $download_id);
if (edd_has_variable_prices($download_id)) {
$limit = edd_software_licensing()->get_price_activation_limit($download_id, $upgrade['price_id']);
$is_lifetime = edd_software_licensing()->get_price_is_lifetime($download_id, $upgrade['price_id']);
update_post_meta($license_id, '_edd_sl_download_price_id', $upgrade['price_id']);
} else {
$limit = edd_software_licensing()->get_license_limit($download_id, $license_id);
}
update_post_meta($license_id, '_edd_sl_limit', $limit);
$license_length = edd_software_licensing()->get_license_length($license_id, $payment_id, $download_id);
if (empty($is_lifetime) && 'lifetime' !== $license_length) {
// Set license expiration date
delete_post_meta($license_id, '_edd_sl_is_lifetime');
edd_software_licensing()->set_license_expiration($license_id, strtotime($license_length, strtotime($purchase_date)));
} else {
edd_software_licensing()->set_license_as_lifetime($license_id);
}
}
// Now store upgrade details / notes on payments
$old_product = get_the_title($old_download_id);
if (false !== $old_price_id) {
$old_product .= ' - ' . edd_get_price_option_name($old_download_id, $old_price_id);
}
$new_product = get_the_title($download_id);
if (edd_has_variable_prices($download_id)) {
$new_product .= ' - ' . edd_get_price_option_name($download_id, $upgrade['price_id']);
}
$note = sprintf(__('License upgraded from %s to %s', 'edd_sl'), $old_product, $new_product);
edd_insert_payment_note($payment_id, $note);
update_post_meta($payment_id, '_edd_sl_upgraded_payment_id', $old_payment_id);
update_post_meta($old_payment_id, '_edd_sl_upgraded_to_payment_id', $payment_id);
}
示例14: affwp_upgrade_license_modal
/**
* Upgrade license modal
*/
function affwp_upgrade_license_modal()
{
$professional_add_ons = affwp_get_pro_add_on_count();
?>
<div id="upgrade" class="popup entry-content mfp-with-anim mfp-hide">
<h1>Upgrade your license</h1>
<p>Pro add-ons are only available to <strong>Professional</strong> or <strong>Ultimate</strong> license-holders.</p>
<p>Once you upgrade your license you'll have access to all <?php
echo $professional_add_ons;
?>
pro add-ons (including this one), as well as any pro add-ons we build in the future.</p>
<div class="affwp-licenses">
<?php
$licenses = affwp_get_users_licenses();
$license_heading = count($licenses) > 1 ? 'Your Licenses' : 'Your license';
?>
<h2><?php
echo $license_heading;
?>
</h2>
<?php
// a customer can happily have more than 1 license of any type
if ($licenses) {
?>
<?php
foreach ($licenses as $id => $license) {
if ($license['limit'] == 0) {
$license['limit'] = 'Unlimited';
} else {
$license['limit'] = $license['limit'];
}
$license_limit_text = $license['limit'] > 1 || $license['limit'] == 'Unlimited' ? ' sites' : ' site';
?>
<div class="affwp-license">
<p><strong><?php
echo edd_get_price_option_name(affwp_get_affiliatewp_id(), $license['price_id']);
?>
</strong> (<?php
echo $license['limit'] . $license_limit_text;
?>
) - <?php
echo $license['license'];
?>
</p>
<?php
if (affwp_has_license_expired($license['license'])) {
$renewal_link = edd_get_checkout_uri(array('edd_license_key' => $license['license'], 'download_id' => affwp_get_affiliatewp_id()));
?>
<p class="license-expired"><a href="<?php
echo esc_url($renewal_link);
?>
">Your license has expired. Renew your license now and save 40% →</a></p>
<?php
}
?>
<?php
if ($license['price_id'] != 3) {
// only provide upgrade if not ultimate
?>
<ul>
<?php
if ($license['price_id'] == 0) {
// personal
?>
<li><a title="Upgrade to Ultimate license" href="<?php
echo affwp_get_license_upgrade_url('ultimate', $id);
?>
">Upgrade to Ultimate license (unlimited sites)</a></li>
<li><a title="Upgrade to Professional license" href="<?php
echo affwp_get_license_upgrade_url('professional', $id);
?>
">Upgrade to Professional license (unlimited sites)</a></li>
<li><a title="Upgrade to Plus license" href="<?php
echo affwp_get_license_upgrade_url('plus', $id);
?>
">Upgrade to Plus license (3 sites)</a></li>
<?php
}
?>
<?php
if ($license['price_id'] == 1) {
// plus
?>
<li><a title="Upgrade to Ultimate license" href="<?php
echo affwp_get_license_upgrade_url('ultimate', $id);
//.........这里部分代码省略.........
示例15: _e
<th scope="row" valign="top">
<span><?php
_e('Downloads Purchased', 'edd');
?>
</span>
</th>
<td id="purchased-downloads">
<?php
$downloads = maybe_unserialize($payment_data['downloads']);
$cart_items = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
if ($downloads) {
foreach ($downloads as $download) {
$id = isset($payment_data['cart_details']) ? $download['id'] : $download;
if (isset($download['options']['price_id'])) {
$variable_prices = '<input type="hidden" name="edd-purchased-downloads[' . $id . '][options][price_id]" value="' . $download['options']['price_id'] . '" />';
$variable_prices .= '(' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id) . ')';
} else {
$variable_prices = '';
}
echo '<div class="purchased_download_' . $id . '">
<input type="hidden" name="edd-purchased-downloads[' . $id . ']" value="' . $id . '"/>
<strong>' . get_the_title($id) . ' ' . $variable_prices . '</strong> - <a href="#" class="edd-remove-purchased-download" data-action="remove_purchased_download" data-id="' . $id . '">' . __('Remove', 'edd') . '</a>
</div>';
}
}
?>
<p id="edit-downloads"><a href="#TB_inline?width=640&inlineId=available-downloads" class="thickbox" title="<?php
printf(__('Add %s to purchase', 'edd'), strtolower(edd_get_label_plural()));
?>
"><?php
printf(__('Add %s to purchase', 'edd'), strtolower(edd_get_label_plural()));