vap93
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Plugins
In reply to: [WooCommerce] How to create a search for a “WC_Customer” in a custom page?Thank you @paulostp, I’ll do it! And thank’s too @rainfallnixfig!!
- This reply was modified 2 years, 6 months ago by vap93.
Forum: Plugins
In reply to: [WooCommerce] How to create a search for a “WC_Customer” in a custom page?Hi,
I still haven’t resolved it. Anyone else to help?? Thanks in advance!!
Forum: Plugins
In reply to: [WooCommerce] Display woocommerce billing address on a custom pageHi! Thanks for your reply!
I received the solution on another forum. So here’s the functional code
<?php // WP_User_Query arguments $args = array( 'meta_key' => 'first_name', 'role' => 'shopkeeper', //'search' => 'first_name', 'search_columns' => array('first_name', 'city', 'state'), 'order' => 'ASC', 'orderby' => 'meta_value', 'fields' => 'all_with_meta', ); // The User Query $users = new WP_User_Query($args); // User Loop if (!empty($users->results)) { foreach ($users->results as $user) { // Get an instance of the WC_Customer Object from the user ID $customer = new WC_Customer( $user->ID ); $username = $customer->get_username(); // Get username $user_email = $customer->get_email(); // Get account email $first_name = $customer->get_first_name(); $last_name = $customer->get_last_name(); $display_name = $customer->get_display_name(); // Customer billing information details (from account) $billing_first_name = $customer->get_billing_first_name(); $billing_last_name = $customer->get_billing_last_name(); $billing_company = $customer->get_billing_company(); $billing_address_1 = $customer->get_billing_address_1(); $billing_address_2 = $customer->get_billing_address_2(); $billing_city = $customer->get_billing_city(); $billing_state = $customer->get_billing_state(); $billing_postcode = $customer->get_billing_postcode(); $billing_country = $customer->get_billing_country(); // Customer shipping information details (from account) $shipping_first_name = $customer->get_shipping_first_name(); $shipping_last_name = $customer->get_shipping_last_name(); $shipping_company = $customer->get_shipping_company(); $shipping_address_1 = $customer->get_shipping_address_1(); $shipping_address_2 = $customer->get_shipping_address_2(); $shipping_city = $customer->get_shipping_city(); $shipping_state = $customer->get_shipping_state(); $shipping_postcode = $customer->get_shipping_postcode(); $shipping_country = $customer->get_shipping_country(); echo '<li>' . '<a href="' . esc_url(get_author_posts_url($user->ID)) . '">' . '<div id="userImage">' . get_avatar($user->ID) . '</div>' . '<div id="userInfo">' . esc_attr($user->first_name) . ' ' . esc_attr($user->last_name) . '<br>' . 'CEP: ' . esc_attr($customer->billing_postcode) . ' — ' . esc_attr($customer->billing_city) . ', ' . esc_attr($customer->billing_state) . '<br>' . '</a>' . '<a href="' . esc_attr($user->user_url) . '">' . esc_attr($user->user_url) . '</a>' . '</div>' . '</li>'; } } else { echo 'Nenhum usuário encontrado.'; } ?>
Viewing 3 replies - 1 through 3 (of 3 total)