/** * Given a User ID, return the markup for the list of user's products that earn commissions * * @param integer $user_id The User ID to get the commissioned products for * @return string HTML markup for the list of products */ function eddc_user_product_list($user_id = 0) { $user_id = empty($user_id) ? get_current_user_id() : $user_id; if (empty($user_id)) { return; } $products = eddc_get_download_ids_of_user($user_id); if (empty($products)) { return; } $header_text = __('Your Products', 'eddc'); if ($user_id != get_current_user_id()) { $user_info = get_userdata($user_id); $header_text = sprintf(__('%s\'s Products', 'eddc'), $user_info->display_name); } ob_start(); ?> <div id="edd_commissioned_products"> <h3 class="edd_commissioned_products_header"><?php echo $header_text; ?> </h3> <table id="edd_commissioned_products_table"> <thead> <tr> <?php do_action('edd_commissioned_products_head_row_begin'); ?> <th class="edd_commissioned_item"><?php _e('Item', 'eddc'); ?> </th> <th class="edd_commissioned_sales"><?php _e('Sales', 'eddc'); ?> </th> <?php do_action('edd_commissioned_products_head_row_end'); ?> </tr> </thead> <tbody> <?php if (!empty($products)) { ?> <?php foreach ($products as $product) { if (!get_post($product)) { continue; } ?> <tr class="edd_user_commission_row"> <?php do_action('edd_commissioned_products_row_begin', $product, $user_id); ?> <td class="edd_commissioned_item"><?php echo get_the_title($product); ?> </td> <td class="edd_commissioned_sales"><?php echo edd_get_download_sales_stats($product); ?> </td> <?php do_action('edd_commissioned_products_row_end', $product, $user_id); ?> </tr> <?php } ?> <?php } else { ?> <tr class="edd_commissioned_products_row_empty"> <td colspan="4"><?php _e('No item', 'eddc'); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php return ob_get_clean(); }
function eddc_user_product_list() { $user_id = get_current_user_id(); $products = eddc_get_download_ids_of_user($user_id); if (!is_user_logged_in()) { return; } if (empty($products)) { return; } ob_start(); ?> <div id="edd_commissioned_products"> <h3 class="edd_commissioned_products_header"><?php _e('Your Items', 'eddc'); ?> </h3> <table id="edd_commissioned_products_table"> <thead> <tr> <?php do_action('edd_commissioned_products_head_row_begin'); ?> <th class="edd_commissioned_item"><?php _e('Item', 'eddc'); ?> </th> <th class="edd_commissioned_sales"><?php _e('Sales', 'eddc'); ?> </th> <?php do_action('edd_commissioned_products_head_row_end'); ?> </tr> </thead> <tbody> <?php if (!empty($products)) { ?> <?php foreach ($products as $product) { if (!get_post($product)) { continue; } ?> <tr class="edd_user_commission_row"> <?php do_action('edd_commissioned_products_row_begin', $product, $user_id); ?> <td class="edd_commissioned_item"><?php echo get_the_title($product); ?> </td> <td class="edd_commissioned_sales"><?php echo edd_get_download_sales_stats($product); ?> </td> <?php do_action('edd_commissioned_products_row_end', $product, $user_id); ?> </tr> <?php } ?> <?php } else { ?> <tr class="edd_commissioned_products_row_empty"> <td colspan="4"><?php _e('No item', 'eddc'); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php return ob_get_clean(); }
/** * Display the commissions area for the customer view * * @since 3.2 * @param object $customer The Customer being displayed * @return void */ function eddc_customer_commissions_view($customer) { ?> <div class="edd-item-notes-header"> <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?> </span> </div> <div id="edd-item-stats-wrapper" class="customer-section"> <ul> <li> <span class="dashicons dashicons-chart-area"></span> <?php echo edd_currency_filter(edd_format_amount(eddc_get_paid_totals($customer->user_id))); ?> <?php _e('Paid Commissions', 'eddc'); ?> <?php $paid_sales = eddc_count_user_commissions($customer->user_id, 'paid'); ?> <?php if (!empty($paid_sales)) { ?> <br /> <a title="<?php _e('View All Paid Commissions', 'edd'); ?> " href="<?php echo admin_url('edit.php?post_type=download&page=edd-commissions&view=paid&user='******'via %d sale', 'via %d sales', $paid_sales, 'eddc'), $paid_sales); ?> </a> <?php } ?> </li> <li> <span class="dashicons dashicons-chart-area"></span> <?php echo edd_currency_filter(edd_format_amount(eddc_get_unpaid_totals($customer->user_id))); ?> <?php _e('Unpaid Commissions', 'eddc'); ?> <?php $unpaid_sales = eddc_count_user_commissions($customer->user_id, 'unpaid'); ?> <?php if (!empty($unpaid_sales)) { ?> <br /> <a title="<?php _e('View All Unpaid Commissions', 'edd'); ?> " href="<?php echo admin_url('edit.php?post_type=download&page=edd-commissions&view=unpaid&user='******'via %d sale', 'via %d sales', $unpaid_sales, 'eddc'), $unpaid_sales); ?> </a> <?php } ?> </li> </ul> </div> <?php $downloads = eddc_get_download_ids_of_user($customer->user_id); ?> <?php if (false !== $downloads) { ?> <div id="edd-item-tables-wrapper" class="customer-section"> <h3><?php printf(__('Commissioned %s', 'eddc'), edd_get_label_plural()); ?> </h3> <table class="wp-list-table widefat striped downloads"> <thead> <tr> <th><?php echo edd_get_label_singular(); ?> </th> <th><?php _e('Rate', 'eddc'); ?> </th> <th width="120px"><?php _e('Actions', 'eddc'); ?> </th> </tr> </thead> <tbody> <?php if (!empty($downloads)) { ?> <?php foreach ($downloads as $download) { ?> <?php $download = new EDD_Download($download); ?> <?php $commission_type = eddc_get_commission_type($download->ID); ?> <?php $commission_rate = eddc_get_recipient_rate($download->ID, $customer->user_id); ?> <tr> <td><?php echo $download->post_title; ?> </td> <td> <?php if ($commission_type === 'percentage') { ?> <?php echo $commission_rate; ?> % <?php } else { ?> <?php echo edd_currency_filter(edd_format_amount($commission_rate)); ?> <?php } ?> </td> <td> <a title="<?php echo esc_attr(sprintf(__('View %s', 'edd'), $download->post_title)); ?> " href="<?php echo esc_url(admin_url('post.php?action=edit&post=' . $download->ID)); ?> "> <?php printf(__('View %s', 'eddc'), edd_get_label_singular()); ?> </a> </td> </tr> <?php } ?> <?php } else { ?> <tr><td colspan="2"><?php printf(__('No %s Found', 'eddc'), edd_get_label_plural()); ?> </td></tr> <?php } ?> </tbody> </table> </div> <?php } ?> <div id="edd-item-tables-wrapper" class="customer-section"> <h3><?php _e('Recent Unpaid Commissions', 'edd'); ?> </h3> <?php $args = array('user_id' => $customer->user_id, 'number' => 10); $commissions = eddc_get_unpaid_commissions($args); ?> <table class="wp-list-table widefat striped payments"> <thead> <tr> <th><?php _e('ID', 'edd'); ?> </th> <th><?php _e('Item', 'edd'); ?> </th> <th><?php _e('Amount', 'edd'); ?> </th> </tr> </thead> <tbody> <?php if (!empty($commissions)) { ?> <?php foreach ($commissions as $commission) { ?> <?php $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true); ?> <tr> <td><?php echo $commission->ID; ?> </td> <td><?php echo get_the_title(get_post_meta($commission->ID, '_download_id', true)); ?> </td> <td><?php echo edd_currency_filter(edd_sanitize_amount($commission_meta['amount'])); ?> </td> </tr> <?php } ?> <?php } else { ?> <tr><td colspan="5"><?php _e('No unpaid commissions', 'edd'); ?> </td></tr> <?php } ?> </tbody> </table> </div> <?php }