| @@ -466,18 +466,21 @@ | ||
| 466 | 466 | /** |
| 467 | 467 | * Returns the booking or customer phone number, if any. |
| 468 | 468 | * Note that the + prefix may not be included. |
| 469 | 469 | * |
| 470 | + * @param ?string $forcedPhone Optional phone number to sanitize. | |
| 471 | + * | |
| 470 | 472 | * @return ?string |
| 471 | 473 | * |
| 472 | 474 | * @since 1.18.8 (J) - 1.8.8 (WP) |
| 475 | + * @since 1.18.16 (J) - 1.8.16 (WP) added argument $forcedPhone. | |
| 473 | 476 | */ |
| 474 | - public function getPhoneNumber() | |
| 477 | + public function getPhoneNumber(?string $forcedPhone = null) | |
| 475 | 478 | { |
| 476 | - // give higher priority to booking-level phone number | |
| 477 | - $phoneNumber = $this->getProperty('phone'); | |
| 479 | + // give higher priority to passed or booking-level phone number | |
| 480 | + $phoneNumber = $forcedPhone ?: $this->getProperty('phone'); | |
| 478 | 481 | |
| 479 | - if (!$phoneNumber) { | |
| 482 | + if (!$phoneNumber && $forcedPhone !== null) { | |
| 480 | 483 | // fetch booking customer details |
| 481 | 484 | $customer = $this->getCustomer(); |
| 482 | 485 | |
| 483 | 486 | // check customer-level phone number |
| @@ -495,8 +498,22 @@ | ||
| 495 | 498 | $phoneNumber = substr_replace($phoneNumber, '+', 0, 2); |
| 496 | 499 | } |
| 497 | 500 | |
| 498 | 501 | return $phoneNumber ?: null; |
| 502 | + } | |
| 503 | + | |
| 504 | + /** | |
| 505 | + * Returns the booking alias phone number (masked phone), if any. | |
| 506 | + * | |
| 507 | + * @return ?string | |
| 508 | + * | |
| 509 | + * @since 1.18.16 (J) - 1.8.16 (WP) | |
| 510 | + */ | |
| 511 | + public function getAliasPhoneNumber() | |
| 512 | + { | |
| 513 | + $phoneAlias = (string) $this->getProperty('phone_alias'); | |
| 514 | + | |
| 515 | + return $phoneAlias ? $this->getPhoneNumber($phoneAlias) : null; | |
| 499 | 516 | } |
| 500 | 517 | |
| 501 | 518 | /** |
| 502 | 519 | * Returns the booking or customer email address, if any. |