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

前端 未结 15 1546
北海茫月
北海茫月 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 00:43

    Get the customer id from the order object:

    $order = new WC_Order($order_id);
    
    // Here the customer data
    $customer = get_userdata($order->customer_user);
    echo $customer->display_name;
    

提交回复
热议问题