Woocommerce Bookings get person count by type


This Content is from Stack Overflow. Question asked by Sam Skirrow

For each of my bookings, I am trying to display a breakdown of person numbers by person type.

So far, I have been able to use the get_persons_total() function to display the total number of persons per booking – however, I have 3 person types (Child, Adult, Baby) and I’d like to be able to separate my person counts by type (or ID)…something like get_persons_total(ID) would be perfect.

Here is the code that fetches the total person count:

$person_count = $booking->get_persons_total();
    if ( !empty( $person_count ) ) {
        $booking_person_count = $person_count;
    } else {
        $booking_person_count = '0';


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?