Admin Workflow & Zoho Creator Integration
Operational workflow for managing course dates between Zoho Creator (master database) and WooCommerce (e-commerce front). The site already ships with a live WooCommerce server layer — once connected, products, variations, orders, and webhooks flow end-to-end.
0. What's already wired in this app
- Server functions in
src/lib/courses.functions.ts:listCourses,getCourseWithDates,placeOrder. They call WooCommerce via the Lovable connector gateway, with automatic fallback to mock data until the store is connected. - WooCommerce webhook receiver at
/api/public/woocommerce/webhook(HMAC-SHA256 verified). Handles order.completed, processing, failed, cancelled. - Zoho Creator push via
src/lib/zoho-creator.server.ts. SetZOHO_CREATOR_WEBHOOK_URL(and optionallyZOHO_CREATOR_AUTH_TOKEN) in project secrets. - Customer & admin emails stubbed in
src/lib/order-emails.server.ts— ready to plug into Lovable Emails.
Required secrets
WOOCOMMERCE_API_KEY+LOVABLE_API_KEY— auto-injected when the WooCommerce connector is linked.WOOCOMMERCE_WEBHOOK_SECRET— paste the same value into Woo → Settings → Advanced → Webhooks → Secret.ZOHO_CREATOR_WEBHOOK_URL— your Creator REST API form workflow URL.ADMIN_ALERT_EMAIL— where failed-order alerts are sent.
1. Recommended WooCommerce Setup
- Product type: Variable Product — one product per course, one variation per date.
- Categories: Domestic, Commercial, Guided Learning.
- Attribute: "Course Date" (used to create variations).
- Stock: manage stock per variation = available spaces.
- Recommended plugins: WooCommerce, WooCommerce Stripe Gateway, WooCommerce PDF Invoices & Packing Slips, YITH WooCommerce Bookings, WooCommerce Subscriptions (optional), Elementor + Elementor Pro.
2. Zoho Creator as Master Database
A single Courses form in Zoho Creator stores authoritative data:
| Field | Type |
|---|---|
| Course Name | Lookup |
| Course Date | Date |
| Venue | Text |
| Trainer | Lookup |
| Available Spaces | Number |
| WooCommerce Product ID | Number |
| WooCommerce Variation ID | Number |
| Booking Status | Picklist (Open, Full, Cancelled) |
3. Adding a New Course Date
- Staff opens Zoho Creator → Courses form.
- Adds new record with course, date, venue, trainer, spaces.
- A Deluge workflow fires
POST /wp-json/wc/v3/products/<product_id>/variationsvia WooCommerce REST API. - WooCommerce returns the new variation ID — Deluge writes it back into the Zoho record.
- The variation is automatically visible on the course page and calendar.
4. Removing Expired Dates
A scheduled Zoho Creator workflow runs daily:
- Selects all course records where Course Date is before today.
- For each, calls
PUT /wp-json/wc/v3/products/<id>/variations/<vid>with status: private to hide it. - Updates booking status to "Closed" in Zoho.
The course page filter (date ≥ today) also hides expired dates client-side.
5. Updating Spaces After a Booking
A WooCommerce webhook (Order Created) is registered to a Zoho Creator REST endpoint:
- WooCommerce sends order payload including variation ID and qty.
- Zoho Creator finds the matching course record by Variation ID.
- Decrements Available Spaces by qty.
- If spaces reach 0, status is set to "Full" and the WooCommerce variation stock is set to 0.
6. Daily Sync Safety Net
A nightly Zoho schedule re-pushes all open course dates to WooCommerce to correct any drift. Conflicts are logged in a Sync Log form for staff review.
7. Roles
- Course Admin — creates and edits course dates in Zoho.
- Finance — manages WooCommerce orders, refunds, coupons.
- Trainer — read-only access to upcoming dates and attendee list.
