WooCommerce Obtener ID de usuario por correo electrónico
$user = get_user_by( 'email', '[email protected]' );
$userId = $user->ID;
Excited Eland
$user = get_user_by( 'email', '[email protected]' );
$userId = $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;
}