Skip to content

Instantly share code, notes, and snippets.

@Ravenna
Created October 9, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ravenna/193fc9735b85cdafb741d000d4ec077d to your computer and use it in GitHub Desktop.
Save Ravenna/193fc9735b85cdafb741d000d4ec077d to your computer and use it in GitHub Desktop.
<?php
header("HTTP/1.1 200 OK"); // Forcing the 200 OK header as WP can return 404 otherwise
$orders = get_orders_ids_by_product_id(498);
$output = array();
foreach($orders as $o){
$order = wc_get_order( $o );
$info = [
'First Name' => $order->get_billing_first_name(),
'Last Name' => $order->get_billing_last_name(),
'Order Status' => $order->get_status(),
'Shipping Address 1' => $order->get_shipping_address_1(),
'Shipping Address 2' => $order->get_shipping_address_2(),
'Shipping City' => $order->get_shipping_city(),
'Shipping State' => $order->get_shipping_state(),
'Shipping Postcode' => $order->get_shipping_postcode(),
'Email' => get_post_meta($o, 'Email'),
'Day Phone' => get_post_meta($o, 'Day Phone'),
'Mobile Phone' => get_post_meta($o, 'Mobile Phone'),
'Order ID' => $o
];
array_push($output, $info);
}
echo serialize($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment