Generate a WordPress plugin that syncs bookings with Google Calendar
If your WordPress site takes bookings, your calendar needs to reflect them instantly. Double-booked appointments are the fastest way to lose trust. Google Calendar is the most common backbone; the plugin's job is to create events when bookings come in, block availability when the calendar already has events from other sources, and handle rescheduling from either side.
A custom Google Calendar plugin uses the Calendar v3 API with a Service Account (no OAuth dance every 60 days), watches for changes via push notifications (or polls every 5 min as a fallback), and keeps booking records in WordPress while mirroring the event in Calendar. We build it around your specific booking shape.
Why generate it instead of installing an existing plugin?
The big booking plugins (Amelia, LatePoint, Bookly) include Google Calendar sync in their pro tiers. If you already own one of them for the booking UI, you probably have this. If you do not, or if your booking model is custom (a specific industry workflow), building the calendar sync separately lets you keep your existing booking logic.
Service Account authentication avoids the most annoying part of Google Calendar integrations: the token refresh dance. The shop owner shares the calendar with the service account email once, and the plugin has permanent access until revoked.
Two-way sync is where generic integrations fall apart. A plugin that listens for Google's push notifications (or polls as fallback) and updates WordPress when someone drags an event in the Calendar UI gives you real consistency. Fire-and-forget integrations create drift you eventually have to reconcile manually.
Example prompt
This is the kind of description that generates this plugin. You can start from it and tweak whatever you need before hitting generate.
Plugin name: Acme Booking Calendar Sync
Authentication: Service Account (JSON credentials pasted in plugin settings).
Target calendar: specific Google Calendar ID in settings.
On booking created in WordPress (custom post type "booking" with meta date, time, duration, customer_name, customer_email):
- Create a Google Calendar event with start/end, summary "Booking - {customer_name}", description with all booking details, attendee = customer_email.
- Store the Google event ID in booking meta.
On booking updated:
- Update the corresponding Google Calendar event.
On booking deleted:
- Delete the Google Calendar event.
Reverse direction (Google → WordPress):
- Watch notifications via Google push (or fallback 5-min cron poll).
- On Google event changed: update the corresponding booking post if we created the event. Do not touch events that came from outside.
Availability check:
- Before accepting a new booking, query freeBusy on the calendar for the proposed slot. Reject if conflict.
Admin: service account JSON, calendar ID, time zone, settings for what fields to include in the event description.What the generated plugin typically includes
- Google API client (Composer vendor/) or wp_remote_post with JWT service account auth
- OAuth 2 JWT flow cached in a transient (50-min tokens)
- Two-way sync: hooks on booking CPT + push notification webhook + polling fallback
- freeBusy check before accepting new bookings
- Event IDs stored in post meta for idempotent updates
- Admin page with credentials, calendar ID, field mapping, timezone
- Logs of recent sync events and reconcile tool
Works with any booking plugin via hook adapter (WooCommerce Bookings, Amelia, your own CPT). Mention which you use.
Frequently asked questions
Does it work with Google Workspace or free Gmail?
Both. You need API access enabled (it is enabled by default on Workspace; free Gmail also works through Google Cloud Console). Service Accounts are created in Cloud Console on either tier.
Will bookings appear on the team's calendars too?
If you share the base calendar with the team, yes. We can also add team members as "attendees" so each of them gets the event on their own calendar. Describe the desired behaviour in the prompt.
What happens if Google API is down?
The booking is created in WordPress regardless (primary source of truth). The Calendar event is queued and retried every 10 minutes. Admin sees a "pending sync" badge.
Does it handle time zones correctly?
Yes. All internal storage is UTC. Display and API calls convert to the calendar's timezone. Customer emails can show their own timezone based on profile or browser detection.