【发布时间】:2014-10-24 19:32:21
【问题描述】:
在我的自定义类中,我想打印客户订购的商品。 在 wooCommerce 的自定义类中执行此操作的正确方法是什么?
我的代码示例;
$args = array(
'post_type' => 'shop_order',
'post_status' => 'wc-processing',
'meta_key' => '_customer_user',
'posts_per_page' => '-1',
);
$my_query = new WP_Query($args);
$customer_orders = $my_query->posts;
# Loop through orders
foreach ($customer_orders as $customer_order) :
$order = new WC_Order($customer_order->id);
$order->populate($customer_order);
$this->woOrders[] = (array) $order;
# User billing address
$this->billingAddress = $order->get_formatted_billing_address();
echo $this->billingAddress;
# User shipping address
$this->shippingAddress = $order->get_formatted_shipping_address();
echo $this->shippingAddress .'<br>';
endforeach;
谢谢
【问题讨论】:
标签: php wordpress woocommerce