How can I get customer details from an order in WooCommerce?

前端 未结 15 1509
北海茫月
北海茫月 2020-12-01 00:10

I have a function that does this:

$order = new WC_Order($order_id);
$customer = new WC_Customer($order_id);

How can I get customer details fr

15条回答
  •  攒了一身酷
    2020-12-01 01:00

    And another example to get the customer details from the database:

    $order = new WC_Order($order_id);
    $order_detail['status']              = $order->get_status();
    $order_detail['customer_first_name'] = get_post_meta($order_id, '_billing_first_name', true);
    $order_detail['customer_last_name']  = get_post_meta($order_id, '_billing_last_name', true);
    $order_detail['customer_email']      = get_post_meta($order_id, '_billing_email', true);
    $order_detail['customer_company']    = get_post_meta($order_id, '_billing_company', true);
    $order_detail['customer_address']    = get_post_meta($order_id, '_billing_address_1', true);
    $order_detail['customer_city']       = get_post_meta($order_id, '_billing_city', true);
    $order_detail['customer_state']      = get_post_meta($order_id, '_billing_state', true);
    $order_detail['customer_postcode']   = get_post_meta($order_id, '_billing_postcode', true);
    

提交回复
热议问题