Orders

$args = array(
‘numberposts’ => – 1,
);
$orders = wc_get_orders( $args );

// Get and Loop Over Order Items
foreach ( $orders as $order ) {
$customername = $order->get_billing_first_name().’ ‘.$order->get_billing_last_name();
$address = $order->get_billing_address_1();
$email = $order->get_billing_email();
$phone = $order->get_billing_phone();
$status = $order->get_status();
$order_id = $order->get_id();
$order_id_key = $order->get_order_key();
if ( count( $order->get_items() ) > 0 ) {
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
$variation_id = $item->get_variation_id();
$product = $item->get_product();
$name = $item->get_name();
$quantity = $item->get_quantity();
$subtotal = $item->get_subtotal();

echo ‘

#’.$order_id.’ ‘.$order_id.’ ‘.$customername.’ ‘.$phone.’ ‘.$email.’ ‘.$quantity.’ ‘.$status.’ ‘.$order->get_view_order_url().’

‘;
}
}
}