📌  相关文章
📜  woocommerce 通过用户 ID 获取订单 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:05.775000             🧑  作者: Mango

代码示例3
public function get_sum_of_paid_orders( int $user_id ): int {

        $customer_orders = [];
        foreach ( wc_get_is_paid_statuses() as $paid_status ) {
            $customer_orders += wc_get_orders( [
                'type'        => 'shop_order',
                'limit'       => - 1,
                'customer_id' => $user_id,
                'status'      => $paid_status,
            ] );
        }

        $total = 0;
        foreach ( $customer_orders as $order ) {
            $total += $order->get_total();

            // your code is here
        }

        return $total;
    }