/**
 * Email template tag: username
 * The buyer's user name on the site, if they registered an account
 *
 * @param int $payment_id
 *
 * @return string username
 */
function edd_email_tag_username($payment_id)
{
    $payment_data = edd_get_payment_meta($payment_id);
    if (empty($payment_data['user_info'])) {
        return '';
    }
    $email_name = edd_get_email_names($payment_data['user_info']);
    return $email_name['username'];
}
/**
 * Email template tag: username
 * The buyer's user name on the site, if they registered an account
 *
 * @since       1.0.0
 * @param       int $payment_id
 * @return      string username
 */
function edd_wallet_email_tag_username($payment_id)
{
    if (get_post_type($payment_id) == 'edd_payment') {
        $payment_data = edd_get_payment_meta($payment_id);
        if (empty($payment_data['user_info'])) {
            return '';
        }
        $email_name = edd_get_email_names($payment_data['user_info']);
        $name = $email_name['username'];
    } else {
        $item = edd_wallet()->db->get_customer_wallet_item($payment_id);
        $user_data = get_userdata($item->user_id);
        $name = $user_data->user_login;
    }
    return $name;
}
/**
 * Email template tag: username
 * The buyer's user name on the site, if they registered an account
 *
 * @param int $payment_id
 *
 * @return string username
 */
function edd_email_tag_username($payment_id)
{
    $payment = new EDD_Payment($payment_id);
    $user_info = $payment->user_info;
    if (empty($user_info)) {
        return '';
    }
    $email_name = edd_get_email_names($user_info);
    return $email_name['username'];
}