/**
  * 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;
 }
Beispiel #2
0
 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;
 }
/**
 * 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');
    }
}
Beispiel #4
0
/**
 * 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>&nbsp;';
            if ('' !== $price_id) {
                echo '<span class="edd_sl_license_price_option">&ndash;&nbsp;' . 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">&nbsp;(' . __('expired', 'edd_sl') . ')</span>';
            } elseif ('draft' == $license->post_status) {
                echo '<span class="edd_sl_license_key_revoked">&nbsp;(' . __('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>';
        }
    }
}
    ?>
			<?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);
            ?>
/**
 * Sales Summary Dashboard Widget
 *
 * @access      private
 * @author      Sunny Ratilal
 * @since       1.2.2
*/
function edd_dashboard_sales_widget()
{
    $top_selling_args = array('post_type' => 'download', 'posts_per_page' => 1, 'post_status' => 'publish', 'meta_key' => '_edd_download_sales', 'meta_compare' => '>', 'meta_value' => 0, 'orderby' => 'meta_value_num', 'cache_results' => false, 'update_post_term_cache' => false, 'no_found_rows' => true, 'order' => 'DESC');
    $top_selling = get_posts($top_selling_args);
    ?>
	<div class="table table_current_month">
		<p class="sub"><?php 
    _e('Current Month', 'edd');
    ?>
</p>
		<table>
			<tbody>
				<tr class="first">
					<td class="first b"><?php 
    echo edd_currency_filter(edd_format_amount(edd_get_earnings_by_date(null, date('n'), date('Y'))));
    ?>
</td>
					<td class="t monthly_earnings"><?php 
    _e('Earnings', 'edd');
    ?>
</td>
				</tr>
				<tr>
					<?php 
    $monthly_sales = edd_get_sales_by_date(null, date('n'), date('Y'));
    ?>
					<td class="first b"><?php 
    echo $monthly_sales;
    ?>
</td>
					<td class="t monthly_sales"><?php 
    echo _n('Sale', 'Sales', $monthly_sales, 'edd');
    ?>
</td>
				</tr>
			</tbody>
		</table>
		<p class="label_heading"><?php 
    _e('Last Month', 'edd');
    ?>
</p>
		<div>
			<?php 
    echo __('Earnings', 'edd') . ':&nbsp;<span class="edd_price_label">' . edd_currency_filter(edd_format_amount(edd_get_earnings_by_date(null, date('n') - 1, date('Y')))) . '</span>';
    ?>
		</div>
		<div>
			<?php 
    $last_month_sales = edd_get_sales_by_date(null, date('n') - 1, date('Y'));
    ?>
			<?php 
    echo _n('Sale', 'Sales', $last_month_sales, 'edd') . ':&nbsp;' . '<span class="edd_price_label">' . $last_month_sales . '</span>';
    ?>
		</div>
	</div>
	<div class="table table_totals">
		<p class="sub"><?php 
    _e('Totals', 'edd');
    ?>
</p>
		<table>
			<tbody>
				<tr class="first">
					<td class="b b-earnings"><?php 
    echo edd_currency_filter(edd_format_amount(edd_get_total_earnings()));
    ?>
</td>
					<td class="last t earnings"><?php 
    _e('Total Earnings', 'edd');
    ?>
</td>
				</tr>
				<tr>
					<td class="b b-sales"><?php 
    echo edd_get_total_sales();
    ?>
</td>
					<td class="last t sales"><?php 
    _e('Total Sales', 'edd');
    ?>
</td>
				</tr>
			</tbody>
		</table>
		<?php 
    if ($top_selling) {
        foreach ($top_selling as $list) {
            ?>
				<p class="lifetime_best_selling label_heading"><?php 
            _e('Lifetime Best Selling', 'edd');
            ?>
</p>
				<p><span class="lifetime_best_selling_label"><?php 
            echo edd_get_download_sales_stats($list->ID);
            ?>
</span> <a href="<?php 
            echo get_permalink($list->ID);
            ?>
"><?php 
            echo get_the_title($list->ID);
            ?>
</a></p>
		<?php 
        }
    }
    ?>
	</div>
	<div style="clear: both"></div>
	<?php 
    $payments = edd_get_payments(array('number' => 5, 'mode' => 'live', 'orderby' => 'post_date', 'order' => 'DESC', 'user' => null, 'status' => 'publish', 'meta_key' => null));
    if ($payments) {
        ?>
	<p class="edd_dashboard_widget_subheading"><?php 
        _e('Recent Purchases', 'edd');
        ?>
</p>
	<div class="table recent_purchases">
		<table>
			<tbody>
				<?php 
        foreach ($payments as $payment) {
            $payment_meta = edd_get_payment_meta($payment->ID);
            ?>
				<tr>
					<td><?php 
            echo get_the_title($payment->ID);
            ?>
 - (<?php 
            echo $payment_meta['email'];
            ?>
) - <span class="edd_price_label"><?php 
            echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment->ID)));
            ?>
</span> - <a href="#TB_inline?width=640&amp;inlineId=purchased-files-<?php 
            echo $payment->ID;
            ?>
" class="thickbox" title="<?php 
            printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID);
            ?>
 "><?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');
            ?>
</h4>
								<ul>
									<li><?php 
            echo __('Name:', 'edd') . ' ' . $user_info['first_name'] . ' ' . $user_info['last_name'];
            ?>
</li>
									<li><?php 
            echo __('Email:', 'edd') . ' ' . $payment_meta['email'];
            ?>
</li>
									<?php 
            do_action('edd_payment_personal_details_list', $payment_meta, $user_info);
            ?>
								</ul>
							</div>
							<?php 
            $gateway = edd_get_payment_gateway($payment->ID);
            if ($gateway) {
                ?>
							<div class="payment-method">
								<h4><?php 
                _e('Payment Method:', 'edd');
                ?>
</h4>
								<span class="payment-method-name"><?php 
                echo edd_get_gateway_admin_label($gateway);
                ?>
</span>
							</div>
							<?php 
            }
            ?>
							<div class="purchase-key-wrap">
								<h4><?php 
            _e('Purchase Key', 'edd');
            ?>
</h4>
								<span class="purchase-key"><?php 
            echo $payment_meta['key'];
            ?>
</span>
							</div>
							<p><a id="edd-close-purchase-details" class="button-secondary" onclick="tb_remove();" title="<?php 
            _e('Close', 'edd');
            ?>
"><?php 
            _e('Close', 'edd');
            ?>
</a></p>
						</div>
					</td>
				</tr>
				<?php 
        }
        // end foreach
        ?>
			</tbody>
		</table>
	</div>
	<?php 
    }
    // end if
}
/**
 * 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;
}
/**
 * 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;
}
/**
 * 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);
}
 /**
  * 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;
 }
 /**
  * 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;
 }
 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 .= "&nbsp;" . edd_get_price_option_name($item_id, $price_id);
         }
     }
     return $title;
 }
/**
 * Process the license upgrade during purchase
 *
 * @since 3.3
 * @return void
 */
function edd_sl_process_license_upgrade($download_id = 0, $payment_id = 0, $type = 'default', $cart_item = array(), $cart_index = 0)
{
    // Bail if this is not a renewal item
    if (empty($cart_item['item_number']['options']['is_upgrade'])) {
        return;
    }
    $license_id = $cart_item['item_number']['options']['license_id'];
    $upgrade_id = $cart_item['item_number']['options']['upgrade_id'];
    $upgrade = edd_sl_get_upgrade_path($download_id, $upgrade_id);
    $old_payment_ids = get_post_meta($license_id, '_edd_sl_payment_id');
    $old_payment_id = end($old_payment_ids);
    // We only want the most recent one
    $old_download_id = edd_software_licensing()->get_download_id($license_id);
    $old_price_id = edd_software_licensing()->get_price_id($license_id);
    $purchase_date = get_post_field('post_date', $old_payment_id);
    if (edd_is_bundled_product($download_id)) {
        // Upgrade to a bundle from a standard license
        $downloads = array();
        $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);
}
Beispiel #14
0
/**
 * 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% &rarr;</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);
                    ?>
">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>
									<?php 
                }
                ?>

									<?php 
                if ($license['price_id'] == 2) {
                    // professional
                    ?>
										<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>
									<?php 
                }
                ?>
								</ul>

							<?php 
            }
            ?>

						</div>

					<?php 
        }
        ?>

				<?php 
    } else {
        ?>
					<p>You do not have a license yet. <a href="<?php 
        echo site_url('pricing');
        ?>
">View pricing &rarr;</a></p>
				<?php 
    }
    ?>
		</div>
		<h2>The Ultimate licence</h2>
		<ul>
			<li>Access all <?php 
    echo $professional_add_ons;
    ?>
 pro add-ons, including any built in the future</li>
			<li>Use AffiliateWP on as many sites as you'd like</li>
			<li>Receive unlimited updates and support &mdash; you'll never have to renew your license</li>
		</ul>

		<h2>The Professional licence</h2>
		<ul>
			<li>Access all <?php 
    echo $professional_add_ons;
    ?>
 pro add-ons, including any built in the future</li>
			<li>Use AffiliateWP on as many sites as you'd like</li>
			<li>1 year of updates and support</li>
		</ul>

	</div>

	<?php 
}
					<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&amp;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()));
		<?php 
    foreach ($upgrades as $upgrade_id => $upgrade) {
        ?>
			<tr class="edd_sl_license_row">
				<?php 
        do_action('edd_sl_license_upgrades_row_start', $license_id);
        ?>
				<td>
					<?php 
        echo get_the_title($upgrade['download_id']);
        ?>
					<?php 
        if (isset($upgrade['price_id']) && edd_has_variable_prices($upgrade['download_id'])) {
            ?>
						- <?php 
            echo edd_get_price_option_name($upgrade['download_id'], $upgrade['price_id']);
            ?>
					<?php 
        }
        ?>
				</td>
				<td><?php 
        echo edd_currency_filter(edd_sanitize_amount(edd_sl_get_license_upgrade_cost($license_id, $upgrade_id)));
        ?>
</td>
				<td><a href="<?php 
        echo esc_url(edd_sl_get_license_upgrade_url($license_id, $upgrade_id));
        ?>
" title="<?php 
        esc_attr_e('Upgrade License', 'edd_sl');
        ?>
/**
 * 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);
                }
            }
        }
    }
}
 /**
  * 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) {
         // skip over payments that don't have upsells in them
         if (!get_post_meta($payment->ID, '_edd_payment_upsell_total', true)) {
             continue;
         }
         $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_csau_get_payment_amount($payment->ID, 'upsell');
         $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) {
                 // skip over downloads which aren't upsells
                 if (!isset($download['item_number']['upsell'])) {
                     continue;
                 }
                 // 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;
 }
        ?>
			<tr class="edd_sl_license_row">
				<?php 
        do_action('edd_sl_license_row_start', $license->ID);
        ?>
				<td>
					<?php 
        $download_id = $edd_sl->get_download_id($license->ID);
        $price_id = $edd_sl->get_price_id($license->ID);
        echo get_the_title($download_id);
        ?>
					<?php 
        if ('' !== $price_id) {
            ?>
						<span class="edd_sl_license_price_option">&ndash;&nbsp;<?php 
            echo edd_get_price_option_name($download_id, $price_id);
            ?>
</span>
					<?php 
        }
        ?>
				</td>
				<td>
					<span class="view-key-wrapper">
						<a href="#" class="edd_sl_show_key" title="<?php 
        _e('Click to view license key', 'edd_sl');
        ?>
"><img src="<?php 
        echo EDD_SL_PLUGIN_URL . '/images/key.png';
        ?>
"/></a>
/**
 * 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 .= "&nbsp;&ndash;&nbsp;" . __('SKU', 'edd') . ': ' . $sku;
                }
                if ($price_id !== false) {
                    $title .= "&nbsp;&ndash;&nbsp;" . 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 .= ' &mdash; <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;
}
/**
 * Email template tag: download_list
 * A list of download links for each download purchased in plaintext
 *
 * @since 2.1.1
 * @param int $payment_id
 *
 * @return string download_list
 */
function edd_email_tag_download_list_plain($payment_id)
{
    $payment_data = edd_get_payment_meta($payment_id);
    $cart_items = edd_get_payment_meta_cart_details($payment_id);
    $email = edd_get_payment_user_email($payment_id);
    $download_list = '';
    if ($cart_items) {
        $show_names = apply_filters('edd_email_show_names', true);
        $show_links = apply_filters('edd_email_show_links', true);
        foreach ($cart_items as $item) {
            if (edd_use_skus()) {
                $sku = edd_get_download_sku($item['id']);
            }
            if (edd_item_quantities_enabled()) {
                $quantity = $item['quantity'];
            }
            $price_id = edd_get_cart_item_price_id($item);
            if ($show_names) {
                $title = get_the_title($item['id']);
                if (!empty($quantity) && $quantity > 1) {
                    $title .= __('Quantity', 'easy-digital-downloads') . ': ' . $quantity;
                }
                if (!empty($sku)) {
                    $title .= __('SKU', 'easy-digital-downloads') . ': ' . $sku;
                }
                if ($price_id !== null) {
                    $title .= edd_get_price_option_name($item['id'], $price_id, $payment_id);
                }
                $download_list .= "\n";
                $download_list .= apply_filters('edd_email_receipt_download_title', $title, $item, $price_id, $payment_id) . "\n";
            }
            $files = edd_get_download_files($item['id'], $price_id);
            if (!empty($files)) {
                foreach ($files as $filekey => $file) {
                    if ($show_links) {
                        $download_list .= "\n";
                        $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $item['id'], $price_id);
                        $download_list .= edd_get_file_name($file) . ': ' . $file_url . "\n";
                    } else {
                        $download_list .= "\n";
                        $download_list .= edd_get_file_name($file) . "\n";
                    }
                }
            } 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, 'download_list');
                foreach ($bundled_products as $bundle_item) {
                    $download_list .= '<div class="edd_bundled_product"><strong>' . get_the_title($bundle_item) . '</strong></div>';
                    $files = edd_get_download_files($bundle_item);
                    foreach ($files as $filekey => $file) {
                        if ($show_links) {
                            $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $bundle_item, $price_id);
                            $download_list .= $file['name'] . ': ' . $file_url . "\n";
                        } else {
                            $download_list .= $file['name'] . "\n";
                        }
                    }
                }
            }
            if ('' != edd_get_product_notes($item['id'])) {
                $download_list .= "\n";
                $download_list .= edd_get_product_notes($item['id']) . "\n";
            }
        }
    }
    return $download_list;
}
/**
 * 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 
}
					<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">&nbsp;&ndash;&nbsp;<?php 
                    echo edd_get_price_option_name($item['id'], $price_id);
                    ?>
</span>
							<?php 
                }
                ?>
						</div>

						<?php 
                if ($edd_receipt_args['notes']) {
                    ?>
							<div class="edd_purchase_receipt_product_notes"><?php 
                    echo edd_get_product_notes($item['id']);
                    ?>
</div>
						<?php 
Beispiel #24
0
/**
 * Retrieve the plan ID from the purchased items
 *
 * @access      public
 * @since       1.5
 * @return      string|bool
 */
function edds_get_plan_id($purchase_data)
{
    foreach ($purchase_data['downloads'] as $download) {
        if (edd_has_variable_prices($download['id'])) {
            $prices = edd_get_variable_prices($download['id']);
            $price_name = edd_get_price_option_name($download['id'], $download['options']['price_id']);
            $price_amount = $prices[$download['options']['price_id']]['amount'];
        } else {
            $price_name = get_post_field('post_name', $download['id']);
            $price_amount = edd_get_download_price($download['id']);
        }
        $period = $download['options']['recurring']['period'];
        $plan_id = $price_name . '_' . $price_amount . '_' . $period;
        return sanitize_key($plan_id);
    }
    return false;
}
 /**
  * Retrieves Recent Sales
  *
  * @access public
  * @since  1.5
  * @return array
  */
 public function get_recent_sales()
 {
     global $wp_query;
     $sales = array();
     if (!user_can($this->user_id, 'view_shop_reports') && !$this->override) {
         return $sales;
     }
     if (isset($wp_query->query_vars['id'])) {
         $query = array();
         $query[] = new EDD_Payment($wp_query->query_vars['id']);
     } elseif (isset($wp_query->query_vars['purchasekey'])) {
         $query = array();
         $query[] = edd_get_payment_by('key', $wp_query->query_vars['purchasekey']);
     } elseif (isset($wp_query->query_vars['email'])) {
         $query = edd_get_payments(array('fields' => 'ids', 'meta_key' => '_edd_payment_user_email', 'meta_value' => $wp_query->query_vars['email'], 'number' => $this->per_page(), 'page' => $this->get_paged(), 'status' => 'publish'));
     } else {
         $query = edd_get_payments(array('fields' => 'ids', 'number' => $this->per_page(), 'page' => $this->get_paged(), 'status' => 'publish'));
     }
     if ($query) {
         $i = 0;
         foreach ($query as $payment) {
             if (is_numeric($payment)) {
                 $payment = new EDD_Payment($payment);
             }
             $payment_meta = $payment->get_meta();
             $user_info = $payment->user_info;
             $sales['sales'][$i]['ID'] = $payment->number;
             $sales['sales'][$i]['transaction_id'] = $payment->transaction_id;
             $sales['sales'][$i]['key'] = $payment->key;
             $sales['sales'][$i]['discount'] = !empty($payment->discounts) ? explode(',', $payment->discounts) : array();
             $sales['sales'][$i]['subtotal'] = $payment->subtotal;
             $sales['sales'][$i]['tax'] = $payment->tax;
             $sales['sales'][$i]['fees'] = $payment->fees;
             $sales['sales'][$i]['total'] = $payment->total;
             $sales['sales'][$i]['gateway'] = $payment->gateway;
             $sales['sales'][$i]['email'] = $payment->email;
             $sales['sales'][$i]['date'] = $payment->date;
             $sales['sales'][$i]['products'] = array();
             $c = 0;
             foreach ($payment->cart_details as $key => $item) {
                 $item_id = isset($item['id']) ? $item['id'] : $item;
                 $price = isset($item['price']) ? $item['price'] : false;
                 $price_id = isset($item['item_number']['options']['price_id']) ? $item['item_number']['options']['price_id'] : null;
                 $quantity = isset($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
                 if (!$price) {
                     // This function is only used on payments with near 1.0 cart data structure
                     $price = edd_get_download_final_price($item_id, $user_info, null);
                 }
                 $price_name = '';
                 if (isset($item['item_number']) && isset($item['item_number']['options'])) {
                     $price_options = $item['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]['id'] = $item_id;
                 $sales['sales'][$i]['products'][$c]['quantity'] = $quantity;
                 $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;
 }
					<?php 
        }
        ?>
				</td>
				<td class="edd_purchased_files">
					<?php 
        // Show a list of downloadable files
        $downloads = edd_get_payment_meta_downloads($post->ID);
        if ($downloads) {
            foreach ($downloads as $download) {
                $id = isset($purchase_data['cart_details']) ? $download['id'] : $download;
                $price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
                $download_files = edd_get_download_files($id, $price_id);
                $name = get_the_title($id);
                if (isset($download['options']['price_id'])) {
                    $name .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $post->ID);
                }
                echo '<div class="edd_purchased_download_name">' . esc_html($name) . '</div>';
                if (!edd_no_redownload()) {
                    if ($download_files) {
                        foreach ($download_files as $filekey => $file) {
                            $download_url = edd_get_download_file_url($purchase_data['key'], $purchase_data['email'], $filekey, $id, $price_id);
                            echo '<div class="edd_download_file"><a href="' . esc_url($download_url) . '" class="edd_download_file_link">' . esc_html($file['name']) . '</a></div>';
                            do_action('edd_purchase_history_files', $filekey, $file, $id, $post->ID, $purchase_data);
                        }
                    } else {
                        _e('No downloadable files found.', 'edd');
                    }
                }
                // End if ! edd_no_redownload()
            }
            $price = edd_get_download_final_price($item_id, $user_info, null);
        }
        ?>

											<li class="download">
												<span>
													<a href="<?php 
        echo admin_url('post.php?post=' . $item_id . '&action=edit');
        ?>
">
														<?php 
        echo get_the_title($item_id);
        if (isset($cart_items[$key]['item_number']) && isset($cart_items[$key]['item_number']['options'])) {
            $price_options = $cart_items[$key]['item_number']['options'];
            if (isset($price_id)) {
                echo ' - ' . edd_get_price_option_name($item_id, $price_id, $payment_id);
            }
        }
        ?>
													</a>
												</span>
												<input type="hidden" name="edd-payment-details-downloads[<?php 
        echo $key;
        ?>
][id]" class="edd-payment-details-download-id" value="<?php 
        echo esc_attr($item_id);
        ?>
"/>
												<input type="hidden" name="edd-payment-details-downloads[<?php 
        echo $key;
        ?>
/**
 * 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
                    if (!empty($download['item_number']['options']['is_renewal'])) {
                        update_post_meta($commission_id, '_edd_commission_is_renewal', true);
                    }
                    do_action('eddc_insert_commission', $recipient, $commission_amount, $rate, $download_id, $commission_id, $payment_id);
                }
            }
        }
    }
}
					<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">&nbsp;&ndash;&nbsp;<?php 
                    echo edd_get_price_option_name($item['id'], $price_id, $payment->ID);
                    ?>
</span>
							<?php 
                }
                ?>
						</div>

						<?php 
                if ($edd_receipt_args['notes']) {
                    ?>
							<div class="edd_purchase_receipt_product_notes"><?php 
                    echo wpautop(edd_get_product_notes($item['id']));
                    ?>
</div>
						<?php 
        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()) {
                    ?>
							<td class="edd_download_download_files">
								<?php 
                    if ('publish' == $payment->post_status) {
                        if ($download_files) {