Developer reference · v1.2.0
Developer reference
Architecture, data model, REST API and the extension hooks you can build on. Flexatech Stay Suite is a standalone booking engine and does not depend on WooCommerce.
Introduction
Overview
Stay Suite is a domain-driven plugin. Custom post types hold properties and rooms; pricing, inventory, orders and payments live in dedicated database tables; a REST API drives both the storefront and the React admin app.
| Item | Value |
|---|---|
| Text domain | flexatech-stay-suite |
| PHP namespace | Flexatech\\StaySuite\\ |
| Autoload | PSR-4, src/ → Flexatech\StaySuite\ |
| REST namespace | flexatech-stay-suite/v1 |
| Hook prefix | flexatech_stay_suite/ |
Design
Architecture
The code is organised by responsibility under src/:
| Layer | Responsibility |
|---|---|
Domain | Entities and repositories (Order, Room, Property, Payment, RatePlan, Inventory, Coupon, Customer). |
Services | Use cases: pricing, availability, checkout, booking lifecycle. |
Rest | REST controllers for storefront and admin. |
Frontend | Post types, shortcodes, blocks, templates, assets. |
Admin | Menu, React app mount, metaboxes, Setup dashboard. |
Gateways | Payment gateway registry and implementations. |
Emails | Transactional emails wired to domain events. |
The admin UI is a React + Vite single-page app mounted inside the Stay Suite menu; it talks to the same REST API documented below.
Setup
Install & requirements
| Requirement | Version |
|---|---|
| WordPress | 6.0 or newer |
| PHP | 8.1 or newer |
| WooCommerce | Not required |
Activation registers the post types, creates the database tables, and flags a rewrite flush. It does not create any pages; the storefront pages are created on demand from the Setup screen.
Data
Post types & taxonomies
| Object | Key | Notes |
|---|---|---|
| Property | flss_property | The hotel or building. |
| Room | flss_room | Bookable unit. Has an archive at /rooms/. |
| Room type | flss_room_type | Taxonomy on rooms. |
| Amenity | flss_amenity | Taxonomy on rooms. |
A room links to its property through the _flss_property_id meta key. Property details live in meta: _flss_property_address, _flss_property_phone, _flss_property_email, and the check-in / check-out times.
Data
Data model
Pricing, inventory, orders and payments are stored in custom tables (prefixed with the site’s $wpdb->prefix), not in post meta:
| Table | Holds |
|---|---|
flss_rate_plans | Rate plans attached to rooms. |
flss_rate_plan_rules | Nightly price rules (price_cents). |
flss_date_overrides | Per-date price overrides. |
flss_room_inventory | Per room, per date total availability. |
flss_orders | Bookings. |
flss_order_items | Rooms within a booking. |
flss_order_item_extras | Extras on a booked room. |
flss_payments | Payments against an order. |
flss_refunds | Refunds against a payment. |
flss_coupons | Discount codes. |
flss_customers | Guest records. |
flss_webhook_events | Gateway webhook log. |
Money is stored in cents
Frontend
Shortcodes & blocks
| Shortcode | Renders |
|---|---|
[flexatech_hotel_search] | Search / availability form. |
[flexatech_hotel_rooms] | Room list with results. |
[flexatech_hotel_room] | A single room with booking. |
[flexatech_hotel_properties] | Property list. |
[flexatech_hotel_cart] | Cart. |
[flexatech_hotel_checkout] | Checkout. |
[flexatech_hotel_thankyou] | Confirmation. |
[flexatech_hotel_account] | My bookings. |
Equivalent blocks are registered for the block editor:
| Block | Equivalent |
|---|---|
flexatech-stay-suite/room-search | Search form |
flexatech-stay-suite/room-list | Room list |
flexatech-stay-suite/single-room-booking | Single room booking |
Integration
REST API reference
All routes are under /wp-json/flexatech-stay-suite/v1. Public read endpoints power the storefront; write and admin endpoints require the matching capability and a REST nonce.
GET /rooms - list bookable rooms; accepts date and occupancy params for availability.
GET /rooms/<id> - a single room.
GET /rooms/<id>/calendar - per-day price and availability for a month.
GET /properties - list properties.
POST /quote - price a stay before checkout.
POST /checkout - create a booking.
GET /account/bookings - the current guest’s bookings.
GET /bookings, GET /stats, GET /rate-plans, GET /overrides, GET /coupons, GET /settings - admin data (require capability).
Authentication
manage_options, each filterable (see below). Never expose an admin endpoint with __return_true.Extend
Hooks · Actions
Events you can listen to. Full argument details are in docs/HOOKS.md in the plugin.
| Action | Fires when |
|---|---|
flexatech_stay_suite/booking/created | A booking is created at checkout. |
flexatech_stay_suite/booking/status_changed | An order moves between statuses. |
flexatech_stay_suite/booking/cancelled | An order is cancelled. |
flexatech_stay_suite/payment/completed | A gateway confirms payment. |
flexatech_stay_suite/payment/refunded | A payment is refunded. |
flexatech_stay_suite/settings/updated | Settings are saved. |
flexatech_stay_suite/rest/register_routes | Register your own REST routes. |
add_action(
'flexatech_stay_suite/payment/completed',
function ( int $order_id, int $payment_id ) {
my_slack_notify( "Booking #{$order_id} paid." );
},
10,
2
);Extend
Hooks · Filters
Change values before they are used:
| Filter | Purpose |
|---|---|
flexatech_stay_suite/pricing/price_for_date | Final nightly price (cents) for a room on a date. |
flexatech_stay_suite/availability/remaining | Rooms remaining for a stay range. |
flexatech_stay_suite/checkout/totals | The computed totals payload. |
flexatech_stay_suite/gateways/register | Add or replace payment gateways. |
flexatech_stay_suite/rest/room_summary | Add fields to each room in REST output. |
flexatech_stay_suite/capabilities/manage | Capability required for admin access. |
flexatech_stay_suite/domain/*/to_array | Reshape any domain object before serialization. |
add_filter(
'flexatech_stay_suite/pricing/price_for_date',
function ( int $cents, int $room_id, DateTimeImmutable $day ) {
$weekend = in_array( (int) $day->format( 'N' ), [ 6, 7 ], true );
return ( 42 === $room_id && $weekend )
? (int) round( $cents * 1.15 )
: $cents;
},
10,
3
);Extend
Custom payment gateways
Register a gateway on gateways/register and resolve it by id on gateway/<id>. Your class implements PaymentGatewayInterface.
add_filter(
'flexatech_stay_suite/gateways/register',
function ( array $gateways ) {
$gateways['my_gateway'] = new My_Gateway();
return $gateways;
}
);
add_filter(
'flexatech_stay_suite/gateway/my_gateway',
fn () => new My_Gateway()
);Extend
Template overrides
Frontend and email templates are overridable. Point a template name at your own file, or turn off the default single / archive room templates entirely.
| Filter | Purpose |
|---|---|
flexatech_stay_suite/frontend/locate_template | Override a storefront template path. |
flexatech_stay_suite/frontend/use_default_templates | Return false to stop taking over room templates. |
flexatech_stay_suite/email/locate_template | Override an email template. |
flexatech_stay_suite/frontend/js_config | Filter the storefront JS config object. |
Extend
Email delivery
Each transactional email exposes filters for its subject, recipients, headers, heading and body, keyed by email id (for example flexatech_stay_suite/email/customer_booking/headers). Emails are also event-driven, so you can attach your own listeners.
Reliable delivery
Reference
Internationalization
Every user-facing string is translatable under the flexatech-stay-suite text domain, on both the PHP side and the React admin app. Drop a .mo file in the standard languages directory to translate the plugin.
Reference
Changelog
| Version | Highlights |
|---|---|
| 1.2.0 | First-run Setup dashboard with a real weighted completion score, one-click booking pages, one-click demo content (a sample hotel you can import and remove), an online documentation site, and a MailBridge email recommendation. |
| 1.1.1 | Capability hardening for the admin data routes, menu repositioned, and a clean Plugin Check pass. |
| 1.1.0 | Standalone hotel booking engine: properties, rooms, rates, inventory, cart, checkout and payments. |
See readme.txt in the plugin for the authoritative changelog.