<?php
/**
 * Template for displaying logged in form.
 *
 * This template can be overridden by copying it to yourtheme/learnpress/checkout/form-logged-in.php.
 *
 * @author   ThimPress
 * @package  Learnpress/Templates
 * @version  4.0.0
 */

defined( 'ABSPATH' ) || exit();

if ( ! is_user_logged_in() ) {
	return;
}

global $user_identity;
?>

<div id="checkout-account-logged-in" class="lp-checkout-block left">
	<!-- <p>
		<?php printf( __( 'Logged in as <a href="%1$s">%2$s</a>.', 'learnpress' ), get_edit_user_link(), $user_identity ); ?>

		<a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>" title="<?php esc_attr_e( 'Log out of this account', 'learnpress' ); ?>">
			<?php esc_html_e( 'Log out &raquo;', 'learnpress' ); ?>
		</a>
	</p> -->

	<p>
		<?php $all_meta_for_user = get_userdata( get_current_user_id() ); 
			//echo '<pre>';print_r($all_meta_for_user);echo '</pre>'; 
			$first_name = $all_meta_for_user->first_name;
			$last_name = $all_meta_for_user->last_name;
			$user_email = $all_meta_for_user->user_email;

			$user_avatar = get_avatar_url( get_current_user_id() );


		?>

		<div class="ch-customer-info">
			<h4>Customer Information</h4>
			<div class="ch-customer-details">
				<div class="ch-user-avatar">
					<?php if($user_avatar != ''){ ?>
						<img src="<?php echo esc_url( get_avatar_url( get_current_user_id() ) ); ?>" />
					<?php }else{ ?>
						<?php $Nickname = substr($first_name, 0, 1).substr($last_name, 0, 1); 
						echo $Nickname; ?>
					<?php } ?>
				</div>
				<div class="ch-user-name"><?php echo $first_name.' '.$last_name; ?><br/>
				<?php echo $user_email; ?></div>
			</div>
		</div>
	</p>
</div>
