Open M-Th 9:00 am - 5:00 pm MT, F 9:00 am - 3:00 pm MT For Support Call 800.729.8509

Golden Flower Chinese Herbs

Account Details

High-quality formulas, tools, and practitioner supplies from Golden Flower Chinese Herbs.

Account Details
<?php
// get woocommerce user
$user = wp_get_current_user();
if ( ! $user->exists() ) {
    return;
}
// check ULM_USER_META_PHONE_1 is defined or not
if (!defined('ULM_USER_META_PHONE_1')){
    define('ULM_USER_META_PHONE_1', 'ulm_user_phone_1');
    define('ULM_USER_META_PHONE_2', 'ulm_user_phone_2');
    define('ULM_USER_META_FAX',     'ulm_user_fax');
}
$wc_user = new WC_Customer( $user->ID );
// Write your PHP code here
?>
<div class="grid-2 mb-2">
<div class="input-group displaynone">
    <label>First Name:</label>
    <input id="txt-first-name" type="text" value="<?php echo $wc_user->get_first_name(); ?>" placeholder="First name">
</div>
<div class="input-group displaynone">
    <label>Last Name:</label>
    <input id="txt-last-name" type="text" value="<?php echo $wc_user->get_last_name(); ?>" placeholder="Last name">
</div>
</div>
<div class="grid-2 mb-2">
<div class="input-group">
    <label>Name:</label>
    <input id="txt-display-name" type="text" value="<?php echo $wc_user->get_display_name(); ?>" placeholder="Company">
</div>
<div class="input-group">
    <label>Company:</label>
    <input id="txt-company" type="text" value="<?php echo $wc_user->get_billing_company(); ?>" placeholder="Company">
</div>
</div>
<div class="grid-2 mb-2">
<div class="input-group">
    <label>Phone:</label>
    <input id="txt-phone" type="email" value="<?php echo $wc_user->get_meta(ULM_USER_META_PHONE_1); ?>" placeholder="Phone">
</div>
<div class="input-group">
    <label>Phone Ext.:</label>
    <input id="txt-phone-ext" type="email" value="<?php echo $wc_user->get_meta(ULM_USER_META_PHONE_2); ?>" placeholder="Phone Ext.">
</div>
</div>
<div class="grid-2 mb-2">
<div class="input-group">
    <label>Fax:</label>
    <input id="txt-fax" type="text" value="<?php echo $wc_user->get_meta(ULM_USER_META_FAX); ?>" placeholder="Fax">
</div>
<div class="input-group">
    <label>
        Email: <?php
        if (ULMUserControls::IsEmailConfirmed()){
            echo '<span title="Email is confirmed!" style="color:#006719;"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
            <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
            <path d="m10.97 4.97-.02.022-3.473 4.425-2.093-2.094a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05"/>
          </svg></span>';
        }
        ?>
    </label>
    <input id="txt-email" type="email" value="<?php echo $wc_user->get_email(); ?>" placeholder="example@email.com">
    <div id="error-message-update" style="font-size: 0.85rem;">
        <?php 
        if (!ULMUserControls::IsEmailConfirmed()){
            echo '<a href="#" role="button" onclick="resend_verification_link(event)" style=" font-size: 0.85rem; text-decoration: underline;">Click here</a> to resend confirmation email.' ;
        }
        ?>
    </div>
</div>
</div>
<div class="d-flex align-items-center">
    <button id="update-user-info" onclick="update_user_info()">Update </button>
    <div class="spinner" style="display:none;" id="spinner-update-user"></div>
</div>
<div id="error-message-update" style="color: red; font-size: 0.85rem;"></div>
<div id="success-message-update" style="color: green; font-size: 0.85rem;"></div>
 <style>
        @media screen and (max-width: 768px) {
            .grid-2.mb-2 {
               gap: 1rem;
            }
        }
    </style>
<script>
var old_email = '<?php echo $wc_user->get_email(); ?>';
var csrf_nonce_update = '<?php echo wp_create_nonce('ulm_update_user_info'); ?>';
function update_user_info(){
    const spinner = document.querySelector('#spinner-update-user');
    document.querySelector('#error-message-update').innerText = '';
    document.querySelector('#success-message-update').innerText = '';
    spinner.style.display = 'block';
    const fd = new FormData();
    fd.append('nonce', csrf_nonce_update);
    fd.append('action', 'ulm_update_user_info');
    fd.append('first_name', document.querySelector('#txt-first-name').value);
    fd.append('last_name', document.querySelector('#txt-last-name').value);
    fd.append('display_name', document.querySelector('#txt-display-name').value);
    fd.append('company', document.querySelector('#txt-company').value);
    fd.append('phone', document.querySelector('#txt-phone').value);
    fd.append('phone_ext', document.querySelector('#txt-phone-ext').value);
    fd.append('fax', document.querySelector('#txt-fax').value);
    let email = document.querySelector('#txt-email').value.trim();
    if (email !== old_email){
        fd.append('email', email);
    }
    fetch("<?php echo admin_url('admin-ajax.php');?>", {
        method: 'POST',
        body: fd
    }).then(res => res.json()).then(data => {
        if (data.error === false){
            // done
            let error_message = document.querySelector('#error-message-update');
            error_message.innerText = '';
            let success_message = document.querySelector('#success-message-update');
            //success_message.innerText = 'User info updated successfully.';
            show_toast('User info updated successfully.', 'success');
        } else {
            //error_message.innerText = data.message;
            show_toast(data.message, 'danger');
        }
    }).catch(err => {
        //error_message.innerText = 'Server error. Please try again later.';
        show_toast('Server error. Please try again later.', 'danger');
        console.error(err);
    }).finally(()=>{
        spinner.style.display = 'none';
    });
}
function resend_verification_link(event){
    event.preventDefault();
    const target = event.target;
    const html_prev = target.innerHTML;
    target.innerHTML = 'Sending... ';
    fetch("/wp-admin/admin-ajax.php", {
        method: "POST",
        body: new URLSearchParams({
            action: "gfch_resend_email_verification"
        })
    }).then(res => res.json()).then(data => {
        if (data.status === "success"){
            show_toast("Email verification sent", "success");
        } else {
            show_toast("Error sending email verification", "danger");
        }
    }).catch(err => {
        show_toast("Error sending email verification", "danger");
    }).finally(()=>{
        target.innerHTML = html_prev;
    });
}
</script>
Reset Password







<?php
    do_action("woocommerce_account_edit-address_endpoint", "");