Skip to content

Instantly share code, notes, and snippets.

@SeanTOSCD
Created September 16, 2019 19:22
Show Gist options
  • Save SeanTOSCD/0a3f93976ea5816c1dcd51b63585976c to your computer and use it in GitHub Desktop.
Save SeanTOSCD/0a3f93976ea5816c1dcd51b63585976c to your computer and use it in GitHub Desktop.
EDD Site Account Dashboard page
<?php
/**
* Content for the Account Dashboard tab on the Account page / The Main Account Page
*/
global $current_user;
$customer = '';
if ( class_exists( 'Easy_Digital_Downloads' ) ) {
$customer = new EDD_Customer( $current_user->ID, true );
}
$account_notifications = false;
$completion = eddwp_get_profile_completion_percentage();
if ( ( function_exists( 'eddwp_user_has_expired_license' ) && eddwp_user_has_expired_license() ) ||
( function_exists( 'eddwp_user_must_update_payment_info' ) && eddwp_user_must_update_payment_info() ) ||
'100%' !== $completion ) {
$account_notifications = true;
}
?>
<div class="account-page-content-header">
<?php eddwp_account_breadcrumbs(); ?>
<h3 class="title">Your account details</h3>
<p class="subtitle"><a href="<?php echo EDDWP_PROFILE; ?>">Click here</a> to edit your information.</p>
</div>
<div class="account-dashboard-content">
<?php if ( $account_notifications ) { ?>
<div class="account-dashboard-section row">
<div class="account-notifications col">
<div class="account-dashboard-section-content">
<h6 class="account-dashboard-section-heading">Notifications</h6>
<div class="tip">
<ul class="account-notifications-list">
<?php
if ( function_exists( 'eddwp_user_has_expired_license' ) && eddwp_user_has_expired_license() ) {
?>
<li>You have one or more expired license keys. <a href="<?php echo EDDWP_LICENSE_KEYS ?>">Manage your license keys</a>.</li>
<?php
}
if ( function_exists( 'eddwp_user_must_update_payment_info' ) && eddwp_user_must_update_payment_info() ) {
?>
<li>You have one or more failing subscription renewal payments. <a href="<?php echo EDDWP_PAYMENT_METHODS ?>">Manage your subscriptions</a>.</li>
<?php
}
if ( '100%' !== $completion ) {
?>
<li>Your profile is incomplete. <a href="<?php echo EDDWP_PROFILE ?>">Manage your profile</a>.</li>
<?php
}
?>
</ul>
</div>
</div>
</div>
</div>
<?php } ?>
<div class="account-dashboard-section account-dashboard-section-details row">
<div class="col">
<div class="account-dashboard-section-content">
<h6 class="account-dashboard-section-heading">Account details</h6>
<div class="account-details">
<span class="account-details-subsection-heading">Personal:</span>
<div>
<span class="account-detail-label">Email:</span><span><?php echo $current_user->user_email; ?></span>
</div>
<div>
<span class="account-detail-label">Username:</span><span><?php echo $current_user->user_login; ?></span>
</div>
<div>
<span class="account-detail-label">Display name:</span><span><?php echo $current_user->display_name; ?></span>
</div>
<?php if ( ! empty( $customer->id ) ) { ?>
<span class="account-details-subsection-heading">Customer history:</span>
<div>
<?php
$customer_since_date = substr( $customer->date_created, 0, strpos( $customer->date_created, ' ' ) );
$customer_since = date( 'F j, Y', str_replace( '-', '/', strtotime( $customer_since_date ) ) );
?>
<span class="account-detail-label">Customer since:</span><span><?php echo $customer_since; ?></span>
</div>
<div>
<span class="account-detail-label">Completed purchases:</span><span><?php echo $customer->purchase_count; ?> <span class="value-link">(<a href="<?php echo EDDWP_PURCHASES; ?>">View all</a>)</span></span>
</div>
<div>
<span class="account-detail-label">Value of purchases:</span><span><?php echo edd_currency_filter( edd_format_amount( $customer->purchase_value ) ); ?></span>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="account-dashboard-section account-dashboard-section-access-pass row">
<div class="col">
<div class="account-dashboard-section-content">
<?php
// Get the All Access passes saved to this customer meta
$customer_all_access_passes = false;
if ( ! empty( $customer ) ) {
$customer_all_access_passes = $customer->get_meta( 'all_access_passes' );
}
?>
<h6 class="account-dashboard-section-heading">Access Passes</h6>
<div class="access-pass-details">
<?php if ( ! empty( $customer_all_access_passes ) ) { ?>
<p>Congratulations! You are an Access Pass holder. You can download multiple extensions from one location.</p>
<a class="eddwp-button blue" href="<?php echo EDDWP_YOUR_DOWNLOADS; ?>">View Your Downloads!</a>
<?php } else { ?>
<p>Did you know that Access Passes allow you to gain access to several extensions with a single purchase? Currently, you are not an Access Pass holder. <a href="<?php echo EDDWP_PRICING; ?>">Click here</a> to see purchase options.</p>
<?php } ?>
</div>
</div>
</div>
</div>
<?php
if ( class_exists( 'EDD_Wallet' ) ) {
$wallet_value = edd_wallet()->wallet->balance( $current_user->ID );
if ( $wallet_value > 0 ) {
?>
<div class="account-dashboard-section row">
<div class="col">
<div class="account-dashboard-section-content">
<h6 class="account-dashboard-section-heading">Wallet balance</h6>
<div class="account-wallet">
<?php $balance = edd_currency_filter( edd_format_amount( $wallet_value ) ); ?>
<p>You currently have a balance of <span class="balance"><?php echo $balance; ?></span> in your Wallet (store credit). To use the funds in your wallet, you must add one or more items to your cart, proceed to checkout, and use the provided link on the checkout cart to apply the funds.</p>
<div class="tip">
<strong>Note:</strong> Wallet funds cannot be used for automatic subscription renewal payments.
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>
@SeanTOSCD
Copy link
Author

Hey @kraftstudio

That's not an extension, nor is it part of any product. It's just my custom work. It's a function I built that works with other custom functions I built to track the completion of certain fields on a user's profile and display various notices around the theme. I created it because we wanted to encourage our US customers to enter their phone numbers into their user profiles. So it's not just that function... it's everything from the little orange dot you may see on the Account menu, to modifications to the purchase receipt and custom account dashboard.

This isn't something I can help you build, though. That function was part of something we needed specifically for our marketing efforts. There's a good chance you do not need it. If you do need something like that, though, you'd have to build it based on the needs of your company. This gist was created to share with someone how customer information was displayed. It's not at all intended for full copy and paste.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment