Answers for "woocommerce get all products by user id"

PHP
6

woocommerce get product id

global $product;
$product->get_id();
Posted by: Guest on July-03-2020
0

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;
    }
Posted by: Guest on June-06-2021

Code answers related to "woocommerce get all products by user id"

Browse Popular Code Answers by Language