Answer the question
In order to leave comments, you need to log in
Woocommerce how to get the sum of all products ordered by a customer for all time?
What function, to display the sum of all orders in the client's account, shoveled the entire Internet, but unfortunately did not find the answer.
Answer the question
In order to leave comments, you need to log in
It?
public function get_customer_total_order() {
$customer_orders = get_posts( array(
'numberposts' => - 1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => array( 'shop_order' ),
'post_status' => array( 'wc-completed' )
) );
$total = 0;
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order );
$total += $order->get_total();
}
return $total;
}
Сумма всех заказов: <?php echo get_customer_total_order(); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question