本文整理汇总了PHP中edd_get_cart_item_price_id函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_cart_item_price_id函数的具体用法?PHP edd_get_cart_item_price_id怎么用?PHP edd_get_cart_item_price_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_cart_item_price_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_get_cart_item_price_id
<?php
continue;
// Skip this item if can't view it
?>
<?php
}
?>
<?php
if (empty($item['in_bundle'])) {
?>
<tr>
<td>
<?php
$price_id = edd_get_cart_item_price_id($item);
$download_files = edd_get_download_files($item['id'], $price_id);
?>
<div class="edd_purchase_receipt_product_name">
<?php
echo esc_html($item['name']);
?>
<?php
if (!is_null($price_id)) {
?>
<span class="edd_purchase_receipt_price_name"> – <?php
echo edd_get_price_option_name($item['id'], $price_id, $payment->ID);
?>
</span>
<?php
示例2: edd_email_tag_file_urls
/**
* Email template tag: file_urls
* A plain-text list of download URLs for each download purchased
*
* @param int $payment_id
*
* @return string $file_urls
*/
function edd_email_tag_file_urls($payment_id)
{
$payment_data = edd_get_payment_meta($payment_id);
$file_urls = '';
$cart_items = edd_get_payment_meta_cart_details($payment_id);
$email = edd_get_payment_user_email($payment_id);
foreach ($cart_items as $item) {
$price_id = edd_get_cart_item_price_id($item);
$files = edd_get_download_files($item['id'], $price_id);
if ($files) {
foreach ($files as $filekey => $file) {
$file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $item['id'], $price_id);
$file_urls .= esc_html($file_url) . '<br/>';
}
} elseif (edd_is_bundled_product($item['id'])) {
$bundled_products = apply_filters('edd_email_tag_bundled_products', edd_get_bundled_products($item['id']), $item, $payment_id, 'file_urls');
foreach ($bundled_products as $bundle_item) {
$files = edd_get_download_files($bundle_item);
foreach ($files as $filekey => $file) {
$file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $bundle_item, $price_id);
$file_urls .= esc_html($file_url) . '<br/>';
}
}
}
}
return $file_urls;
}
示例3: edd_get_cart_item_name
/**
* Get cart item title
*
* @since 2.4.3
* @param int $item Cart item array
* @return string item title
*/
function edd_get_cart_item_name($item = array())
{
$item_title = get_the_title($item['id']);
if (empty($item_title)) {
$item_title = $item['id'];
}
if (edd_has_variable_prices($item['id']) && false !== edd_get_cart_item_price_id($item)) {
$item_title .= ' - ' . edd_get_cart_item_price_name($item);
}
return apply_filters('edd_get_cart_item_name', $item_title, $item['id'], $item);
}
示例4: role_map_edd_complete_purchase
/**
* Callback on the `edd_complete_purchase` hook that updates the user's role based on purchase
*
* @since 1.0.0
* @access public
* @param int $payment_id
* @return bool
*/
function role_map_edd_complete_purchase($payment_id = 0)
{
// User info
$user_info = edd_get_payment_meta_user_info($payment_id);
// User ID
$user_id = $user_info['id'];
// Cart details
$downloads = edd_get_payment_meta_cart_details($payment_id);
// Bail if there are no downloads.
if (!is_array($downloads)) {
return;
}
// Get user roles purchased.
$roles = array();
foreach ($downloads as $download) {
// Bypass downloads that are not memberships.
if (!get_post_meta($download['id'], '_edd_members_length_enabled', true)) {
continue;
}
// Get price id.
$price_id = edd_get_cart_item_price_id($download);
// Get the price option role.
$roles[] = role_map_edd_get_price_option_role($download['id'], $price_id);
}
// If we have roles.
if ($roles) {
// Note: We're currently grabbing the first role. We need to add a check to
// get the highest priced role in case someone purchases multiple.
role_map_edd_set_user_role($user_id, array_shift($roles));
}
}
示例5: edd_osgi_action_payment_receipt_after_table
/**
*
* @param unknown $payment
* @param string $edd_receipt_args
*/
public function edd_osgi_action_payment_receipt_after_table($payment, $edd_receipt_args = null)
{
if ($this->osgipub_osgi_debug) {
echo "<p>debug: this is the action after table</p>\n";
}
if (isset($payment) && edd_is_payment_complete($payment->ID)) {
$meta = get_post_meta($payment->ID);
if ($this->osgipub_osgi_debug) {
echo "<p>debug: Payment vardump=";
var_dump($payment);
echo "</p>\n";
echo "<p>debug: Payment metadata vardump=";
var_dump($meta);
echo "</p>\n";
}
// same $cart = edd_get_payment_meta_cart_details( $payment->ID, true );
$downloads = edd_get_payment_meta_cart_details($payment->ID, true);
$edd_payment_post_id = $payment->ID;
$edd_payment_user_id = (string) $meta['_edd_payment_user_id'][0];
$edd_payment_customer_id = (string) $meta['_edd_payment_customer_id'][0];
//TODO REMOVED BECAUSE NOT BEING GENERATED $edd_payment_number = ( string ) $meta ['_edd_payment_number'] [0];
$edd_payment_number = $edd_payment_post_id;
$edd_payment_purchase_key = (string) $meta['_edd_payment_purchase_key'][0];
// see easy-digital-downloads/templates/history-downloads.php
// add_query_arg( 'payment_key', edd_get_payment_key( $post->ID ), edd_get_success_page_uri() )
if ($downloads) {
$display_licence_table = false;
// check if any downloads are osgi licenced
foreach ($downloads as $download) {
if ($this->is_osgi_licenced($download['id'])) {
$display_licence_table = true;
}
}
if ($display_licence_table) {
echo "<div id=\"osgi_licence_list_table\" class=\"osgi_licence_list\">\n";
echo "<h3>OSGi Licences</h3>\n";
echo "<p>One of more of your purchased downloads have associated OSGi Licences.<BR>To generate your licences select the links below.</p>\n";
echo "<table>\n";
}
// used to set change licence name for multiple downloads
$download_no = 0;
foreach ($downloads as $download) {
// Skip over Bundles. Products included with a bundle will be displayed individually
if (edd_is_bundled_product($download['id'])) {
continue;
}
// if not osgi licenced bundle skip
if (!$this->is_osgi_licenced($download['id'])) {
continue;
}
$download_no++;
$price_id = edd_get_cart_item_price_id($download);
$download_files = edd_get_download_files($download['id'], $price_id);
$name = get_the_title($download['id']);
// quantity used to handle multiple licences per download
for ($quantity = 1; $quantity <= $download['quantity']; $quantity++) {
if (isset($edd_payment_number)) {
// start of table row
echo " <tr>\n";
echo " <td>\n";
// product id string from download
// contains maven unique id of product to which this licence applies
$edd_osgiProductIdStr = get_post_meta($download['id'], '_edd_osgiProductIdStr', true);
// try loading modified LicenceMetadataSpecStr from this product efinition and apply to licence post
$edd_modified_osgiLicenceMetadataSpecStr = get_post_meta($download['id'], '_edd_modified_osgiLicenceMetadataSpecStr', true);
// Retrieve and append the price option name
if (!empty($price_id)) {
$name .= ' - ' . edd_get_price_option_name($download['id'], $price_id, $payment->ID);
}
// product name - payment number - download number
$licence_post_title = $name . ' - ' . $edd_payment_number . '-' . $download_no . '-' . $quantity;
// remove whitepsace
$licence_post_name = preg_replace('/\\s+/', '', $licence_post_title);
if ($this->osgipub_osgi_debug) {
echo "<p>debug: download [id]=" . $download['id'] . '</p>\\n';
if (!isset($edd_osgiProductIdStr)) {
echo "<p>debug: from download edd_osgiProductIdStr not set for download [id]=" . $download['id'] . '</p>\\n';
} else {
echo "<p>debug: from download edd_osgiProductIdStr=";
echo $edd_osgiProductIdStr;
echo "</p>\n";
}
echo "<p>debug: payment name=";
echo $name;
echo "</p>\n";
echo "<p>debug: licence_post_title=";
echo $licence_post_title;
echo "</p>\n";
echo "<p>debug: licence_post_name=";
echo $licence_post_name;
echo "</p>\n";
echo "<p>debug: edd_payment_number=";
echo $edd_payment_number;
echo "</p>\n";
}
//.........这里部分代码省略.........
示例6: foreach
<?php
foreach ($purchases as $payment) {
$downloads = edd_get_payment_meta_cart_details($payment->ID, true);
$purchase_data = edd_get_payment_meta($payment->ID);
$email = edd_get_payment_user_email($payment->ID);
if ($downloads) {
foreach ($downloads as $download) {
// Skip over Bundles. Products included with a bundle will be displayed individually
if (edd_is_bundled_product($download['id'])) {
continue;
}
?>
<tr class="edd_download_history_row">
<?php
$price_id = edd_get_cart_item_price_id($download);
$download_files = edd_get_download_files($download['id'], $price_id);
$name = get_the_title($download['id']);
// Retrieve and append the price option name
if (!empty($price_id)) {
$name .= ' - ' . edd_get_price_option_name($download['id'], $price_id, $payment->ID);
}
do_action('edd_download_history_row_start', $payment->ID, $download['id']);
?>
<td class="edd_download_download_name"><?php
echo esc_html($name);
?>
</td>
<?php
if (!edd_no_redownload()) {
示例7: edd_get_cart_item_price_name
/**
* Get cart item price name
*
* @since 1.8
* @param int $item Cart item array
* @return string Price name
*/
function edd_get_cart_item_price_name($item = array())
{
$price_id = (int) edd_get_cart_item_price_id($item);
$prices = edd_get_variable_prices($item['id']);
$name = !empty($prices[$price_id]) ? $prices[$price_id]['name'] : '';
return apply_filters('edd_get_cart_item_price_name', $name, $item['id'], $price_id, $item);
}
示例8: eddc_record_commission
/**
* Record Commissions
*
* @access private
* @since 1.0
* @return void
*/
function eddc_record_commission($payment_id, $new_status, $old_status)
{
// Check if the payment was already set to complete
if ($old_status == 'publish' || $old_status == 'complete') {
return;
}
// Make sure that payments are only completed once
// Make sure the commission is only recorded when new status is complete
if ($new_status != 'publish' && $new_status != 'complete') {
return;
}
if (edd_get_payment_gateway($payment_id) == 'manual_purchases' && !isset($_POST['commission'])) {
return;
}
// do not record commission on manual payments unless specified
if (edd_get_payment_meta($payment_id, '_edd_completed_date')) {
return;
}
$payment_data = edd_get_payment_meta($payment_id);
$user_info = maybe_unserialize($payment_data['user_info']);
$cart_details = edd_get_payment_meta_cart_details($payment_id);
$calc_base = edd_get_option('edd_commissions_calc_base', 'subtotal');
$shipping = edd_get_option('edd_commissions_shipping', 'ignored');
// loop through each purchased download and award commissions, if needed
foreach ($cart_details as $download) {
$download_id = absint($download['id']);
$commissions_enabled = get_post_meta($download_id, '_edd_commisions_enabled', true);
if ('subtotal' == $calc_base) {
$price = $download['subtotal'];
} else {
if ('total_pre_tax' == $calc_base) {
$price = $download['price'] - $download['tax'];
} else {
$price = $download['price'];
}
}
if (!empty($download['fees'])) {
foreach ($download['fees'] as $fee_id => $fee) {
if (false !== strpos($fee_id, 'shipping')) {
// If we're adjusting the commission for shipping, we need to remove it from the calculation and then add it after the commission amount has been determined
if ('ignored' !== $shipping) {
continue;
}
}
$price += $fee['amount'];
}
}
// if we need to award a commission, and the price is greater than zero
if ($commissions_enabled && floatval($price) > '0') {
// set a flag so downloads with commissions awarded are easy to query
update_post_meta($download_id, '_edd_has_commission', true);
$commission_settings = get_post_meta($download_id, '_edd_commission_settings', true);
if ($commission_settings) {
$type = eddc_get_commission_type($download_id);
// but if we have price variations, then we need to get the name of the variation
$has_variable_prices = edd_has_variable_prices($download_id);
if ($has_variable_prices) {
$price_id = edd_get_cart_item_price_id($download);
$variation = edd_get_price_option_name($download_id, $price_id);
}
$recipients = eddc_get_recipients($download_id);
// Record a commission for each user
foreach ($recipients as $recipient) {
$rate = eddc_get_recipient_rate($download_id, $recipient);
// percentage amount of download price
$args = array('price' => $price, 'rate' => $rate, 'type' => $type, 'download_id' => $download_id, 'recipient' => $recipient, 'payment_id' => $payment_id);
$commission_amount = eddc_calc_commission_amount($args);
// calculate the commission amount to award
$currency = $payment_data['currency'];
// If shipping is included or not included, we need to adjust the amount
if (!empty($download['fees']) && 'ignored' !== $shipping) {
foreach ($download['fees'] as $fee_id => $fee) {
if (false !== strpos($fee_id, 'shipping')) {
// If we're adjusting the commission for shipping, we need to remove it from the calculation and then add it after the commission amount has been determined
if ('include_shipping' == $shipping) {
$commission_amount += $fee['amount'];
}
}
}
}
$commission = array('post_type' => 'edd_commission', 'post_title' => $user_info['email'] . ' - ' . get_the_title($download_id), 'post_status' => 'publish');
$commission_id = wp_insert_post(apply_filters('edd_commission_post_data', $commission));
$commission_info = apply_filters('edd_commission_info', array('user_id' => $recipient, 'rate' => $rate, 'amount' => $commission_amount, 'currency' => $currency), $commission_id, $payment_id, $download_id);
eddc_set_commission_status($commission_id, 'unpaid');
update_post_meta($commission_id, '_edd_commission_info', $commission_info);
update_post_meta($commission_id, '_download_id', $download_id);
update_post_meta($commission_id, '_user_id', $recipient);
update_post_meta($commission_id, '_edd_commission_payment_id', $payment_id);
// If we are dealing with a variation, then save variation info
if ($has_variable_prices && isset($variation)) {
update_post_meta($commission_id, '_edd_commission_download_variation', $variation);
}
// If it's a renewal, save that detail
//.........这里部分代码省略.........
示例9: elseif
)</script>
</td>
</tr>
<?php
}
}
} elseif (edd_is_bundled_product($cart_item['id'])) {
$bundled_products = edd_get_bundled_products($cart_item['id']);
foreach ($bundled_products as $bundle_item) {
$product = get_post($bundle_item);
$bundle_license = edd_software_licensing()->get_license_by_purchase($payment_id, $product->ID);
//$post_meta = get_post_meta($product->ID, '_edd_sl_download_id', true);
$price_id = edd_get_cart_item_price_id(0);
$download_files = edd_get_download_files($product->ID, $price_id);
$product_domains_check = get_post($download_files[0]['attachment_id']);
//$cart_key = array_search($bundle_item, array_column($cart, 'id')); // (PHP 5 >= 5.5.0)
$products_domains = edd_software_licensing()->get_sites($bundle_license->ID);
foreach ($cart as $cart_row => $cart_item) {
if ($cart_item['id'] == $bundle_item) {
$cart_key = $cart_row;
break;
}
}
$download_files = edd_get_download_files($bundle_item);
$license_date = get_post_meta($bundle_license->ID, '_edd_sl_expiration', true);
$unlimited_license = get_post_meta($bundle_license->ID, '_unlimited_license', true);
$now = strtotime(date('Y-m-d H:i:s'));
$expired_license = $license_date > $now || $unlimited_license == 1 ? 0 : 1;
示例10: edd_process_paypal_purchase
/**
* Process PayPal Purchase
*
* @since 1.0
* @global $edd_options Array of all the EDD Options
* @param array $purchase_data Purchase Data
* @return void
*/
function edd_process_paypal_purchase($purchase_data)
{
global $edd_options;
// Collect payment data
$payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'paypal', 'status' => 'pending');
// Record the pending payment
$payment = edd_insert_payment($payment_data);
// Check payment
if (!$payment) {
// Record the error
edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
// Problems? send back
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
// Only send to PayPal if the pending payment is created successfully
$listener_url = add_query_arg('edd-listener', 'IPN', home_url('index.php'));
// Get the success url
$return_url = add_query_arg(array('payment-confirmation' => 'paypal', 'payment-id' => $payment), get_permalink($edd_options['success_page']));
// Get the PayPal redirect uri
$paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
// Setup PayPal arguments
$paypal_args = array('business' => $edd_options['paypal_email'], 'email' => $purchase_data['user_email'], 'invoice' => $purchase_data['purchase_key'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => edd_get_currency(), 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => edd_get_failed_transaction_uri('?payment-id=' . $payment), 'notify_url' => $listener_url, 'page_style' => edd_get_paypal_page_style(), 'cbt' => get_bloginfo('name'), 'bn' => 'EasyDigitalDownloads_SP');
if (!empty($purchase_data['user_info']['address'])) {
$paypal_args['address1'] = $purchase_data['user_info']['address']['line1'];
$paypal_args['address2'] = $purchase_data['user_info']['address']['line2'];
$paypal_args['city'] = $purchase_data['user_info']['address']['city'];
$paypal_args['country'] = $purchase_data['user_info']['address']['country'];
}
$paypal_extra_args = array('cmd' => '_cart', 'upload' => '1');
$paypal_args = array_merge($paypal_extra_args, $paypal_args);
// Add cart items
$i = 1;
foreach ($purchase_data['cart_details'] as $item) {
if (edd_has_variable_prices($item['id']) && edd_get_cart_item_price_id($item) !== false) {
$item['name'] .= ' - ' . edd_get_cart_item_price_name($item);
}
$paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wp_strip_all_tags($item['name']), ENT_COMPAT, 'UTF-8'));
$paypal_args['quantity_' . $i] = $item['quantity'];
$paypal_args['amount_' . $i] = round($item['subtotal'] / $item['quantity'], 2);
if (edd_use_skus()) {
$paypal_args['item_number_' . $i] = edd_get_download_sku($item['id']);
}
$i++;
}
// Calculate discount
$discounted_amount = 0.0;
if (!empty($purchase_data['fees'])) {
$i = empty($i) ? 1 : $i;
foreach ($purchase_data['fees'] as $fee) {
if (floatval($fee['amount']) > '0') {
// this is a positive fee
$paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wp_strip_all_tags($fee['label']), ENT_COMPAT, 'UTF-8'));
$paypal_args['quantity_' . $i] = '1';
$paypal_args['amount_' . $i] = edd_sanitize_amount($fee['amount']);
$i++;
} else {
// This is a negative fee (discount)
$discounted_amount += abs($fee['amount']);
}
}
}
if ($discounted_amount > '0') {
$paypal_args['discount_amount_cart'] = edd_sanitize_amount($discounted_amount);
}
// Add taxes to the cart
if (edd_use_taxes()) {
$paypal_args['tax_cart'] = edd_sanitize_amount($purchase_data['tax']);
}
$paypal_args = apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data);
// Build query
$paypal_redirect .= http_build_query($paypal_args);
// Fix for some sites that encode the entities
$paypal_redirect = str_replace('&', '&', $paypal_redirect);
// Get rid of cart contents
edd_empty_cart();
// Redirect to PayPal
wp_redirect($paypal_redirect);
exit;
}
}
示例11: edd_email_template_tags
/**
* Email Template Tags
*
* @since 1.0
*
* @param string $message Message with the template tags
* @param array $payment_data Payment Data
* @param int $payment_id Payment ID
*
* @return string $message Fully formatted message
*/
function edd_email_template_tags($message, $payment_data, $payment_id)
{
global $edd_options;
$has_tags = strpos($message, '{') !== false;
if (!$has_tags) {
return $message;
}
$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>';
$cart_items = edd_get_payment_meta_cart_details($payment_id);
if ($cart_items) {
$show_names = apply_filters('edd_email_show_names', true);
foreach ($cart_items as $item) {
if (edd_use_skus()) {
$sku = edd_get_download_sku($item['id']);
}
$price_id = edd_get_cart_item_price_id($item);
if ($show_names) {
$title = get_the_title($item['id']);
if (!empty($sku)) {
$title .= " – " . __('SKU', 'edd') . ': ' . $sku;
}
if ($price_id !== false) {
$title .= " – " . edd_get_price_option_name($item['id'], $price_id);
}
$download_list .= '<li>' . apply_filters('edd_email_receipt_download_title', $title, $item['id'], $price_id) . '<br/>';
$download_list .= '<ul>';
}
$files = edd_get_download_files($item['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, $item['id'], $price_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($item['id'])) {
$download_list .= ' — <small>' . edd_get_product_notes($item['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 = str_replace('{payment_id}', $payment_id, $message);
$message = str_replace('{receipt_link}', sprintf(__('%1$sView it in your browser.%2$s', 'edd'), '<a href="' . add_query_arg(array('purchase_key' => $receipt_id, 'edd_action' => 'view_receipt'), home_url()) . '">', '</a>'), $message);
$message = apply_filters('edd_email_template_tags', $message, $payment_data, $payment_id);
return $message;
}
示例12: eddc_record_commission
/**
* Record Commissions
*
* @access private
* @since 1.0
* @return void
*/
function eddc_record_commission($payment_id, $new_status, $old_status)
{
// Check if the payment was already set to complete
if ($old_status == 'publish' || $old_status == 'complete') {
return;
}
// Make sure that payments are only completed once
// Make sure the commission is only recorded when new status is complete
if ($new_status != 'publish' && $new_status != 'complete') {
return;
}
if (edd_get_payment_gateway($payment_id) == 'manual_purchases' && !isset($_POST['commission'])) {
return;
}
// do not record commission on manual payments unless specified
$payment_data = edd_get_payment_meta($payment_id);
$user_info = maybe_unserialize($payment_data['user_info']);
$cart_details = maybe_unserialize($payment_data['cart_details']);
// loop through each purchased download and award commissions, if needed
foreach ($cart_details as $download) {
$download_id = absint($download['id']);
$commissions_enabled = get_post_meta($download_id, '_edd_commisions_enabled', true);
if ('subtotal' == edd_get_option('edd_commissions_calc_base', 'subtotal')) {
$price = $download['subtotal'];
} else {
$price = $download['price'];
}
// if we need to award a commission, and the price is greater than zero
if ($commissions_enabled && floatval($price) > '0') {
// set a flag so downloads with commissions awarded are easy to query
update_post_meta($download_id, '_edd_has_commission', true);
$commission_settings = get_post_meta($download_id, '_edd_commission_settings', true);
if ($commission_settings) {
$type = eddc_get_commission_type($download_id);
// but if we have price variations, then we need to get the name of the variation
if (edd_has_variable_prices($download_id)) {
$price_id = edd_get_cart_item_price_id($download);
$variation = edd_get_price_option_name($download_id, $price_id);
}
$recipients = eddc_get_recipients($download_id);
// Record a commission for each user
foreach ($recipients as $recipient) {
$rate = eddc_get_recipient_rate($download_id, $recipient);
// percentage amount of download price
$commission_amount = eddc_calc_commission_amount($price, $rate, $type);
// calculate the commission amount to award
$currency = $payment_data['currency'];
$commission = array('post_type' => 'edd_commission', 'post_title' => $user_info['email'] . ' - ' . get_the_title($download_id), 'post_status' => 'publish');
$commission_id = wp_insert_post(apply_filters('edd_commission_post_data', $commission));
$commission_info = apply_filters('edd_commission_info', array('user_id' => $recipient, 'rate' => $rate, 'amount' => $commission_amount, 'currency' => $currency), $commission_id);
update_post_meta($commission_id, '_edd_commission_info', $commission_info);
update_post_meta($commission_id, '_commission_status', 'unpaid');
update_post_meta($commission_id, '_download_id', $download_id);
update_post_meta($commission_id, '_user_id', $recipient);
update_post_meta($commission_id, '_edd_commission_payment_id', $payment_id);
//if we are dealing with a variation, then save variation info
if (isset($variation)) {
update_post_meta($commission_id, '_edd_commission_download_variation', $variation);
}
do_action('eddc_insert_commission', $recipient, $commission_amount, $rate, $download_id, $commission_id, $payment_id);
}
}
}
}
}
示例13: edd_pup_products_links_tag_plain
/**
* Email template tag: updated_products_links
* A list of updated products with download links included
*
* @access public
* @param mixed $payment_id
* @return void
*/
function edd_pup_products_links_tag_plain($payment_id, $email = null)
{
// Used to generate accurate tag outputs for preview and test emails
if (isset($email) && absint($email) != 0) {
$updated_products = get_post_meta($email, '_edd_pup_updated_products', true);
$updated_products = is_array($updated_products) ? $updated_products : array($updated_products);
foreach ($updated_products as $id => $name) {
$customer_updates[$id] = array('id' => $id, 'name' => $name);
}
} else {
$email = get_transient('edd_pup_sending_email_' . get_current_user_id());
$updated_products = get_post_meta($email, '_edd_pup_updated_products', true);
$updated_products = is_array($updated_products) ? $updated_products : array($updated_products);
$customer_updates = edd_pup_get_customer_updates($payment_id, $email);
$customer_updates = is_array($customer_updates) ? $customer_updates : array($customer_updates);
}
$filters = get_post_meta($email, '_edd_pup_filters', true);
if ($customer_updates) {
$show_names = apply_filters('edd_pup_email_show_names', true);
$payment_data = edd_get_payment_meta($payment_id);
// Set email to most recent email if it's been changed from initial email
if (isset($payment_data['user_info']['email']) && $payment_data['user_info']['email'] != $payment_data['email']) {
$payment_data['email'] = $payment_data['user_info']['email'];
}
// Used for detecting when to place commas
$c = 1;
$download_list = '';
foreach ($customer_updates as $item) {
if (edd_use_skus()) {
$sku = edd_get_download_sku($item['id']);
}
$price_id = edd_get_cart_item_price_id($item);
if ($show_names) {
$title = $c == 1 ? $item['name'] : ', ' . $item['name'];
if (!empty($sku)) {
$title .= " – " . __('SKU', 'edd') . ': ' . $sku;
}
$download_list .= apply_filters('edd_pup_email_products_link_title_plain', $title, $item, $price_id, $payment_id);
}
$files = edd_get_download_files($item['id'], $price_id);
if ($files) {
// $f used for detecting when to place commas
$f = 1;
$download_list .= ' (';
foreach ($files as $filekey => &$file) {
$file_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $filekey, $item['id'], $price_id);
$download_list .= $f == 1 ? edd_get_file_name($file) . ': ' . esc_url($file_url) : ', ' . edd_get_file_name($file) . ': ' . esc_url($file_url);
$f++;
}
$download_list .= ')';
}
if (edd_is_bundled_product($item['id'])) {
$b = 1;
$bundled_products = edd_get_bundled_products($item['id']);
$download_list .= " – ";
foreach ($bundled_products as $bundle_item) {
if ($filters['bundle_1'] == 'all' || isset($updated_products[$bundle_item])) {
$download_list .= $b == 1 ? get_the_title($bundle_item) : '; ' . get_the_title($bundle_item);
$fb = 1;
$bundlefiles = edd_get_download_files($bundle_item);
$download_list .= ' (';
foreach ($bundlefiles as $bundlefilekey => $bundlefile) {
$bundlefile_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $bundlefilekey, $bundle_item, $price_id);
$download_list .= $fb == 1 ? $bundlefile['name'] . ': ' . esc_url($bundlefile_url) : ', ' . $bundlefile['name'] . ': ' . esc_url($bundlefile_url);
$fb++;
}
$download_list .= ')';
}
$b++;
}
}
if ('' != edd_get_product_notes($item['id'])) {
$download_list .= ' – ' . edd_get_product_notes($item['id']);
}
$c++;
}
return $download_list;
}
}
示例14: eddflg_build_download_url
/**
* Returns the link to the file available for download
*
* @since 0.1
*/
function eddflg_build_download_url($payment_id)
{
$downloads = edd_get_payment_meta_cart_details($payment_id, true);
$purchase_data = edd_get_payment_meta($payment_id);
if ($downloads) {
$price_id = edd_get_cart_item_price_id($downloads[0]);
$download_files = edd_get_download_files($downloads[0]['id'], $price_id);
}
foreach ($download_files as $filekey => $file) {
$download_url = edd_get_download_file_url($purchase_data['key'], $purchase_data['email'], $filekey, $downloads[0]['id'], $price_id);
}
return $download_url;
}
示例15: is_service
/**
* Is service
* @param int $item_id ID of download
* @return boolean true if service, false otherwise
* @return boolean
*/
public function is_service($item_id)
{
global $edd_receipt_args, $edd_options;
// get array of service categories
$service_categories = isset($edd_options['edd_das_service_categories']) ? $edd_options['edd_das_service_categories'] : '';
$term_ids = array();
if ($service_categories) {
foreach ($service_categories as $term_id => $term_name) {
$term_ids[] = $term_id;
}
}
$is_service = get_post_meta($item_id, '_edd_das_enabled', true);
// get payment
$payment = get_post($edd_receipt_args['id']);
$meta = isset($payment) ? edd_get_payment_meta($payment->ID) : '';
$cart = isset($payment) ? edd_get_payment_meta_cart_details($payment->ID, true) : '';
if ($cart) {
foreach ($cart as $key => $item) {
$price_id = edd_get_cart_item_price_id($item);
$download_files = edd_get_download_files($item_id, $price_id);
// if the service has a file attached, we still want to show it
if ($download_files) {
return;
}
}
}
// check if download has meta key or has a service term assigned to it
if ($is_service || has_term($term_ids, 'download_category', $item_id)) {
return true;
}
return false;
}