Okay
  Public Ticket #2670017
Changing of provider for appointment doesn't update Google Calendar
Closed

Comments

  •   Simon Lobo started the conversation
  • Simon Lobo replied

    I just tested changing the time of the appointment too, and this is not reflected in the Google Calendar either...

  • Simon Lobo replied

    After debugging I've found the call Runner::run throws an exception:

    Error calling PUT https://www.googleapis.com/calendar/v3/calendars/simon%40axcultures.com/events/c4gaod83c0r82efkbb7nuo48hg?sendNotifications=false: (404) Not Found

    Call stack:

    Runner.php:176, AmeliaGoogle_Task_Runner->run()
    REST.php:46, AmeliaGoogle_Http_REST::execute()
    Client.php:593, AmeliaGoogle_Client->execute()
    Resource.php:240, AmeliaGoogle_Service_Calendar_Events_Resource->call()
    Calendar.php:1742, AmeliaGoogle_Service_Calendar_Events_Resource->update()
    GoogleCalendarService.php:393, AmeliaBooking\Infrastructure\Services\Google\GoogleCalendarService->updateEvent()
    GoogleCalendarService.php:226, AmeliaBooking\Infrastructure\Services\Google\GoogleCalendarService->handleEvent()
    AppointmentEditedEventHandler.php:137, AmeliaBooking\Infrastructure\WP\EventListeners\Booking\Appointment\AppointmentEditedEventHandler::handle()
    AppointmentEventsListener.php:69, AmeliaBooking\Infrastructure\WP\EventListeners\Booking\Appointment\AppointmentEventsListener->handle()
    Emitter.php:217, call_user_func_array:{D:\www\cac\wp-content\plugins\ameliabooking\vendor\league\event\src\Emitter.php:217}()
    Emitter.php:217, League\Event\Emitter->invokeListeners()
    Emitter.php:169, League\Event\Emitter->emit()
    DomainEventBus.php:40, AmeliaBooking\Domain\Events\DomainEventBus->emit()
    UpdateAppointmentController.php:68, AmeliaBooking\Application\Controller\Booking\Appointment\UpdateAppointmentController->emitSuccessEvent()
    Controller.php:125, AmeliaBooking\Application\Controller\Booking\Appointment\UpdateAppointmentController->__invoke()
    RequestResponse.php:40, call_user_func:{D:\www\cac\wp-content\plugins\ameliabooking\vendor\slim\slim\Slim\Handlers\Strategies\RequestResponse.php:40}()
    RequestResponse.php:40, Slim\Handlers\Strategies\RequestResponse->__invoke()
    Route.php:281, Slim\Route->__invoke()
    MiddlewareAwareTrait.php:117, Slim\Route->callMiddlewareStack()
    Route.php:268, Slim\Route->run()
    App.php:503, Slim\App->__invoke()
    MiddlewareAwareTrait.php:117, Slim\App->callMiddlewareStack()
    App.php:392, Slim\App->process()
    App.php:297, Slim\App->run()
    ameliabooking.php:167, AmeliaBooking\Plugin::wpAmeliaApiCall()
    class-wp-hook.php:287, WP_Hook->apply_filters()
    class-wp-hook.php:311, WP_Hook->do_action()
    plugin.php:484, do_action()
    admin-ajax.php:184, {main}()
    
  • Simon Lobo replied

    Furthermore, I was successful in changing the time if I kept the original employee - but once I changed the employee no other changes were synced...

  •  2,572
    Aleksandar replied

    Hello Simon

    Thank you for your purchase.

    At the moment, changing the employee in back-end will not update the associated employee's Google Calendar, as you confirmed in your testing.

    Our developers are aware of this, and they will work on the issue for one of our future updates. I can't say when it will be resolved, but it is on our "to-do" list.

    Sorry for the inconvenience.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Simon Lobo replied

    Updated the code myself in Google CalendarService.php and it seems to be working pretty well:

    public function handleEvent($appointment, $commandSlug, $originalEmployeeId = null)
        {
            /** @var ProviderRepository $providerRepository */
            $providerRepository = $this->container->get('domain.users.providers.repository');         $appointmentStatus = $appointment->getStatus()->getValue();         $provider = $providerRepository->getById($appointment->getProviderId()->getValue());         if ($provider->getGoogleCalendar() && $provider->getGoogleCalendar()->getCalendarId()->getValue()) {
                $this->authorizeProvider($provider);             switch ($commandSlug) {
                    case AppointmentAddedEventHandler::APPOINTMENT_ADDED:
                    case BookingAddedEventHandler::BOOKING_ADDED:
                        // Add new appointment or update existing one
                        if (!$appointment->getGoogleCalendarEventId()) {
                            $this->insertEvent($appointment, $provider);
                        } else {
                            $this->updateEvent($appointment, $provider);
                        }                     // When status is pending we must first insert the event to get event ID
                        // because if we update the status later to 'Approved' we must have ID of the event
                        if ($appointmentStatus === 'pending' && $this->settings['insertPendingAppointments'] === false) {
                            $this->deleteEvent($appointment, $provider);
                        }
                        break;
                    case AppointmentEditedEventHandler::APPOINTMENT_EDITED:
                    case AppointmentTimeUpdatedEventHandler::TIME_UPDATED:
                    case AppointmentStatusUpdatedEventHandler::APPOINTMENT_STATUS_UPDATED:
                    case BookingCanceledEventHandler::BOOKING_CANCELED:
                        if ($appointmentStatus === 'canceled' || $appointmentStatus === 'rejected' ||
                            ($appointmentStatus === 'pending' && $this->settings['insertPendingAppointments'] === false)
                        ) {
                            $this->deleteEvent($appointment, $provider);
                            break;
                        }                     if (($commandSlug == AppointmentEditedEventHandler::APPOINTMENT_EDITED) &&
                          ($originalEmployeeId !== null) &&
                          ($originalEmployeeId != $provider->getId()->getValue())) {
                          $appointment->setProviderId(new \AmeliaBooking\Domain\ValueObjects\Number\Integer\Id($originalEmployeeId));                       $this->deleteEvent($appointment, $providerRepository->getById($originalEmployeeId));                       $appointment->setProviderId($provider->getId());                       $this->insertEvent($appointment, $provider);
                        }
                        else {
                          $this->updateEvent($appointment, $provider);
                        }
                        break;
                    case AppointmentDeletedEventHandler::APPOINTMENT_DELETED:
                        $this->deleteEvent($appointment, $provider);
                        break;
                }
            }
        }
  •  2,572
    Aleksandar replied

    Awesome, Simon, thank you very much for this!

    I forwarded the code to our developers, so they will implement the change in our next update.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2,572
    Aleksandar replied

    Thank you once again, Simon!

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables