0

I'm using WooCommerce and need to get my users billing name, billing address, billing phone, billing email, etc from wp_usermeta in a good format like this:

name,address,phone,email
fake name, 123 stackexchange rd,111-111-1111,email@email.com

Anyone know how to do something like this? I need to do it for alot of users (10k+) in one go if possible. I tried using some php code but it didnt work. Any help appreciated

  • 1
    Please tell what you tried. – kuchenundkakao Nov 4 '15 at 21:39
0

You can use meta_query to specify what conditions you want to meet with that query you are performing. i.e.:

// grab some record from DB with a specific meta query
$args = array(
    'post_type' => array( 'woo_commerce_something' ),
    'orderby' => 'rand',
    'posts_per_page' => -1,
    'meta_query' => array(
        array(
            'key' => 'meta_something_woo_commerce_email',
            'value' => 'email@email@email.com'
        )
    )
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();
        // do something 
    endwhile;
endif;
wp_reset_postdata();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.