本文整理汇总了PHP中edd_get_payment_meta_cart_details函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_payment_meta_cart_details函数的具体用法?PHP edd_get_payment_meta_cart_details怎么用?PHP edd_get_payment_meta_cart_details使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_payment_meta_cart_details函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_data
/**
* Get the data being exported
*
* @access public
* @since 1.2
* @return array
*/
public function get_data()
{
global $edd_logs;
$data = array();
$args = array('nopaging' => true, 'post_type' => 'edd_payment', 'meta_key' => '_edd_payment_shipping_status', 'meta_value' => '1', 'fields' => 'ids');
$payments = get_posts($args);
if ($payments) {
foreach ($payments as $payment) {
$user_info = edd_get_payment_meta_user_info($payment);
$downloads = edd_get_payment_meta_cart_details($payment);
$products = '';
if ($downloads) {
foreach ($downloads as $key => $download) {
// Display the Downoad Name
$products .= get_the_title($download['id']);
if ($key != count($downloads) - 1) {
$products .= ' / ';
}
}
}
$data[] = array('id' => $payment, 'date' => get_post_field('post_date', $payment), 'first_name' => $user_info['first_name'], 'last_name' => $user_info['last_name'], 'email' => $user_info['email'], 'address' => $user_info['shipping_info']['address'], 'address2' => !empty($user_info['shipping_info']['address2']) ? $user_info['shipping_info']['address2'] : '', 'city' => $user_info['shipping_info']['city'], 'state' => $user_info['shipping_info']['state'], 'zip' => $user_info['shipping_info']['zip'], 'country' => $user_info['shipping_info']['country'], 'amount' => edd_get_payment_amount($payment), 'tax' => edd_get_payment_tax($payment), 'gateway' => edd_get_payment_gateway($payment), 'key' => edd_get_payment_key($payment), 'products' => $products, 'status' => get_post_field('post_status', $payment));
}
}
$data = apply_filters('edd_export_get_data', $data);
$data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
return $data;
}
示例2: ck_edd_user_download_button
function ck_edd_user_download_button($purchase_form, $args)
{
global $edd_options;
if (!is_user_logged_in()) {
return $purchase_form;
}
$download_id = (string) $args['download_id'];
$current_user_id = get_current_user_id();
// If the user has purchased this item, itterate through their purchases to get the specific
// purchase data and pull out the key and email associated with it. This is necessary for the
// generation of the download link
if (edd_has_user_purchased($current_user_id, $download_id, $variable_price_id = null)) {
$user_purchases = edd_get_users_purchases($current_user_id, -1, false, 'complete');
foreach ($user_purchases as $purchase) {
$cart_items = edd_get_payment_meta_cart_details($purchase->ID);
$item_ids = wp_list_pluck($cart_items, 'id');
if (in_array($download_id, $item_ids)) {
$email = edd_get_payment_user_email($purchase->ID);
$payment_key = edd_get_payment_key($purchase->ID);
}
}
$download_ids = array();
if (edd_is_bundled_product($download_id)) {
$download_ids = edd_get_bundled_products($download_id);
} else {
$download_ids[] = $download_id;
}
// Setup the style and colors associated with the settings
$style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
$color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
$new_purchase_form = '';
foreach ($download_ids as $item) {
// Attempt to get the file data associated with this download
$download_data = edd_get_download_files($item, null);
if ($download_data) {
foreach ($download_data as $filekey => $file) {
// Generate the file URL and then make a link to it
$file_url = edd_get_download_file_url($payment_key, $email, $filekey, $item, null);
$new_purchase_form .= '<a href="' . $file_url . '" class="' . $style . ' ' . $color . ' edd-submit"><span class="edd-add-to-cart-label">Download ' . $file['name'] . '</span></a> ';
}
}
// As long as we ended up with links to show, use them.
if (!empty($new_purchase_form)) {
$purchase_form = '<h4>' . __('You already own this product. Download it now:', 'edd') . '</h4>' . $new_purchase_form;
}
}
}
return $purchase_form;
}
示例3: save_attendee_meta_to_order
/**
* Sets attendee data on order posts
*
* @since 4.1
*
* @param int $order_id EDD Order ID
* @param array $post_data Data submitted via POST during checkout
*/
public function save_attendee_meta_to_order($order_id, $post_data)
{
$order_items = edd_get_payment_meta_cart_details($order_id);
// Bail if the order is empty
if (empty($order_items)) {
return;
}
$product_ids = array();
// gather product ids
foreach ((array) $order_items as $item) {
if (empty($item['id'])) {
continue;
}
$product_ids[] = $item['id'];
}
$meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
// build the custom meta data that will be stored in the order meta
if (!($order_meta = $meta_object->build_order_meta($product_ids))) {
return;
}
// store the custom meta on the order
update_post_meta($order_id, Tribe__Tickets_Plus__Meta::META_KEY, $order_meta, true);
// clear out product custom meta data cookies
foreach ($product_ids as $product_id) {
$meta_object->clear_meta_cookie_data($product_id);
}
}
示例4: 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;
}
示例5: pw_edd_sl_license_length
function pw_edd_sl_license_length($expiration, $payment_id, $download_id, $license_id)
{
$purchase_details = edd_get_payment_meta_cart_details($payment_id);
$price_id = false;
foreach ($purchase_details as $item) {
if ((int) $item['id'] === (int) $download_id) {
if (!empty($item['item_number']['options'])) {
foreach ($item['item_number']['options'] as $option) {
$price_id = (int) $option['price_id'];
}
}
}
}
if ($price_id !== false) {
switch ($price_id) {
case 0:
$expiration = '+10 years';
break;
case 1:
$expiration = '+2 years';
break;
case 2:
$expiration = '+1 year';
break;
}
}
return $expiration;
}
示例6: get_data
/**
* Get the Export Data
*
* @access public
* @since 1.4.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, $edd_options;
$data = array();
$payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => edd_is_test_mode() ? 'test' : 'live', 'status' => isset($_POST['edd_export_payment_status']) ? $_POST['edd_export_payment_status'] : 'any', 'month' => isset($_POST['month']) ? absint($_POST['month']) : date('n'), 'year' => isset($_POST['year']) ? absint($_POST['year']) : date('Y')));
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 = isset($payment_meta['amount']) ? $payment_meta['amount'] : 0.0;
$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']) . ' - ';
}
}
$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, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'products' => $products, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(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)), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'edd'), 'status' => edd_get_payment_status($payment, true));
if (!edd_use_skus()) {
unset($data['skus']);
}
}
$data = apply_filters('edd_export_get_data', $data);
$data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
return $data;
}
示例7: render_tag_content
public function render_tag_content($payment_id = 0)
{
$output = '';
$cart_items = edd_get_payment_meta_cart_details($payment_id, true);
foreach ($cart_items as $item) {
// do something to $output for each cart item
}
return $output;
}
示例8: get_data
/**
* Get the Export Data
*
* @access public
* @since 2.5
* @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 $edd_logs, $wpdb;
$accepted_statuses = apply_filters('edd_recount_accepted_statuses', array('publish', 'revoked'));
if ($this->step == 1) {
$this->delete_data('edd_temp_recount_download_stats');
}
$totals = $this->get_stored_data('edd_temp_recount_download_stats');
if (false === $totals) {
$totals = array('earnings' => (double) 0, 'sales' => 0);
$this->store_data('edd_temp_recount_download_stats', $totals);
}
$args = apply_filters('edd_recount_download_stats_args', array('post_parent' => $this->download_id, 'post_type' => 'edd_log', 'posts_per_page' => $this->per_step, 'post_status' => 'publish', 'paged' => $this->step, 'log_type' => 'sale', 'fields' => 'ids'));
$log_ids = $edd_logs->get_connected_logs($args, 'sale');
$this->_log_ids_debug = array();
if ($log_ids) {
$log_ids = implode(',', $log_ids);
$payment_ids = $wpdb->get_col("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_edd_log_payment_id' AND post_id IN ({$log_ids})");
unset($log_ids);
$payment_ids = implode(',', $payment_ids);
$payments = $wpdb->get_results("SELECT ID, post_status FROM {$wpdb->posts} WHERE ID IN (" . $payment_ids . ")");
unset($payment_ids);
foreach ($payments as $payment) {
if (!in_array($payment->post_status, $accepted_statuses)) {
continue;
}
$items = edd_get_payment_meta_cart_details($payment->ID);
foreach ($items as $item) {
if ($item['id'] != $this->download_id) {
continue;
}
$this->_log_ids_debug[] = $payment->ID;
$amount = $item['price'];
if (!empty($item['fees'])) {
foreach ($item['fees'] as $fee) {
// Only let negative fees affect earnings
if ($fee['amount'] > 0) {
continue;
}
$amount += $fee['amount'];
}
}
$totals['sales']++;
$totals['earnings'] += $amount;
}
}
$this->store_data('edd_temp_recount_download_stats', $totals);
return true;
}
update_post_meta($this->download_id, '_edd_download_sales', $totals['sales']);
update_post_meta($this->download_id, '_edd_download_earnings', $totals['earnings']);
return false;
}
示例9: edd_rp_log_recommendation_sale
/**
* Maybe log a recommendation sale
* Iterates through items in the payment and if one is a recommendation logs it
*
* @since 1.2.6
* @param int $payment_id The Payment ID being completed
* @return void
*/
function edd_rp_log_recommendation_sale($payment_id)
{
$payment_items = edd_get_payment_meta_cart_details($payment_id, true);
foreach ($payment_items as $item) {
if (!empty($item['item_number']['recommendation_source'])) {
$edd_log = new EDD_Logging();
$log_data = array('post_parent' => $item['item_number']['recommendation_source'], 'post_date' => edd_get_payment_completed_date($payment_id), 'log_type' => 'recommendation_sale');
$log_meta = array('payment_id' => $payment_id, 'download_id' => $item['id'], 'price' => $item['price'], 'quantity' => $item['quantity'], 'item_price' => $item['item_price']);
$log_entry = $edd_log->insert_log($log_data, $log_meta);
}
}
}
示例10: edd_points_add_point_for_complete_purchase
/**
* Add points for purchase
*
* Handles to add points for purchases
*
* @package Easy Digital Downloads - Points and Rewards
* @since 1.0.0
*/
public function edd_points_add_point_for_complete_purchase($payment_id)
{
global $edd_options, $current_user;
//get payment data
$paymentdata = edd_get_payment_meta($payment_id);
$userdata = edd_get_payment_meta_user_info($payment_id);
$user_id = isset($userdata['id']) && !empty($userdata['id']) ? $userdata['id'] : 0;
//get discount towards points
$gotdiscount = $this->model->edd_points_get_payment_discount($payment_id);
//check user has redeemed points or not & user_id should not empty
if (isset($gotdiscount) && !empty($gotdiscount) && !empty($user_id)) {
//get discounte price from points
$discountedpoints = $this->model->edd_points_calculate_points($gotdiscount);
//update user points
edd_points_minus_points_from_user($discountedpoints, $user_id);
//points label
$pointslable = $this->model->edd_points_get_points_label($discountedpoints);
//record data logs for redeem for purchase
$post_data = array('post_title' => sprintf(__('Redeem %s for purchase', 'eddpoints'), $pointslable), 'post_content' => sprintf(__('%s redeemed for purchasing download by redeeming the points and get discounts.', 'eddpoints'), $pointslable), 'post_author' => $user_id);
//log meta array
$log_meta = array('userpoint' => $discountedpoints, 'events' => 'redeemed_purchase', 'operation' => 'minus');
//insert entry in log
$this->logs->edd_points_insert_logs($post_data, $log_meta);
// set order meta, regardless of whether any points were earned, just so we know the process took place
update_post_meta($payment_id, '_edd_points_order_redeemed', $discountedpoints);
}
//end if to check points redeemed taken by buyer or not
// get cartdata from older order
$cartdata = edd_get_payment_meta_cart_details($payment_id);
//get bought points for points downloads types
$boughtpoints = $this->model->edd_points_get_bought_points($cartdata);
//get cart points from cartdata and payment discount given to user
$cartpoints = $this->model->edd_points_get_user_checkout_points($cartdata, $gotdiscount);
//add bought points to cart points
$cartpoints = !empty($boughtpoints) ? $cartpoints + $boughtpoints : $cartpoints;
//check checkout points earned points or user id is not empty
if (!empty($cartpoints) && !empty($user_id)) {
//points label
$pointslable = $this->model->edd_points_get_points_label($cartpoints);
//get user points after subtracting the redemption points
$userpoints = edd_points_get_user_points();
$post_data = array('post_title' => sprintf(__('%s earned for purchasing the downloads.', 'eddpoints'), $pointslable), 'post_content' => sprintf(__('Get %s for purchasing the downloads.', 'eddpoints'), $pointslable), 'post_author' => $user_id);
$log_meta = array('userpoint' => $cartpoints, 'events' => 'earned_purchase', 'operation' => 'add');
//insert entry in log
$this->logs->edd_points_insert_logs($post_data, $log_meta);
//update user points
edd_points_add_points_to_user($cartpoints, $user_id);
// set order meta, regardless of whether any points were earned, just so we know the process took place
update_post_meta($payment_id, '_edd_points_order_earned', $cartpoints);
}
//end if to check checkout points should not empty
}
示例11: 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;
}
示例12: wplms_edd_completed_purchase
function wplms_edd_completed_purchase($payment_id, $new_status, $old_status)
{
if ($old_status == 'publish' || $old_status == 'complete') {
return;
}
// Make sure that payments are only completed once
// Make sure the payment completion is only processed when new status is complete
if ($new_status != 'publish' && $new_status != 'complete') {
return;
}
$user_id = get_current_user_id();
$cart_items = edd_get_payment_meta_cart_details($payment_id);
foreach ($cart_items as $key => $cart_item) {
$item_id = isset($cart_item['id']) ? $cart_item['id'] : $cart_item;
if (is_numeric($item_id) && get_post_type($item_id) == 'download') {
$courses = vibe_sanitize(get_post_meta($item_id, 'vibe_courses', false));
$subscribed = get_post_meta($product_id, 'vibe_subscription', true);
if (vibe_validate($subscribed)) {
$duration = get_post_meta($product_id, 'vibe_duration', true);
$product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400);
// Product duration for subscription based
$t = time() + $duration * $product_duration_parameter;
foreach ($courses as $course) {
update_post_meta($course, $user_id, 0);
update_user_meta($user_id, $course, $t);
$group_id = get_post_meta($course, 'vibe_group', true);
if (isset($group_id) && $group_id != '') {
groups_join_group($group_id, $user_id);
}
bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id));
}
} else {
if (isset($courses) && is_array($courses)) {
foreach ($courses as $course) {
$duration = get_post_meta($course, 'vibe_duration', true);
$course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400);
// Course duration for subscription based
$t = time() + $duration * $course_duration_parameter;
update_post_meta($course, $user_id, 0);
update_user_meta($user_id, $course, $t);
$group_id = get_post_meta($course, 'vibe_group', true);
if (isset($group_id) && $group_id != '') {
groups_join_group($group_id, $user_id);
}
bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id));
}
}
}
}
}
}
示例13: sumobi_edd_email_tag_downloads
/**
* The {downloads} email tag
*/
function sumobi_edd_email_tag_downloads($payment_id)
{
$cart_items = edd_get_payment_meta_cart_details($payment_id);
$download_list = '<ul>';
if ($cart_items) {
foreach ($cart_items as $item) {
$title = sprintf('<a href="%s">%s</a>', get_permalink($item['id']), get_the_title($item['id']));
$download_list .= '<li>' . $title . '<br/>';
$download_list .= '</li>';
}
}
$download_list .= '</ul>';
return $download_list;
}
示例14: pw_edd_sl_license_at_limit
function pw_edd_sl_license_at_limit($ret = false, $license_id = 0, $limit = 0, $download_id = 0)
{
$purchase_id = get_post_meta($license_id, '_edd_sl_payment_id', true);
$purchase_date = new DateTime(get_post_field('post_date', $purchase_id));
$limit_date = new DateTime('2013-01-01');
if ($purchase_date < $limit_date) {
// licenses purchased before January 1, 2013 are unlimited
return false;
}
$purchase_details = edd_get_payment_meta_cart_details($purchase_id);
$price_id = false;
foreach ($purchase_details as $item) {
if ($item['id'] == $download_id) {
if (!empty($item['item_number']['options'])) {
foreach ($item['item_number']['options'] as $option) {
$price_id = (int) $option['price_id'];
}
}
}
}
if ($price_id !== false) {
switch ($price_id) {
case 0:
$limit = 1;
// single site license
break;
case 1:
$limit = 5;
// up to 5 sites
break;
case 2:
$limit = 0;
// unlimited
break;
}
$site_count = absint(get_post_meta($license_id, '_edd_sl_site_count', true));
// check to make sure a limit is in place
if ($limit > 0) {
if ($site_count >= absint($limit)) {
$ret = true;
// license is at limit
}
}
}
return $ret;
}
示例15: edd_csau_payment_actions
/**
* Payment actions
*
* @since 1.1
*/
function edd_csau_payment_actions($payment_id)
{
$cart_details = edd_get_payment_meta_cart_details($payment_id);
if (is_array($cart_details)) {
// Increase purchase count and earnings
foreach ($cart_details as $download) {
// "bundle" or "default"
$download_type = edd_get_download_type($download['id']);
$price_id = isset($download['options']['price_id']) ? (int) $download['options']['price_id'] : false;
// Increase earnings, and fire actions once per quantity number
for ($i = 0; $i < $download['quantity']; $i++) {
if (!edd_is_test_mode() || apply_filters('edd_log_test_payment_stats', false)) {
if (isset($download['item_number']['cross_sell'])) {
$type = 'cross_sell';
} elseif (isset($download['item_number']['upsell'])) {
$type = 'upsell';
} else {
$type = null;
}
if ($type) {
edd_csau_increase_purchase_count($download['id'], $type);
edd_csau_increase_earnings($download['id'], $download['price'], $type);
edd_csau_record_sale_in_log($download['id'], $payment_id, $price_id, $type);
}
}
$types[] = $type;
$types = array_unique(array_filter($types));
}
}
// Clear the total earnings cache
delete_transient('edd_' . $type . '_earnings_total');
}
if ($types) {
foreach ($types as $type) {
// store the total amount of cross-sell earnings
update_post_meta($payment_id, '_edd_payment_' . $type . '_total', edd_csau_calculate_sales($payment_id, $type));
$amount = edd_csau_get_payment_amount($payment_id, $type);
// increase earnings
edd_csau_increase_total_earnings($amount, $type);
}
}
}