I am wondering if there is any way to check if a successful purchase was from a new or returning customer.
I have a script which needs added to the Order Success page.
I've got this so far, which doesn't really work as I need it to as it is only checking for guest or logged-in checkout:
$order = wc_get_order($order->id);
$user = get_user_by('email', $order->billing_email);
if (isset($user->ID)) {
echo 'User is logged in.';
} else {
echo 'User is a guest.';
}
Thanks!