← All changes
|
app/Services/Integrations/FluentBooking/FluentBookingService.php
+28
-14
trunk
→
2.4.0
View file →
| @@ -10,8 +10,10 @@ | ||
| 10 | 10 | class FluentBookingService |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | + * Registers WordPress hooks for the booking-scheduled and agent-response events. | |
| 15 | + * | |
| 14 | 16 | * @return void |
| 15 | 17 | */ |
| 16 | 18 | public function init() |
| 17 | 19 | { |
| @@ -19,10 +21,12 @@ | ||
| 19 | 21 | add_action('fluent_support/response_added_by_agent', [$this, 'promoteGeneratedBookingLinksFromResponse'], 20, 3); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | /** |
| 23 | - * Pass $eventTypes if already loaded to skip the query. | |
| 25 | + * Returns the plugin's active/configured state. | |
| 24 | 26 | * |
| 27 | + * Pass $eventTypes from a prior getEventTypes() call to avoid a redundant DB query. | |
| 28 | + * | |
| 25 | 29 | * @param array|null $eventTypes |
| 26 | 30 | * @return array |
| 27 | 31 | */ |
| 28 | 32 | public function getStatus($eventTypes = null) |
| @@ -40,9 +44,9 @@ | ||
| 40 | 44 | ]; |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | /** |
| 44 | - * Active event types whose landing page is public, for the frontend selector. | |
| 48 | + * Returns all active, publicly-accessible event types the current user can read, shaped for the frontend selector. | |
| 45 | 49 | * |
| 46 | 50 | * @return array |
| 47 | 51 | */ |
| 48 | 52 | public function getEventTypes() |
| @@ -75,11 +79,12 @@ | ||
| 75 | 79 | return $eventTypes; |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | /** |
| 79 | - * Build the reply content (HTML and plain text) with a tokenised booking link. | |
| 80 | - * Selected slots are re-checked against live availability. | |
| 83 | + * Generates a tokenised booking URL and both HTML and plain-text email content. | |
| 81 | 84 | * |
| 85 | + * Each selected slot is validated against live availability before being embedded. | |
| 86 | + * | |
| 82 | 87 | * @param Ticket $ticket |
| 83 | 88 | * @param int $eventId |
| 84 | 89 | * @param string $message |
| 85 | 90 | * @param array $selectedSlots |
| @@ -126,9 +131,9 @@ | ||
| 126 | 131 | ]; |
| 127 | 132 | } |
| 128 | 133 | |
| 129 | 134 | /** |
| 130 | - * Available slots for the event in the given range, grouped by day. | |
| 135 | + * Fetches and formats available time slots for the given event and date range, grouped by day for the UI preview. | |
| 131 | 136 | * |
| 132 | 137 | * @param int $eventId |
| 133 | 138 | * @param string $range |
| 134 | 139 | * @param string $timezone |
| @@ -174,11 +179,12 @@ | ||
| 174 | 179 | ]; |
| 175 | 180 | } |
| 176 | 181 | |
| 177 | 182 | /** |
| 178 | - * Upcoming and past bookings for the ticket's customer, scoped to the | |
| 179 | - * events and dates of the ticket's stored links when there are any. | |
| 183 | + * Returns upcoming and past bookings for the ticket's customer. | |
| 180 | 184 | * |
| 185 | + * When stored link tokens exist the query is scoped to those event types and date range. | |
| 186 | + * | |
| 181 | 187 | * @param Ticket $ticket |
| 182 | 188 | * @return array |
| 183 | 189 | */ |
| 184 | 190 | public function getTicketMeetings(Ticket $ticket) |
| @@ -238,10 +244,12 @@ | ||
| 238 | 244 | return $meetings; |
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | /** |
| 242 | - * Add a timeline note when the customer books through a link sent from the ticket. | |
| 248 | + * Hook: fluent_booking/after_booking_scheduled. | |
| 243 | 249 | * |
| 250 | + * Appends an internal timeline note when a customer books via a link sent from this ticket. | |
| 251 | + * | |
| 244 | 252 | * @param object $booking |
| 245 | 253 | * @param object $calendarSlot |
| 246 | 254 | * @param array $bookingData |
| 247 | 255 | * @return void |
| @@ -284,10 +292,12 @@ | ||
| 284 | 292 | ]); |
| 285 | 293 | } |
| 286 | 294 | |
| 287 | 295 | /** |
| 288 | - * Store any tokenised booking links found in an agent response. | |
| 296 | + * Hook: fluent_support/response_added_by_agent. | |
| 289 | 297 | * |
| 298 | + * Scans outgoing response content for tokenised booking URLs and persists any found as ticket meta. | |
| 299 | + * | |
| 290 | 300 | * @param object $response |
| 291 | 301 | * @param Ticket $ticket |
| 292 | 302 | * @param object $person |
| 293 | 303 | * @return void |
| @@ -310,9 +320,9 @@ | ||
| 310 | 320 | } |
| 311 | 321 | } |
| 312 | 322 | |
| 313 | 323 | /** |
| 314 | - * FluentBooking is installed and the integration is enabled. | |
| 324 | + * Returns true when FluentBooking is installed. | |
| 315 | 325 | * |
| 316 | 326 | * @return bool |
| 317 | 327 | */ |
| 318 | 328 | public function isActive() |
| @@ -323,9 +333,9 @@ | ||
| 323 | 333 | return Helper::getBusinessSettings('enable_fluent_booking_integration', 'yes') === 'yes'; |
| 324 | 334 | } |
| 325 | 335 | |
| 326 | 336 | /** |
| 327 | - * The calendar's public landing page is enabled and includes this event. | |
| 337 | + * Returns true when the event's landing-page sharing is enabled and includes this slot. | |
| 328 | 338 | * |
| 329 | 339 | * @param object $event |
| 330 | 340 | * @return bool |
| 331 | 341 | */ |
| @@ -344,11 +354,15 @@ | ||
| 344 | 354 | return in_array((int) $event->id, array_map('intval', Arr::get($settings, 'enabled_slots', [])), true); |
| 345 | 355 | } |
| 346 | 356 | |
| 347 | 357 | /** |
| 348 | - * Landing-page URL for an event, prefilled with the customer and ticket ID when given. | |
| 349 | - * Forces getLandingPageUrl() because callers have already checked canUseEvent(). | |
| 358 | + * Builds the booking landing-page URL for an event. | |
| 350 | 359 | * |
| 360 | + * Uses Calendar::getLandingPageUrl() so FluentBooking owns its URL format (pretty-slug vs query-string). | |
| 361 | + * canUseEvent() has already confirmed the landing page is enabled, so $isForce = true skips the | |
| 362 | + * redundant settings re-check inside getLandingPageUrl(). | |
| 363 | + * Appends customer name, email, and ticket ID when a ticket is provided. | |
| 364 | + * | |
| 351 | 365 | * @param object $event |
| 352 | 366 | * @param Ticket|null $ticket |
| 353 | 367 | * @return string |
| 354 | 368 | */ |
| @@ -377,9 +391,9 @@ | ||
| 377 | 391 | ]), $url)); |
| 378 | 392 | } |
| 379 | 393 | |
| 380 | 394 | /** |
| 381 | - * Add fs_booking_link_token so a booking can be traced back to the link that was sent. | |
| 395 | + * Appends fs_booking_link_token to a URL so a completed booking can be traced back to the originating ticket link. | |
| 382 | 396 | * |
| 383 | 397 | * @param string $url |
| 384 | 398 | * @param string $linkToken |
| 385 | 399 | * @return string |