| @@ -46,8 +46,9 @@ | ||
| 46 | 46 | 'last_name' => '', |
| 47 | 47 | 'email' => '', |
| 48 | 48 | 'phone' => '', |
| 49 | 49 | 'password' => '', |
| 50 | + 'quantity' => [] | |
| 50 | 51 | ]; |
| 51 | 52 | |
| 52 | 53 | /** |
| 53 | 54 | * Customer constructor |
| @@ -149,8 +150,46 @@ | ||
| 149 | 150 | return $user->user_pass; |
| 150 | 151 | } |
| 151 | 152 | |
| 152 | 153 | /** |
| 154 | + * Get quantity | |
| 155 | + * | |
| 156 | + * @return array | |
| 157 | + */ | |
| 158 | + public function get_quantity() { | |
| 159 | + $all_quantity = $this->get_prop( 'quantity' ); | |
| 160 | + $quantities = []; | |
| 161 | + if ( is_array( $all_quantity ) ){ | |
| 162 | + foreach( $all_quantity as $key => $quantity){ | |
| 163 | + $quantities[$key] = $quantity; | |
| 164 | + } | |
| 165 | + } | |
| 166 | + return $quantities; | |
| 167 | + | |
| 168 | + } | |
| 169 | + | |
| 170 | + /** | |
| 171 | + * Get Attendees | |
| 172 | + * | |
| 173 | + * @return array | |
| 174 | + */ | |
| 175 | + public function get_attendees() { | |
| 176 | + $all_attendees = $this->get_prop( 'attendees' ); | |
| 177 | + $attendees = []; | |
| 178 | + | |
| 179 | + if ( is_array( $all_attendees ) ) { | |
| 180 | + foreach( $all_attendees as $key => $attendee ) { | |
| 181 | + $attendees[] = [ | |
| 182 | + 'name' => $attendee['name'], | |
| 183 | + 'email' => $attendee['email'] | |
| 184 | + ]; | |
| 185 | + } | |
| 186 | + } | |
| 187 | + return $attendees; | |
| 188 | + | |
| 189 | + } | |
| 190 | + | |
| 191 | + /** | |
| 153 | 192 | * Get prop |
| 154 | 193 | * |
| 155 | 194 | * @param string |
| 156 | 195 | * |
| @@ -375,14 +414,19 @@ | ||
| 375 | 414 | * |
| 376 | 415 | * @return WP_Query |
| 377 | 416 | */ |
| 378 | 417 | private function booking_query() { |
| 379 | - $default_booking_status = timetics_get_option( 'default_booking_status', 'approved' ); | |
| 418 | + // Not tied to "default_booking_status" (that's what status a NEW | |
| 419 | + // booking starts in, not which bookings count here) — otherwise an | |
| 420 | + // approved booking can vanish from the customer's count/history the | |
| 421 | + // moment it's approved, on any site where new bookings default to | |
| 422 | + // pending. See core/reports/api-report.php for the same fix. | |
| 423 | + $counted_statuses = apply_filters( 'timetics/report/counted_statuses', [ 'approved', 'completed' ] ); | |
| 380 | 424 | |
| 381 | 425 | $query = new \WP_Query( |
| 382 | 426 | [ |
| 383 | 427 | 'post_type' => 'timetics-booking', |
| 384 | - 'post_status' => $default_booking_status, | |
| 428 | + 'post_status' => $counted_statuses, | |
| 385 | 429 | // @codingStandardsIgnoreStart |
| 386 | 430 | 'meta_key' => '_tt_booking_customer', |
| 387 | 431 | 'meta_value' => $this->id, |
| 388 | 432 | // @codingStandardsIgnoreEnd |