Search
 
SCRIPT & CODE EXAMPLE
 

PHP

woocommerce get orders by user id

    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;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: replace all occurrence char in string php 
Php :: img src php wordpress theme child 
Php :: get custom post type taxonomy value 
Php :: how to get a sum of a column in lravel 
Php :: laravel with callback 
Php :: ckeditor laravel 
Php :: laravel array cast 
Php :: php convert guzzle response to json 
Php :: php gethostname 
Php :: laravel model update table 
Php :: json encode decode 
Php :: carbon check if date is greater 
Php :: laravel where on relationsship column 
Php :: multi condition inside single if in php 
Php :: woocommerce checkout manager confirm password 
Php :: explode segments url php 
Php :: phpspreadsheet CellProtection 
Php :: Creating default object from empty value 
Php :: 301 redirect 
Php :: where is phpinfo() 
Php :: php redirect with query string 
Php :: how to solve php mysqli_query function problem does not execute 
Php :: laravel factory relationship one to many 
Php :: php proper function comments 
Php :: laravel mail send flexible subject 
Php :: Termlaravel validation exists array data 
Php :: doctrine querybuilder select alias 
Php :: __invoke in laravel 
Php :: category title in post 
Php :: laravel switch 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =