Woocommerce 获取订单信息

获取与woomerce插件(wordpress)上的订单相关联的数据

<?php
global $woocommerce;
$order = new WC_Order($order_id);
$order_shipping_total = $order->get_shipping();
echo $order_shipping_total;
?>


$args = array(
'post_type' => 'shop_order',
'post_status' => 'publish',
'meta_key' => '_customer_user',
'posts_per_page' => '-1'
);
$my_query = new WP_Query($args);
$customer_orders = $my_query->posts;
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$orderdata = (array) $order;
// $orderdata Array will have Information. for e.g Shippin firstname, Lastname, Address ... and MUCH more.... Just enjoy!
}

Leave a Reply

Your email address will not be published. Required fields are marked *