/** * Register the commissions view for the customer interface * * @since 3.2 * @param array $tabs The tabs currently added to the customer views * @return array Updated tabs array */ function eddc_customer_view($views) { $customer_id = isset($_GET['id']) ? absint($_GET['id']) : false; $customer = new EDD_Customer($customer_id); if ($customer->user_id && eddc_user_has_commissions($customer->user_id)) { $views['commissions'] = 'eddc_customer_commissions_view'; } return $views; }
/** * Register Dashboard Widgets * * Registers the dashboard widgets. * * @access private * @since 1.6 */ function eddc_register_dashboard_commission_widgets() { if (eddc_user_has_commissions()) { wp_add_dashboard_widget('edd_dashboard_user_commissions', __('Commissions Summary', 'edd'), 'eddc_dashboard_commissions_widget'); } }
<?php if (EDD_FES()->integrations->is_commissions_active()) { ?> <h1 class="fes-headers" id="fes-commissions-page-title"><?php _e('Commissions Overview', 'edd_fes'); ?> </h1> <?php if (eddc_user_has_commissions()) { echo do_shortcode('[edd_commissions]'); } else { echo __('You haven\'t made any sales yet!', 'edd_fes'); } } else { echo 'Error 4908'; }
function eddc_generate_user_export_file($data) { $user_id = !empty($data['user_id']) ? intval($data['user_id']) : get_current_user_id(); if (empty($user_id) || !eddc_user_has_commissions($user_id)) { return; } include_once EDDC_PLUGIN_DIR . 'includes/class-commissions-export.php'; $export = new EDD_Commissions_Export(); $export->user_id = $user_id; $export->year = $data['year']; $export->month = $data['month']; $export->export(); }
function eddc_generate_user_export_file($data) { if (!is_user_logged_in() || !eddc_user_has_commissions()) { return; } include_once EDDC_PLUGIN_DIR . 'includes/class-commissions-export.php'; $export = new EDD_Commissions_Export(); $export->user_id = get_current_user_id(); $export->year = $data['year']; $export->month = $data['month']; $export->export(); }
function eddc_user_commissions() { global $user_ID; if (!is_user_logged_in()) { return; } $unpaid_paged = isset($_GET['eddcup']) ? absint($_GET['eddcup']) : 1; $paid_paged = isset($_GET['eddcp']) ? absint($_GET['eddcp']) : 1; $unpaid_commissions = eddc_get_unpaid_commissions(array('user_id' => $user_ID, 'number' => 20, 'paged' => $unpaid_paged)); $paid_commissions = eddc_get_paid_commissions(array('user_id' => $user_ID, 'number' => 20, 'paged' => $paid_paged)); $total_unpaid = eddc_count_user_commissions($user_ID, 'unpaid'); $total_paid = eddc_count_user_commissions($user_ID, 'paid'); $unpaid_offset = 20 * ($unpaid_paged - 1); $unpaid_total_pages = ceil($total_unpaid / 20); $paid_offset = 20 * ($paid_paged - 1); $paid_total_pages = ceil($total_paid / 20); $stats = ''; if (eddc_user_has_commissions()) { // only show tables if user has commission data ob_start(); ?> <div id="edd_user_commissions"> <!-- unpaid --> <div id="edd_user_commissions_unpaid"> <h3 class="edd_user_commissions_header"><?php _e('Unpaid Commissions', 'eddc'); ?> </h3> <table id="edd_user_unpaid_commissions_table" class="edd_user_commissions"> <thead> <tr class="edd_user_commission_row"> <?php do_action('eddc_user_commissions_unpaid_head_row_begin'); ?> <th class="edd_commission_item"><?php _e('Item', 'eddc'); ?> </th> <th class="edd_commission_amount"><?php _e('Amount', 'eddc'); ?> </th> <th class="edd_commission_rate"><?php _e('Rate', 'eddc'); ?> </th> <th class="edd_commission_date"><?php _e('Date', 'eddc'); ?> </th> <?php do_action('eddc_user_commissions_unpaid_head_row_end'); ?> </tr> </thead> <tbody> <?php $total = (double) 0; ?> <?php if (!empty($unpaid_commissions)) { ?> <?php foreach ($unpaid_commissions as $commission) { ?> <tr class="edd_user_commission_row"> <?php do_action('eddc_user_commissions_unpaid_row_begin', $commission); $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true)); $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true); $amount = $commission_info['amount']; $rate = $commission_info['rate']; ?> <td class="edd_commission_item"><?php echo esc_html($item_name); ?> </td> <td class="edd_commission_amount"><?php echo edd_currency_filter(edd_format_amount($amount)); ?> </td> <td class="edd_commission_rate"><?php echo $rate . '%'; ?> </td> <td class="edd_commission_date"><?php echo date_i18n(get_option('date_format'), strtotime($commission->post_date)); ?> </td> <?php do_action('eddc_user_commissions_unpaid_row_end', $commission); ?> </tr> <?php } ?> <?php } else { ?> <tr class="edd_user_commission_row edd_row_empty"> <td colspan="4"><?php _e('No unpaid commissions', 'eddc'); ?> </td> </tr> <?php } ?> </tbody> </table> <div id="edd_user_commissions_unpaid_total"><?php _e('Total unpaid:', 'eddc'); ?> <?php echo edd_currency_filter(edd_format_amount(eddc_get_unpaid_totals($user_ID))); ?> </div> <div id="edd_commissions_unpaid_pagination" class="navigation"> <?php $big = 999999; echo paginate_links(array('base' => remove_query_arg('eddcup', edd_get_current_page_url()) . '%_%#edd_user_commissions_unpaid', 'format' => '?eddcup=%#%', 'current' => max(1, $unpaid_paged), 'total' => $unpaid_total_pages)); ?> </div> </div><!--end #edd_user_commissions_unpaid--> <!-- paid --> <div id="edd_user_commissions_paid"> <h3 class="edd_user_commissions_header"><?php _e('Paid Commissions', 'eddc'); ?> </h3> <table id="edd_user_paid_commissions_table" class="edd_user_commissions"> <thead> <tr class="edd_user_commission_row"> <?php do_action('eddc_user_commissions_paid_head_row_begin'); ?> <th class="edd_commission_item"><?php _e('Item', 'eddc'); ?> </th> <th class="edd_commission_amount"><?php _e('Amount', 'eddc'); ?> </th> <th class="edd_commission_rate"><?php _e('Rate', 'eddc'); ?> </th> <th class="edd_commission_date"><?php _e('Date', 'eddc'); ?> </th> <?php do_action('eddc_user_commissions_paid_head_row_end'); ?> </tr> </thead> <tbody> <?php $total = (double) 0; ?> <?php if (!empty($paid_commissions)) { ?> <?php foreach ($paid_commissions as $commission) { ?> <tr class="edd_user_commission_row"> <?php do_action('eddc_user_commissions_paid_row_begin', $commission); $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true)); $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true); $amount = $commission_info['amount']; $rate = $commission_info['rate']; ?> <td class="edd_commission_item"><?php echo esc_html($item_name); ?> </td> <td class="edd_commission_amount"><?php echo edd_currency_filter($amount); ?> </td> <td class="edd_commission_rate"><?php echo $rate . '%'; ?> </td> <td class="edd_commission_date"><?php echo date_i18n(get_option('date_format'), strtotime($commission->post_date)); ?> </td> <?php do_action('eddc_user_commissions_paid_row_end', $commission); ?> </tr> <?php } ?> <?php } else { ?> <tr class="edd_user_commission_row edd_row_empty"> <td colspan="4"><?php _e('No paid commissions', 'eddc'); ?> </td> </tr> <?php } ?> </tbody> </table> <div id="edd_user_commissions_paid_total"><?php _e('Total paid:', 'eddc'); ?> <?php echo edd_currency_filter(edd_format_amount(eddc_get_paid_totals($user_ID))); ?> </div> <div id="edd_commissions_paid_pagination" class="navigation"> <?php $big = 999999; echo paginate_links(array('base' => remove_query_arg('eddcp', edd_get_current_page_url()) . '%_%#edd_user_commissions_paid', 'format' => '?eddcp=%#%', 'current' => max(1, $paid_paged), 'total' => $paid_total_pages)); ?> </div> <div id="edd_commissions_export"> <p><strong><?php _e('Export Paid Commissions', 'eddc'); ?> </strong></p> <form method="post" action="<?php echo home_url(); ?> "> <?php echo EDD()->html->month_dropdown(); ?> <?php echo EDD()->html->year_dropdown(); ?> <input type="hidden" name="edd_action" value="generate_commission_export"/> <input type="submit" class="edd-submit button" value="<?php _e('Download CSV', 'eddc'); ?> "/> </form><br/> </div> </div><!--end #edd_user_commissions_paid--> </div><!--end #edd_user_commissions--> <?php $stats = apply_filters('edd_user_commissions_display', ob_get_clean()); } return $stats; }
/** * Display the field to edit the PayPal email address in the profile editor * * @since 3.2 * @return void */ function eddc_profile_editor_paypal() { $user_id = get_current_user_id(); if (!eddc_user_has_commissions($user_id)) { return; } $custom_paypal = get_user_meta($user_id, 'eddc_user_paypal', true); $email = is_email($custom_paypal) ? $custom_paypal : ''; ?> <p> <strong><?php _e('Commissions', 'eddc'); ?> </strong><br /> <label for="eddc-paypal-email"><?php _e('PayPal Email Address', 'eddc'); ?> </label> <input name="eddc_paypal_email" id="eddc-paypal-email" class="text edd-input" type="email" value="<?php echo esc_attr($email); ?> " /> </p> <?php }
public function show_page() { $vendor = isset($_GET['vendor']) ? absint($_GET['vendor']) : false; if (!$vendor) { echo __('Invalid ID', 'edd_fes'); exit; } if (!user_can(get_current_user_id(), 'manage_shop_settings')) { echo __('Access Denied', 'edd_fes'); exit; } $user = get_userdata($vendor); echo '<div class="wrap about-wrap"><h2>' . __('Vendor: ', 'edd_fes') . $user->display_name . ' (' . __('ID', 'edd_fes') . ': ' . $user->ID . ')</h2>'; $message = false; if (isset($_GET['approved']) && $_GET['approved'] == '2') { ?> <div class="updated"> <p><?php printf(__('%s approved!', 'edd_fes'), EDD_FES()->vendors->get_vendor_constant_name($plural = false, $uppercase = true)); ?> </p> </div> <?php } ?> <style> #fes-vendor-edit-page{display:none;} div.fes-fields{clear:both;} </style> <script type="text/javascript"> // This is super hackish but it works so well! (jQuery)(document).ready(function(){ (jQuery)(".updated p").prepend("<?php printf(__('%s updated!', 'edd_fes'), EDD_FES()->vendors->get_vendor_constant_name($plural = false, $uppercase = true)); ?> "); }); </script> <h2 class="nav-tab-wrapper"> <a href="#fes-metabox" class="nav-tab" id="fes-editor-tab"><?php printf(__('%s Overview', 'edd_fes'), EDD_FES()->vendors->get_vendor_constant_name($plural = false, $uppercase = true)); ?> </a> <a href="#fes-metabox-registration-form" class="nav-tab" id="fes-registration-form"><?php _e('Application Form', 'edd_fes'); ?> </a> <a href="#fes-metabox-profile-form" class="nav-tab" id="fes-post-settings-form-tab"><?php _e('Profile Form', 'edd_fes'); ?> </a> <a href="#fes-metabox-products" class="nav-tab" id="fes-products-tab"><?php _e('Products', 'edd_fes'); ?> </a> <?php if (EDD_FES()->integrations->is_commissions_active()) { ?> <a href="<?php echo esc_url(admin_url('edit.php?post_type=download&page=edd-commissions&user='******'Commissions', 'edd_fes'); ?> </a> <?php } ?> <?php do_action('fes_edit_vendor_form_tab'); ?> </h2> <div class="tab-content"> <div id="fes-metabox" class="group"> <div class="fes-form"> <fieldset> <?php _e('Name: ', 'edd_fes'); ?> </td><td><?php echo $user->display_name; ?> </fieldset> <fieldset> <?php _e('Status: ', 'edd_fes'); if (user_can($user->ID, 'fes_is_admin') || user_can($user->ID, 'frontend_vendor')) { _e('Frontend Vendor', 'edd_fes'); } else { if (user_can($user->ID, 'pending_vendor')) { _e('Pending Vendor', 'edd_fes'); } else { if (user_can($user->ID, 'suspended_vendor')) { _e('Suspended Vendor', 'edd_fes'); } else { _e('Error!', 'edd_fes'); } } } ?> </fieldset> <fieldset> <?php printf(__('Total %s: ', 'edd_fes'), EDD_FES()->vendors->get_product_constant_name($plural = true, $uppercase = true)); ?> </td><td><?php echo EDD_FES()->vendors->get_all_products_count($user->ID, array('publish', 'pending', 'trash')); ?> <br> <?php printf(__('Live %s: ', 'edd_fes'), EDD_FES()->vendors->get_product_constant_name($plural = true, $uppercase = true)); ?> </td><td><?php echo EDD_FES()->vendors->get_all_products_count($user->ID, 'publish'); ?> <br> <?php printf(__('Pending %s: ', 'edd_fes'), EDD_FES()->vendors->get_product_constant_name($plural = true, $uppercase = true)); ?> </td><td><?php echo EDD_FES()->vendors->get_all_products_count($user->ID, 'pending'); ?> <br> <?php printf(__('Trashed %s: ', 'edd_fes'), EDD_FES()->vendors->get_product_constant_name($plural = true, $uppercase = true)); ?> </td><td><?php echo EDD_FES()->vendors->get_all_products_count($user->ID, 'trash'); ?> <br> </fieldset> <fieldset> <?php _e('Actions: ', 'edd_fes'); if (user_can($user->ID, 'fes_is_admin') || user_can($user->ID, 'frontend_vendor')) { ?> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=revoke_vendor&redirect=2'); ?> "><?php _e('Revoke', 'edd_fes'); ?> </a> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=suspend_vendor&redirect=2'); ?> "><?php _e('Suspend', 'edd_fes'); ?> </a> <?php } else { if (user_can($user->ID, 'pending_vendor')) { ?> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=approve_vendor&redirect=2'); ?> "><?php _e('Approve', 'edd_fes'); ?> </a> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=decline_vendor&redirect=2'); ?> "><?php _e('Decline', 'edd_fes'); ?> </a> <?php } else { if (user_can($user->ID, 'suspended_vendor')) { ?> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=unsuspend_vendor&redirect=2'); ?> "><?php _e('Unsuspend', 'edd_fes'); ?> </a> <a href="<?php echo admin_url('admin.php?page=fes-vendors&vendor=' . $user->ID . '&action=revoke_vendor&redirect=2'); ?> "><?php _e('Revoke', 'edd_fes'); ?> </a> <?php } } } ?> </fieldset> </div> </div> <div id="fes-metabox-registration-form" class="group"> <?php EDD_FES()->forms->render_form('registration', $user->ID, true, $args = array('backend' => true)); ?> </div> <div id="fes-metabox-profile-form" class="group"> <?php EDD_FES()->forms->render_form('profile', $user->ID, false, $args = array('backend' => true)); ?> </div> <div id="fes-metabox-products" class="group"> <?php $concat = get_option("permalink_structure") ? "?" : "&"; $products = EDD_FES()->vendors->get_all_products($user->ID); $sales = 0; $earnings = 0; if (!empty($products)) { ?> <table class="widefat" id="fes-all-products"> <thead> <tr> <th><?php _e('ID', 'edd_fes'); ?> </th> <th><?php _e('Title', 'edd_fes'); ?> </th> <th><?php _e('Status', 'edd_fes'); ?> </th> <th><?php _e('Sales', 'edd_fes'); ?> </th> </tr> </thead> <tbody> <?php foreach ($products as $product) { ?> <tr> <td><?php echo esc_html($product['ID']); ?> </td> <td><a href="<?php echo esc_html($product['url']); ?> "><?php echo esc_html($product['title']); ?> </a></td> <td><?php echo esc_html($product['status']); ?> </td> <td><?php echo esc_html($product['sales']); ?> </td> </tr> <?php $sales += $product['sales']; ?> <?php } ?> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> <tfoot> <td><strong><?php _e('Total Sales', 'edd_fes'); ?> </strong></td> <td></td> <td></td> <td><?php echo $sales; ?> </td> </tfoot> </table> <?php } else { printf(__('%s has no %s', 'edd_fes'), EDD_FES()->vendors->get_vendor_constant_name($plural = false, $uppercase = true), EDD_FES()->vendors->get_product_constant_name($plural = true, $uppercase = false)); } ?> </div> <?php if (EDD_FES()->integrations->is_commissions_active()) { ?> <div id="fes-metabox-commissions" class="group"> <?php if (eddc_user_has_commissions($user->ID)) { echo eddc_user_commissions($user->ID); } else { printf(__('This %s has no sales yet!', 'edd_fes'), EDD_FES()->vendors->get_vendor_constant_name($plural = false, $uppercase = false)); } ?> </div> <?php } do_action('fes_edit_vendor_tab_content'); ?> </div> <?php }