Advertisement
Guest User

Untitled

a guest
May 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2. require('wp-blog-header.php');
  3. require_once("wp-config.php");
  4. require_once("wp-includes/wp-db.php");
  5.  
  6. global $woocommerce;
  7.  
  8. $args = array(
  9.     'post_type'     => 'shop_order',
  10.     'post_status'     => 'any',
  11.     'posts_per_page' => -1,
  12.     'tax_query' => array(
  13.       array(
  14.         'taxonomy' => 'shop_order_status',
  15.         'field' => 'slug',
  16.         'terms' => array('complete')
  17.         )
  18.       )
  19.     );
  20.  
  21. $loop = new WP_Query( $args );
  22.  
  23. while ( $loop->have_posts() ) : $loop->the_post();
  24.   $order_id = $loop->post->ID;
  25.   $order = new WC_Order($order_id);
  26.   list( $name, $undef ) = explode("<br/>", $order->get_billing_address());
  27.   list( $firstname, $lastname ) = explode(" ", $name);
  28.   $billing_email = $order->billing_email;
  29.   $order_total = $order->order_total;
  30.   $cart_discount = $order->cart_discount;
  31.   $user = get_user_by('id', $order->user_id);
  32.   $customer_email = $user->user_email;
  33.   $user_id = get_user_id($firstname, $lastname, $billing_email, $customer_email);
  34.  
  35.   print "$firstname $lastname";
  36. endwhile;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement