wordpress - Woocommerce - php to get order information -
i'm trying data associated order on woocommerce plugin (wordpress). currently, have written own plugin contains code:
<?php global $woocommerce; $order = new wc_order($order_id); $order_shipping_total = $order->get_shipping(); echo $order_shipping_total; ?>
this test out, don't believe working- need list of orders have order status, , able access fields(like first name) each order in list. how go doing this? also, files include make work? class-wc-order() file?
recently worked export of orders data in xml.
$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 $customer_order) { $order = new wc_order(); $order->populate($customer_order); $orderdata = (array) $order; // $orderdata array have information. e.g shippin firstname, lastname, address ... , more.... enjoy! }
Comments
Post a Comment