esc_html__( 'Customers', 'easy-digital-downloads' ), 'emails' => esc_html__( 'Email Addresses', 'easy-digital-downloads' ), 'physical' => esc_html__( 'Physical Addresses', 'easy-digital-downloads' ) ) ); } // Return return $pages; } /** * Display customer sections * * Contains backwards compat code to shim tabs & views to EDD_Sections() * * @since 3.0 * * @param object $customer */ function edd_customers_sections( $customer ) { // Instantiate the Sections class and sections array $sections = new EDD\Admin\Sections(); $c_sections = array(); // Setup sections variables $sections->item = $customer; $sections->use_js = true; $sections->current_section = ! empty( $_GET['view'] ) ? sanitize_key( $_GET['view'] ) : 'overview'; $sections->base_url = edd_get_admin_url( array( 'page' => 'edd-customers', 'id' => absint( $customer->id ), ) ); // Get all registered tabs & views $tabs = edd_customer_tabs(); $views = edd_customer_views(); // Do not display the addresses tab if there are none. if ( empty( $customer->get_addresses() ) ) { unset( $tabs['addresses'] ); } // Loop through tabs & setup sections if ( ! empty( $tabs ) ) { foreach ( $tabs as $id => $tab ) { // Bail if no view if ( ! isset( $views[ $id ] ) ) { continue; } // Add to sections array $c_sections[] = array( 'id' => $id, 'label' => $tab['title'], 'icon' => str_replace( 'dashicons-', '', $tab['dashicon'] ), 'callback' => $views[ $id ] ); } } // Set the customer sections $sections->set_sections( $c_sections ); // Display the sections $sections->display(); } /** * Customers Page * * Renders the customers page contents. * * @since 2.3 * @return void */ function edd_customers_page() { // Enqueue scripts. wp_enqueue_script( 'edd-admin-customers' ); wp_enqueue_script( 'edd-admin-notes' ); // Views $default_views = edd_customer_views(); $requested_view = isset( $_GET['view'] ) ? sanitize_key( $_GET['view'] ) : 'customers'; // Tabs $active_tab = ! empty( $_GET['page_type'] ) ? sanitize_key( $_GET['page_type'] ) : 'customers'; // Single customer view if ( array_key_exists( $requested_view, $default_views ) && is_callable( $default_views[ $requested_view ] ) ) { edd_render_customer_view( $requested_view, $default_views ); // List table view } else { edd_customers_list( $active_tab ); } } /** * Register the views for customer management * * @since 2.3 * @return array Array of views and their callbacks */ function edd_customer_views() { return apply_filters( 'edd_customer_views', array() ); } /** * Register the tabs for customer management * * @since 2.3 * @return array Array of tabs for the customer */ function edd_customer_tabs() { return apply_filters( 'edd_customer_tabs', array() ); } /** * List table of customers * * @since 2.3 * @return void */ function edd_customers_list( $active_tab = 'customers' ) { // Get the possible pages $pages = edd_get_customer_pages(); // Reset page if not a registered page if ( ! in_array( $active_tab, array_keys( $pages ), true ) ) { $active_tab = 'customers'; } // Get the label/name from the active tab $name = $pages[ $active_tab ]; // Get the action url from the active tab $action_url = edd_get_admin_url( array( 'page_type' => sanitize_key( $active_tab ), 'page' => 'edd-' . sanitize_key( $active_tab ), ) ); // Setup the list table class switch ( $active_tab ) { case 'customers' : include_once dirname( __FILE__ ) . '/class-customer-table.php'; $list_table_class = 'EDD_Customer_Reports_Table'; break; case 'emails' : include_once dirname( __FILE__ ) . '/class-customer-email-addresses-table.php'; $list_table_class = 'EDD_Customer_Email_Addresses_Table'; break; case 'physical' : include_once dirname( __FILE__ ) . '/class-customer-addresses-table.php'; $list_table_class = 'EDD_Customer_Addresses_Table'; break; } // Initialize the list table $customers_table = new $list_table_class; $customers_table->prepare_items(); ?>



views(); $customers_table->search_box( sprintf( __( 'Search %s', 'easy-digital-downloads' ), $name ), 'edd-customers' ); $customers_table->display(); ?>
id ) ) { edd_set_error( 'edd-invalid_customer', __( 'Invalid Customer ID Provided.', 'easy-digital-downloads' ) ); $render = false; } ?>


get_meta( 'agree_to_terms_time', false ); $show_terms = edd_get_option( 'show_agree_to_terms' ); $privacy_timestamps = $customer->get_meta( 'agree_to_privacy_time', false ); $show_privacy = edd_get_option( 'show_agree_to_privacy_policy' ); $last_payment_date = ''; if ( ( empty( $agreement_timestamps ) && $show_terms ) || ( empty( $privacy_timestamps ) && $show_privacy ) ) { $last_payment = edd_get_orders( array( 'customer_id' => $customer->id, 'orderby' => 'date', 'order' => 'DESC', 'number' => 1, ) ); if ( ! empty( $last_payment ) ) { $last_payment = reset( $last_payment ); $last_payment_date = strtotime( $last_payment->date_created ); } } if ( is_array( $agreement_timestamps ) ) { $agreement_timestamp = array_pop( $agreement_timestamps ); } if ( is_array( $privacy_timestamps ) ) { $privacy_timestamp = array_pop( $privacy_timestamps ); } $user_id = ( $customer->user_id > 0 ) ? absint( $customer->user_id ) : ''; $address_args = array( 'address' => '', 'address2' => '', 'city' => '', 'region' => '', 'postal_code' => '', 'country' => '', ); $data_atts = array( 'key' => 'user_login', 'exclude' => $user_id ); $user_args = array( 'name' => 'customerinfo[user_login]', 'class' => 'edd-user-dropdown', 'data' => $data_atts ); // Maybe get user data if ( ! empty( $user_id ) ) { $userdata = get_userdata( $user_id ); if ( ! empty( $userdata->user_login ) ) { $user_login = $userdata->user_login; $user_args['value'] = $user_login; } else { $user_login = false; } } // Address $address = $customer->get_address(); if ( ! empty( $address ) ) { $address = $address->to_array(); $address = wp_parse_args( $address, $address_args ); } else { $address = $address_args; } do_action( 'edd_customer_card_top', $customer ); // Country $selected_country = $address['country']; $countries = edd_get_country_list(); // State $selected_state = edd_get_shop_state(); $states = edd_get_shop_states( $selected_country ); $selected_state = isset( $address['region'] ) ? $address['region'] : $selected_state; // Orders // Orders and refunds. $orders = edd_get_orders( array( 'customer_id' => $customer->id, 'number' => 10, 'type' => 'sale', ) ); $refunds = edd_get_orders( array( 'customer_id' => $customer->id, 'number' => 10, 'type' => 'refund', ) ); // Downloads $downloads = edd_get_users_purchased_products( $customer->email ); ?>
email, 150 ); ?>
#id ); ?>
name ); ?> email ); ?> date_created ) ) ); ?> html->ajax_user_search( $user_args ); ?> ' . esc_html( $user_id ) . ''); endif; ?> 0 ) : ?>

status ) { $state = ' — ' . edd_get_payment_status_label( $order->status ); } // View URL $view_url = edd_get_admin_url( array( 'page' => 'edd-payment-history', 'view' => 'view-order-details', 'id' => absint( $order->id ), ) ); ?>
get_number() ); ?> gateway ) ); ?> total ), $order->currency ); ?>

'edd-payment-history', 'view' => 'view-refund-details', 'id' => absint( $refund->id ), ) ); ?>
order_number ); ?> gateway ) ); ?> total ), $refund->currency ); ?>

post_title ); ?>
$customer->id, 'orderby' => 'type', // to put `primary` email first 'order' => 'ASC' ) ); ?>

$email ) : ?>
email ); ?> type ) : ?>
'edd-customers', 'view' => 'overview', 'id' => urlencode( $customer->id ), ) ); $actions = array( 'promote' => array( 'url' => wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email->email ), 'edd_action' => 'customer-primary-email' ), $base_url ), 'edd-set-customer-primary-email' ), 'label' => __( 'Make Primary', 'easy-digital-downloads' ), ), 'delete' => array( 'url' => wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email->email ), 'edd_action' => 'customer-remove-email' ), $base_url ), 'edd-remove-customer-email' ), 'label' => __( 'Delete', 'easy-digital-downloads' ), ), ); $action_links = array(); foreach ( $actions as $action => $args ) { $action_links[] = sprintf( '%s', esc_attr( $action ), esc_url( $args['url'] ), esc_html( $args['label'] ) ); } echo wp_kses( implode( ' | ', $action_links ), edd_get_allowed_tags() ); ?>
get_addresses(); // This has already been checked when setting the tabs. if ( empty( $addresses ) ) { return; } ?>

'edd-customers', 'view' => 'overview', 'id' => urlencode( $address->id ), 'edd_action' => 'customer-remove-address', ) ), 'edd-remove-customer-address' ); ?>
address ) ? esc_html( $address->address ) : '—'; echo ! empty( $address->address2 ) ? esc_html( $address->address2 ) : ''; ?> city ) ? esc_html( $address->city ) : '—'; ?> region ) ? esc_html( edd_get_state_name( $address->country, $address->region ) ) : '—'; ?> postal_code ) ? esc_html( $address->postal_code ) : '—'; ?> country ) ? esc_html( edd_get_country_name( $address->country ) ) : '—'; ?> is_primary ) ) : ?>
get_notes( $per_page, $paged ); $note_count = $customer->get_notes_count(); $args = array( 'total' => $note_count, 'add_fragment' => '#edd_general_notes' ); ?>

id, 'customer' ); ?>

html->checkbox( array( 'name' => 'edd-customer-delete-confirm' ) ); ?>

html->checkbox( array( 'name' => 'edd-customer-delete-records', 'options' => array( 'disabled' => true ) ) ); ?>

user_id ) ) { return; } $url = wp_nonce_url( edd_get_admin_url( array( 'page' => 'edd-customers', 'view' => 'overview', 'edd_action' => 'verify_user_admin', 'id' => absint( $customer->id ), ) ), 'edd-verify-user' ); echo '

'; esc_html_e( 'This customer\'s user account is pending verification.', 'easy-digital-downloads' ); echo ' '; echo '' . esc_html__( 'Verify account.', 'easy-digital-downloads' ) . ''; echo "\n\n"; echo '

'; } add_action( 'edd_customer_card_top', 'edd_verify_customer_notice', 10, 1 );