function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'rate':
             $download = get_post_meta($item['ID'], '_download_id', true);
             $type = eddc_get_commission_type($download);
             if ('percentage' == $type) {
                 return $item[$column_name] . '%';
             } else {
                 return edd_currency_filter(edd_sanitize_amount($item[$column_name]));
             }
         case 'status':
             return $item[$column_name];
         case 'amount':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'date':
             return date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $item['ID'])));
         case 'download':
             $download = !empty($item['download']) ? $item['download'] : false;
             return $download ? '<a href="' . esc_url(add_query_arg('download', $download)) . '" title="' . __('View all commissions for this item', 'eddc') . '">' . get_the_title($download) . '</a>' . (!empty($item['variation']) ? ' - ' . $item['variation'] : '') : '';
         case 'payment':
             $payment = get_post_meta($item['ID'], '_edd_commission_payment_id', true);
             return $payment ? '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '" title="' . __('View payment details', 'eddc') . '">#' . $payment . '</a> - ' . edd_get_payment_status(get_post($payment), true) : '';
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.4
  *
  * @param array $item Contains all the data of the log item
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     $return = '';
     switch ($column_name) {
         case 'download':
             $return = '<a href="' . add_query_arg('download', $item[$column_name]) . '" >' . get_the_title($item[$column_name]) . '</a>';
             break;
         case 'user_id':
             $user = !empty($item['user_id']) ? $item['user_id'] : edd_get_payment_user_email($item['payment_id']);
             $return = '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'">' . $item['user_name'] . '</a>';
             break;
         case 'item_price':
             $return = edd_currency_filter(edd_format_amount($item['item_price']));
             break;
         case 'amount':
             $return = edd_currency_filter(edd_format_amount($item['amount'] / $item['quantity']));
             break;
         case 'payment_id':
             $return = '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment_id']) . '">' . edd_get_payment_number($item['payment_id']) . '</a>';
             break;
         default:
             $return = $item[$column_name];
             break;
     }
     return $return;
 }
/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                echo edd_get_download_sales_stats($post_id);
                break;
            case 'earnings':
                echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
/**
 * Adds item to the cart from the wish list via AJAX. Based off edd_ajax_add_to_cart()
 *
 * @since 1.0
 * @return void
 */
function edd_ajax_add_to_cart_from_wish_list()
{
    if (isset($_POST['download_id'])) {
        global $post;
        $to_add = array();
        if (isset($_POST['price_ids']) && is_array($_POST['price_ids'])) {
            foreach ($_POST['price_ids'] as $price) {
                $to_add[] = array('price_id' => $price);
            }
        }
        foreach ($to_add as $options) {
            if ($_POST['download_id'] == $options['price_id']) {
                $options = array();
            }
            parse_str($_POST['post_data'], $post_data);
            if (isset($options['price_id']) && isset($post_data['edd_download_quantity_' . $options['price_id']])) {
                $options['quantity'] = absint($post_data['edd_download_quantity_' . $options['price_id']]);
            } else {
                $options['quantity'] = isset($post_data['edd_download_quantity']) ? absint($post_data['edd_download_quantity']) : 1;
            }
            // call EDD's edd_add_to_cart function
            $key = edd_add_to_cart($_POST['download_id'], $options);
            $item = array('id' => $_POST['download_id'], 'options' => $options);
            $item = apply_filters('edd_wl_ajax_pre_cart_item_template', $item);
            $return = array('add_to_cart' => 'Added to Cart', 'subtotal' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())), ENT_COMPAT, 'UTF-8'), 'cart_item' => html_entity_decode(edd_get_cart_item_template($key, $item, true), ENT_COMPAT, 'UTF-8'));
            echo json_encode($return);
        }
    }
    edd_die();
}
/**
 * Get the allowed deposit levels
 *
 * @since       1.0.0
 * @return      array $levels The allowed deposit levels
 */
function edd_wallet_get_deposit_levels()
{
    $levels = array();
    $initial_levels = apply_filters('edd_wallet_deposit_levels', array('10', '20', '30', '40', '50', '60', '70', '80', '90', '100', '200', '300', '400', '500'));
    foreach ($initial_levels as $level) {
        $levels[$level] = edd_currency_filter(edd_format_amount($level));
    }
    return $levels;
}
function download_lowest_price_function($atts)
{
    $atts = shortcode_atts(array('limit' => -1, 'id' => ''), $atts, 'download_price_lowest');
    if ($atts['id'] != '') {
        $id = $atts['id'];
    } else {
        $id = get_the_id();
    }
    return edd_currency_filter(edd_format_amount(edd_get_download_price($id, false)));
}
/**
 * Display column contents
 *
 * @since       1.0.0
 * @param       string $value The default value for the column
 * @param       int $item_id The ID of the row item
 * @return      string $value The updated value for the column
 */
function edd_wallet_column_data($value, $item_id)
{
    $customer = new EDD_Customer($item_id);
    if ($customer->user_id < 1) {
        return '';
    }
    $value = edd_wallet()->wallet->balance($customer->user_id);
    $value = edd_currency_filter(edd_format_amount((double) $value));
    // Build the wallet link
    $value = '<a href="' . admin_url('edit.php?post_type=download&page=edd-customers&view=wallet&id=' . $item_id) . '" title="' . __('View user wallet', 'edd-wallet') . '">' . $value . '</a>';
    return $value;
}
/**
 * Email Download Purchase Receipt
 *
 * Email the download link(s) and payment confirmation to the buyer.
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_email_purchase_receipt($payment_id, $admin_notice = true)
{
    global $edd_options;
    $payment_data = edd_get_payment_meta($payment_id);
    $user_info = maybe_unserialize($payment_data['user_info']);
    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 = $user_info['email'];
    }
    $message = edd_get_email_body_header();
    $message .= edd_get_email_body_content($payment_id, $payment_data);
    $message .= edd_get_email_body_footer();
    $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
    $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
    $subject = isset($edd_options['purchase_subject']) && strlen(trim($edd_options['purchase_subject'])) > 0 ? edd_email_template_tags($edd_options['purchase_subject'], $payment_data, $payment_id) : __('Purchase Receipt', 'edd');
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    // allow add-ons to add file attachments
    $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data);
    wp_mail($payment_data['email'], $subject, $message, $headers, $attachments);
    if ($admin_notice) {
        /* send an email notification to the admin */
        $admin_email = edd_get_admin_notice_emails();
        $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data);
        $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n";
        $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n";
        $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;
                $download_list .= html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8') . "\n";
            }
        }
        $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true));
        $admin_message .= $download_list . "\n";
        $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
        $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n";
        $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n";
        $admin_message .= __('Thank you', 'edd');
        $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data);
        $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data);
        $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data);
        wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments);
    }
}
 /**
  * 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;
 }
 /**
  * Render most columns
  *
  * @access      private
  * @since       1.4
  * @return      string
  */
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'name':
             return '<a href="' . admin_url('/edit.php?post_type=download&page=edd-payment-history&user='******'email'])) . '">' . esc_html($item[$column_name]) . '</a>';
         case 'amount_spent':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'file_downloads':
             return '<a href="' . admin_url('/edit.php?post_type=download&page=edd-reports&tab=logs&user='******'ID']) ? $item['ID'] : $item['email'])) . '" target="_blank">' . $item['file_downloads'] . '</a>';
         default:
             return $item[$column_name];
     }
 }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.4
  *
  * @param array $item Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'download':
             return '<a href="' . add_query_arg('download', $item[$column_name]) . '" >' . get_the_title($item[$column_name]) . '</a>';
         case 'user_id':
             return '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'user_id'])) . '">' . $item['user_name'] . '</a>';
         case 'amount':
             return edd_currency_filter(edd_format_amount($item['amount']));
         default:
             return $item[$column_name];
     }
 }
 /**
  * Output column data
  *
  * @access      private
  * @since       1.3
  * @return      string
  */
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'earnings':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'average_sales':
             return round($item[$column_name]);
         case 'average_earnings':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         default:
             return $item[$column_name];
     }
 }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.5
  *
  * @param array $item Contains all the data of the downloads
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'earnings':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'average_sales':
             return round($item[$column_name]);
         case 'average_earnings':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'details':
             return '<a href="' . admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $item['ID']) . '">' . __('View Detailed Report', 'easy-digital-downloads') . '</a>';
         default:
             return $item[$column_name];
     }
 }
function download_checkout_item_total_function($atts)
{
    $atts = shortcode_atts(array('id' => ''), $atts, 'download_checkout_item_total');
    global $x, $cart_array;
    if ($atts['id'] != '') {
        $id = $atts['id'];
    } else {
        $id = get_the_id();
    }
    $options = $cart_array[get_the_ID()][$x - 1]['options'];
    $price = edd_get_cart_item_price($id, $options);
    $price += edd_get_cart_item_tax($id, $options, $price);
    $price = edd_currency_filter(edd_format_amount($price));
    return $price;
}
/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $color = $color == 'inherit' ? '' : $color;
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&tab=logs&view=sales&download=' . $post_id)) . '">';
                    echo edd_get_download_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post_id)) . '">';
                    echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.2.6
  *
  * @param array $item Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'id':
             return $item['id'];
         case 'download':
             return '<a href="' . add_query_arg(array('download' => $item['download']), $this->base) . '">' . get_the_title($item['download']) . '</a>';
         case 'source':
             return '<a href="' . add_query_arg(array('source' => $item['source']), $this->base) . '">' . get_the_title($item['source']) . '</a>';
         case 'payment':
             return '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment']) . '">' . $item['payment'] . '</a>';
         case 'amount':
             return edd_currency_filter(edd_format_amount($item['amount']));
         default:
             return $item[$column_name];
     }
 }
function sd_edd_commissions_email_alert($user_id, $commission_amount, $rate, $download_id, $commission_id)
{
    global $edd_options;
    $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
    $from_name = apply_filters('eddc_email_from_name', $from_name, $user_id, $commission_amount, $rate, $download_id);
    $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
    $from_email = apply_filters('eddc_email_from_email', $from_email, $user_id, $commission_amount, $rate, $download_id);
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    /* send an email alert of the sale */
    $user = get_userdata($user_id);
    $email = $user->user_email;
    // set address here
    $message = __('Hello', 'eddc') . "\n\n" . sprintf(__('You have made a new sale on %s!', 'eddc'), stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))) . ".\n\n";
    $variation = get_post_meta($commission_id, '_edd_commission_download_variation', true);
    $message .= __('Item sold: ', 'eddc') . get_the_title($download_id) . (!empty($variation) ? ' - ' . $variation : '') . "\n\n";
    $message .= __('Amount: ', 'eddc') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($commission_amount))) . "\n\n";
    $message .= __('Commission Rate: ', 'eddc') . $rate . "%\n\n";
    $message .= __('Thank you', 'eddc');
    $message = apply_filters('eddc_sale_alert_email', $message, $user_id, $commission_amount, $rate, $download_id);
    wp_mail($email, __('New Sale!', 'eddc'), $message, $headers);
}
 /**
  * Tie into the heartbeat and append our stats
  *
  * @access public
  * @since 1.8
  * @return array
  */
 public static function heartbeat_received($response, $data)
 {
     if (!current_user_can('view_shop_reports')) {
         return $response;
         // Only modify heartbeat if current user can view show reports
     }
     // Make sure we only run our query if the edd_heartbeat key is present
     if (isset($data['edd_heartbeat']) && $data['edd_heartbeat'] == 'dashboard_summary') {
         // Instantiate the stats class
         $stats = new EDD_Payment_Stats();
         $earnings = edd_get_total_earnings();
         // Send back the number of complete payments
         $response['edd-total-payments'] = edd_format_amount(edd_get_total_sales(), false);
         $response['edd-total-earnings'] = html_entity_decode(edd_currency_filter(edd_format_amount($earnings)), ENT_COMPAT, 'UTF-8');
         $response['edd-payments-month'] = edd_format_amount($stats->get_sales(0, 'this_month', false, array('publish', 'revoked')), false);
         $response['edd-earnings-month'] = html_entity_decode(edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'this_month'))), ENT_COMPAT, 'UTF-8');
         $response['edd-payments-today'] = edd_format_amount($stats->get_sales(0, 'today', false, array('publish', 'revoked')), false);
         $response['edd-earnings-today'] = html_entity_decode(edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'today'))), ENT_COMPAT, 'UTF-8');
     }
     return $response;
 }
/**
 * Process deposit
 *
 * @since       1.0.0
 * @return      void
 */
function edd_wallet_process_deposit()
{
    // Verify the nonce
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edd-wallet-deposit-nonce')) {
        wp_die(__('Nonce verification failed', 'edd-wallet'), __('Error', 'edd-wallet'), array('response' => 403));
    }
    // Make sure the cart is empty
    edd_empty_cart();
    $value = $_POST['edd_wallet_deposit_amount'];
    if ($value == 'custom') {
        $value = $_POST['edd_wallet_custom_deposit'];
    }
    // Setup the fee label
    $label = edd_get_option('edd_wallet_deposit_description', __('Deposit to wallet', 'edd-wallet'));
    $label = str_replace('{val}', edd_currency_filter(edd_format_amount($value)), $label);
    // Setup the fee (product) for the deposit
    $fee = array('amount' => $value, 'label' => $label, 'type' => 'item', 'no_tax' => true, 'id' => 'edd-wallet-deposit');
    EDD()->fees->add_fee($fee);
    // Redirect to checkout
    wp_redirect(edd_get_checkout_uri(), 303);
    edd_die();
}
 /**
  * Display widget
  *
  * @access      public
  * @since       1.1.0
  * @param       array $args Arguements for the widget
  * @param       array $instance This widget instance
  * @return      void
  */
 public function widget($args, $instance)
 {
     // Bail if user isn't logged in
     if (!is_user_logged_in()) {
         return;
     }
     $args['id'] = isset($args['id']) ? $args['id'] : 'edd_wallet_widget';
     $instance['title'] = isset($instance['title']) ? $instance['title'] : '';
     $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']);
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('edd_before_wallet_widget');
     $current_user = wp_get_current_user();
     $value = edd_wallet()->wallet->balance($current_user->ID);
     $value = edd_currency_filter(edd_format_amount($value));
     $value = '<span class="edd-wallet-value">' . $value . '</span>';
     echo $value;
     do_action('edd_after_wallet_widget');
     echo $args['after_widget'];
 }
function shoestrap_edd_purchase_variable_pricing($download_id)
{
    $variable_pricing = edd_has_variable_prices($download_id);
    if (!$variable_pricing) {
        return;
    }
    $prices = apply_filters('edd_purchase_variable_prices', edd_get_variable_prices($download_id), $download_id);
    $type = edd_single_price_option_mode($download_id) ? 'checkbox' : 'radio';
    do_action('edd_before_price_options', $download_id);
    echo '<div class="edd_price_options">';
    if ($prices) {
        echo '<select name="edd_options[price_id][]">';
        foreach ($prices as $key => $price) {
            printf('<option for="%3$s" name="edd_options[price_id][]" id="%3$s" class="%4$s" value="%5$s" %7$s> %6$s</option>', checked(0, $key, false), $type, esc_attr('edd_price_option_' . $download_id . '_' . $key), esc_attr('edd_price_option_' . $download_id), esc_attr($key), esc_html($price['name'] . ' - ' . edd_currency_filter(edd_format_amount($price['amount']))), selected(isset($_GET['price_option']), $key, false));
            do_action('edd_after_price_option', $key, $price, $download_id);
        }
        echo '</select>';
    }
    do_action('edd_after_price_options_list', $download_id, $prices, $type);
    echo '</div><!--end .edd_price_options-->';
    do_action('edd_after_price_options', $download_id);
}
/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&tab=logs&view=sales&download=' . $post_id)) . '">';
                    echo edd_get_download_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post_id)) . '">';
                    echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
        }
    }
}
 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.4
  *   Database API
  * @global object $edd_logs EDD Logs Object
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     $data = array();
     if (!empty($this->download)) {
         // Export customers of a specific product
         global $edd_logs;
         $args = array('post_parent' => absint($this->download), 'log_type' => 'sale', 'posts_per_page' => 30, 'paged' => $this->step);
         if (null !== $this->price_id) {
             $args['meta_query'] = array(array('key' => '_edd_log_price_id', 'value' => (int) $this->price_id));
         }
         $logs = $edd_logs->get_connected_logs($args);
         if ($logs) {
             foreach ($logs as $log) {
                 $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true);
                 $customer_id = edd_get_payment_customer_id($payment_id);
                 $customer = new EDD_Customer($customer_id);
                 $data[] = array('id' => $customer->id, 'name' => $customer->name, 'email' => $customer->email, 'purchases' => $customer->purchase_count, 'amount' => edd_format_amount($customer->purchase_value));
             }
         }
     } else {
         // Export all customers
         $offset = 30 * ($this->step - 1);
         $customers = EDD()->customers->get_customers(array('number' => 30, 'offset' => $offset));
         $i = 0;
         foreach ($customers as $customer) {
             $data[$i]['id'] = $customer->id;
             $data[$i]['name'] = $customer->name;
             $data[$i]['email'] = $customer->email;
             $data[$i]['purchases'] = $customer->purchase_count;
             $data[$i]['amount'] = edd_format_amount($customer->purchase_value);
             $i++;
         }
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since 1.4
  *
  * @param array $payment Contains all the data of the payment
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($payment, $column_name)
 {
     switch ($column_name) {
         case 'amount':
             $amount = $payment->total;
             $amount = !empty($amount) ? $amount : 0;
             $value = edd_currency_filter(edd_format_amount($amount), edd_get_payment_currency_code($payment->ID));
             break;
         case 'date':
             $date = strtotime($payment->date);
             $value = date_i18n(get_option('date_format'), $date);
             break;
         case 'status':
             $payment = get_post($payment->ID);
             $value = edd_get_payment_status($payment, true);
             break;
         case 'details':
             $value = '<a href="' . add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')) . '">' . __('View Order Details', 'easy-digital-downloads') . '</a>';
             break;
         default:
             $value = isset($payment->{$column_name}) ? $payment->{$column_name} : '';
             break;
     }
     return apply_filters('edd_payments_table_column', $value, $payment->ID, $column_name);
 }
			<?php 
        foreach ($fees as $fee) {
            ?>
				<tr>
					<td class="edd_fee_label"><?php 
            echo esc_html($fee['label']);
            ?>
</td>
					<?php 
            if (edd_item_quantities_enabled()) {
                ?>
						<td></td>
					<?php 
            }
            ?>
					<td class="edd_fee_amount"><?php 
            echo edd_currency_filter(edd_format_amount($fee['amount']));
            ?>
</td>
				</tr>
			<?php 
        }
        ?>
		<?php 
    }
    ?>
		</tbody>

	</table>
<?php 
}
/**
 * Retrieves a price from from low to high of a variable priced download
 *
 * @since 1.4.4
 * @param int $download_id ID of the download
 * @return string $range A fully formatted price range
 */
function edd_price_range($download_id = 0)
{
    $low = edd_get_lowest_price_option($download_id);
    $high = edd_get_highest_price_option($download_id);
    $range = '<span class="edd_price_range_low">' . edd_currency_filter(edd_format_amount($low)) . '</span>';
    $range .= '<span class="edd_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
    $range .= '<span class="edd_price_range_high">' . edd_currency_filter(edd_format_amount($high)) . '</span>';
    return apply_filters('edd_price_range', $range, $download_id, $low, $high);
}
/**
 * Gets the total tax amount for the cart contents in a fully formatted way
 *
 * @since 1.2.3
 * @param bool $echo Whether to echo the tax amount or not (default: false)
 * @return string Total tax amount (if $echo is set to true)
 */
function edd_cart_tax($echo = false)
{
    $cart_tax = 0;
    if (edd_is_cart_taxed()) {
        $cart_tax = edd_get_cart_tax();
        $cart_tax = edd_currency_filter(edd_format_amount($cart_tax));
    }
    $tax = apply_filters('edd_cart_tax', $cart_tax);
    if (!$echo) {
        return $tax;
    }
    echo $tax;
}
Exemple #28
0
/**
 * View a customer
 *
 * @since  2.3
 * @param  $customer The Customer object being displayed
 * @return void
 */
function edd_customers_view($customer)
{
    $customer_edit_role = apply_filters('edd_edit_customers_role', 'edit_shop_payments');
    ?>

	<?php 
    do_action('edd_customer_card_top', $customer);
    ?>

	<div class="info-wrapper customer-section">

		<form id="edit-customer-info" method="post" action="<?php 
    echo admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . $customer->id);
    ?>
">

			<div class="customer-info">

				<div class="avatar-wrap left" id="customer-avatar">
					<?php 
    echo get_avatar($customer->email);
    ?>
<br />
					<?php 
    if (current_user_can($customer_edit_role)) {
        ?>
						<span class="info-item editable customer-edit-link"><a title="<?php 
        _e('Edit Customer', 'edd');
        ?>
" href="#" id="edit-customer"><?php 
        _e('Edit Customer', 'edd');
        ?>
</a></span>
					<?php 
    }
    ?>
				</div>

				<div class="customer-id right">
					#<?php 
    echo $customer->id;
    ?>
				</div>

				<div class="customer-address-wrapper right">
				<?php 
    if (isset($customer->user_id) && $customer->user_id > 0) {
        ?>

					<?php 
        $address = get_user_meta($customer->user_id, '_edd_user_address', true);
        $defaults = array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'country' => '', 'zip' => '');
        $address = wp_parse_args($address, $defaults);
        ?>

					<?php 
        if (!empty($address)) {
            ?>
					<strong><?php 
            _e('Customer Address', 'edd');
            ?>
</strong>
					<span class="customer-address info-item editable">
						<span class="info-item" data-key="line1"><?php 
            echo $address['line1'];
            ?>
</span>
						<span class="info-item" data-key="line2"><?php 
            echo $address['line2'];
            ?>
</span>
						<span class="info-item" data-key="city"><?php 
            echo $address['city'];
            ?>
</span>
						<span class="info-item" data-key="state"><?php 
            echo $address['state'];
            ?>
</span>
						<span class="info-item" data-key="country"><?php 
            echo $address['country'];
            ?>
</span>
						<span class="info-item" data-key="zip"><?php 
            echo $address['zip'];
            ?>
</span>
					</span>
					<?php 
        }
        ?>
					<span class="customer-address info-item edit-item">
						<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php 
        _e('Address 1', 'edd');
        ?>
" value="<?php 
        echo $address['line1'];
        ?>
" />
						<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php 
        _e('Address 2', 'edd');
        ?>
" value="<?php 
        echo $address['line2'];
        ?>
" />
						<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php 
        _e('City', 'edd');
        ?>
" value="<?php 
        echo $address['city'];
        ?>
" />
						<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country edd-select edit-item">
							<?php 
        $selected_country = $address['country'];
        $countries = edd_get_country_list();
        foreach ($countries as $country_code => $country) {
            echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
        }
        ?>
						</select>
						<?php 
        $selected_state = edd_get_shop_state();
        $states = edd_get_shop_states($selected_country);
        $selected_state = isset($address['state']) ? $address['state'] : $selected_state;
        if (!empty($states)) {
            ?>
						<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state edd-select info-item">
							<?php 
            foreach ($states as $state_code => $state) {
                echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
            }
            ?>
						</select>
						<?php 
        } else {
            ?>
						<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state edd-input info-item" placeholder="<?php 
            _e('State / Province', 'edd');
            ?>
"/>
						<?php 
        }
        ?>
						<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php 
        _e('Postal', 'edd');
        ?>
" value="<?php 
        echo $address['zip'];
        ?>
" />
					</span>
				<?php 
    }
    ?>
				</div>

				<div class="customer-main-wrapper left">

					<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php 
    echo esc_attr($customer->name);
    ?>
" placeholder="<?php 
    _e('Customer Name', 'edd');
    ?>
" /></span>
					<span class="customer-name info-item editable"><span data-key="name"><?php 
    echo $customer->name;
    ?>
</span></span>
					<span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php 
    echo $customer->email;
    ?>
" placeholder="<?php 
    _e('Customer Email', 'edd');
    ?>
" /></span>
					<span class="customer-email info-item editable" data-key="email"><?php 
    echo $customer->email;
    ?>
</span>
					<span class="customer-since info-item">
						<?php 
    _e('Customer since', 'edd');
    ?>
						<?php 
    echo date_i18n(get_option('date_format'), strtotime($customer->date_created));
    ?>
					</span>
					<span class="customer-user-id info-item edit-item">
						<?php 
    $user_id = $customer->user_id > 0 ? $customer->user_id : '';
    $data_atts = array('key' => 'user_login', 'exclude' => $user_id);
    $user_args = array('name' => 'customerinfo[user_login]', 'class' => 'edd-user-dropdown', 'data' => $data_atts);
    if (!empty($user_id)) {
        $userdata = get_userdata($user_id);
        $user_args['value'] = $userdata->user_login;
    }
    echo EDD()->html->ajax_user_search($user_args);
    ?>
						<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php 
    echo $customer->user_id;
    ?>
" />
					</span>

					<span class="customer-user-id info-item editable">
						<?php 
    _e('User ID', 'edd');
    ?>
:&nbsp;
						<?php 
    if (intval($customer->user_id) > 0) {
        ?>
							<span data-key="user_id"><?php 
        echo $customer->user_id;
        ?>
</span>
						<?php 
    } else {
        ?>
							<span data-key="user_id"><?php 
        _e('none', 'edd');
        ?>
</span>
						<?php 
    }
    ?>
						<?php 
    if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) {
        ?>
							<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php 
        _e('Disconnects the current user ID from this customer record', 'edd');
        ?>
"><?php 
        _e('Disconnect User', 'edd');
        ?>
</a></span>
						<?php 
    }
    ?>
					</span>

				</div>

			</div>

			<span id="customer-edit-actions" class="edit-item">
				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php 
    echo $customer->id;
    ?>
" />
				<?php 
    wp_nonce_field('edit-customer', '_wpnonce', false, true);
    ?>
				<input type="hidden" name="edd_action" value="edit-customer" />
				<input type="submit" id="edd-edit-customer-save" class="button-secondary" value="<?php 
    _e('Update Customer', 'edd');
    ?>
" />
				<a id="edd-edit-customer-cancel" href="" class="delete"><?php 
    _e('Cancel', 'edd');
    ?>
</a>
			</span>

		</form>
	</div>

	<?php 
    do_action('edd_customer_before_stats', $customer);
    ?>

	<div id="customer-stats-wrapper" class="customer-section">
		<ul>
			<li>
				<a title="<?php 
    _e('View All Purchases', 'edd');
    ?>
" href="<?php 
    echo admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'%d Completed Sale', '%d Completed Sales', $customer->purchase_count, 'edd'), $customer->purchase_count);
    ?>
				</a>
			</li>
			<li>
				<span class="dashicons dashicons-chart-area"></span>
				<?php 
    echo edd_currency_filter(edd_format_amount($customer->purchase_value));
    ?>
 <?php 
    _e('Lifetime Value', 'edd');
    ?>
			</li>
			<?php 
    do_action('edd_customer_stats_list', $customer);
    ?>
		</ul>
	</div>

	<?php 
    do_action('edd_customer_before_tables_wrapper', $customer);
    ?>

	<div id="customer-tables-wrapper" class="customer-section">

		<?php 
    do_action('edd_customer_before_tables', $customer);
    ?>

		<h3><?php 
    _e('Recent Payments', 'edd');
    ?>
</h3>
		<?php 
    $payment_ids = explode(',', $customer->payment_ids);
    $payments = edd_get_payments(array('post__in' => $payment_ids));
    $payments = array_slice($payments, 0, 10);
    ?>
		<table class="wp-list-table widefat striped payments">
			<thead>
				<tr>
					<th><?php 
    _e('ID', 'edd');
    ?>
</th>
					<th><?php 
    _e('Amount', 'edd');
    ?>
</th>
					<th><?php 
    _e('Date', 'edd');
    ?>
</th>
					<th><?php 
    _e('Status', 'edd');
    ?>
</th>
					<th><?php 
    _e('Actions', 'edd');
    ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
    if (!empty($payments)) {
        ?>
					<?php 
        foreach ($payments as $payment) {
            ?>
						<tr>
							<td><?php 
            echo $payment->ID;
            ?>
</td>
							<td><?php 
            echo edd_payment_amount($payment->ID);
            ?>
</td>
							<td><?php 
            echo date_i18n(get_option('date_format'), strtotime($payment->post_date));
            ?>
</td>
							<td><?php 
            echo edd_get_payment_status($payment, true);
            ?>
</td>
							<td>
								<a title="<?php 
            _e('View Details for Payment', 'edd');
            echo ' ' . $payment->ID;
            ?>
" href="<?php 
            echo admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment->ID);
            ?>
">
									<?php 
            _e('View Details', 'edd');
            ?>
								</a>
								<?php 
            do_action('edd_customer_recent_purcahses_actions', $customer, $payment);
            ?>
							</td>
						</tr>
					<?php 
        }
        ?>
				<?php 
    } else {
        ?>
					<tr><td colspan="5"><?php 
        _e('No Payments Found', 'edd');
        ?>
</td></tr>
				<?php 
    }
    ?>
			</tbody>
		</table>

		<h3><?php 
    printf(__('Purchased %s', 'edd'), edd_get_label_plural());
    ?>
</h3>
		<?php 
    $downloads = edd_get_users_purchased_products($customer->email);
    ?>
		<table class="wp-list-table widefat striped downloads">
			<thead>
				<tr>
					<th><?php 
    echo edd_get_label_singular();
    ?>
</th>
					<th width="120px"><?php 
    _e('Actions', 'edd');
    ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
    if (!empty($downloads)) {
        ?>
					<?php 
        foreach ($downloads as $download) {
            ?>
						<tr>
							<td><?php 
            echo $download->post_title;
            ?>
</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', 'edd'), edd_get_label_singular());
            ?>
								</a>
							</td>
						</tr>
					<?php 
        }
        ?>
				<?php 
    } else {
        ?>
					<tr><td colspan="2"><?php 
        printf(__('No %s Found', 'edd'), edd_get_label_plural());
        ?>
</td></tr>
				<?php 
    }
    ?>
			</tbody>
		</table>

		<?php 
    do_action('edd_customer_after_tables', $customer);
    ?>

	</div>

	<?php 
    do_action('edd_customer_card_bottom', $customer);
    ?>

	<?php 
}
Exemple #29
0
/**
 * Render Stats Meta Box
 *
 * @since 1.0
 * @global array $post Contains all the download data
 * @return void
 */
function edd_render_stats_meta_box()
{
    global $post;
    if (!current_user_can('view_product_stats', $post->ID)) {
        return;
    }
    $earnings = edd_get_download_earnings_stats($post->ID);
    $sales = edd_get_download_sales_stats($post->ID);
    ?>

	<p>
		<strong class="label"><?php 
    _e('Sales:', 'edd');
    ?>
</strong>
		<span><?php 
    echo $sales;
    ?>
 &mdash; <a href="<?php 
    echo admin_url('/edit.php?page=edd-reports&view=sales&post_type=download&tab=logs&download=' . $post->ID);
    ?>
"><?php 
    _e('View Sales Log', 'edd');
    ?>
</a></span>
	</p>

	<p>
		<strong class="label"><?php 
    _e('Earnings:', 'edd');
    ?>
</strong>
		<span><?php 
    echo edd_currency_filter(edd_format_amount($earnings));
    ?>
</span>
	</p>

	<hr />

	<p class="file-download-log">
		<span><a href="<?php 
    echo admin_url('edit.php?page=edd-reports&view=file_downloads&post_type=download&tab=logs&download=' . $post->ID);
    ?>
"><?php 
    _e('View File Download Log', 'edd');
    ?>
</a></span><br/>
	</p>
	<p>
		<span><a href="<?php 
    echo admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post->ID);
    ?>
"><?php 
    _e('View Detailed Earnings Report', 'edd');
    ?>
</a></span>
	</p>
<?php 
    do_action('edd_stats_meta_box');
}
Exemple #30
-1
/**
 * Parse email template tags
 *
 * @since       3.0
 * @param       string $message The email body
 * @param       int $download_id The ID for a given download
 * @param       int $commission_id The ID of this commission
 * @param       int $commission_amount The amount of the commission
 * @param       int $rate The commission rate of the user
 * @return      string $message The email body
 */
function eddc_parse_template_tags($message, $download_id, $commission_id, $commission_amount, $rate)
{
    $meta = get_post_meta($commission_id, '_edd_commission_info', true);
    $variation = get_post_meta($commission_id, '_edd_commission_download_variation', true);
    $download = get_the_title($download_id) . (!empty($variation) ? ' - ' . $variation : '');
    $amount = html_entity_decode(edd_currency_filter(edd_format_amount($commission_amount)));
    $date = date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $commission_id)));
    $user = get_userdata($meta['user_id']);
    if (!empty($user->first_name)) {
        $name = $user->first_name;
        if (!empty($user->last_name)) {
            $fullname = $name . ' ' . $user->last_name;
        } else {
            $fullname = $name;
        }
    } else {
        $name = $user->display_name;
        $fullname = $name;
    }
    $message = str_replace('{download}', $download, $message);
    $message = str_replace('{amount}', $amount, $message);
    $message = str_replace('{date}', $date, $message);
    $message = str_replace('{rate}', $rate, $message);
    $message = str_replace('{name}', $name, $message);
    $message = str_replace('{fullname}', $fullname, $message);
    return $message;
}