Developer notes
Data model
Section titled “Data model”| Table | Purpose |
|---|---|
kv_et_events |
One row per event product: product_id (unique), company_id (the organiser), status (A, D), starts_at, ends_at, venue, address, note, option_id (the ticket type option), total_capacity. |
kv_et_types |
One row per ticket type: event_id, variant_id (0 = the default type), name, capacity (0 = unlimited). |
kv_et_lines |
One row per order line that holds seats: state R (reserved, order placed), I (issued), V (void). Seats taken = sum of qty in R and I; an R line of an Incomplete order (status N, online payment not finished) counts for one hour after it was written. |
kv_et_tickets |
One row per ticket: unique code (10 characters), unique (order_id, item_id, seq) which makes issuing idempotent, holder, status V valid, U used, X void, void_reason O (order) or A (admin), scans, reminded. |
kv_et_scans |
Scan log: ticket, device scan time, server time, user, result. |
The QR payload
Section titled “The QR payload”KT1-<code>-<signature>: the 10-character ticket code and the first 16 hex characters of HMAC-SHA256("KT1|" + code, key). The key is 64 random hex characters in the core storage data (kv_et_signing_key), created on first use, never in a setting and never printed. The scanner sends the payload to the server; the server checks the signature (constant time) and looks the code up. A typed code (no signature) is accepted from staff. The QR encoder is part of the add-on (ISO/IEC 18004, byte mode, error correction M); the jsQR reader used as a fallback by the scanner is bundled under the Apache License 2.0 (js/addons/kv_event_tickets/jsqr.LICENSE.txt).
Order status rules
Section titled “Order status rules”- Issuing:
fn_get_settled_order_statuses()(payment received); with the setting “Paid or open” alsofn_get_order_paid_statuses()(statuses that decrease the inventory) minus the void list. - Voiding: the explicit list in the setting
void_statuses, plus (settingvoid_on_stock_return, default on, 1.0.1) a custom order status that does not decrease the inventory and is not paid. Never Incomplete (N), the Multi-Vendor parent order (T) or Backordered (B).Config::returnsStock(). - Order editor (1.0.1): the
place_orderhook of an order that already has lines reconciles it: lowered quantity voids tickets above it (reason Q), a gone or re-keyed line is voided, a raised quantity brings Q tickets back. - Attendee save (
tickets.attendees) checks the session form key (security_hash), printed in the cart template asdata-kv-et-hash. - Multi-Vendor parent orders (
is_parent_order = Y) are skipped; the line is processed in the child order that holds it. - A second
change_order_status_postfor the same order and status changes nothing.
Hooks used
Section titled “Hooks used”PHP: pre_add_to_cart (sale window and capacity), pre_place_order (takes the named MySQL lock seats, checks capacity and names, copies the names into the line extra), place_order (writes the reservation of the new order, also for an order that stays Incomplete on a payment page, then releases the lock), change_order_status_post, delete_order, delete_product_post, update_product_post (the Event tab), before_dispatch (admin fallback of the cron pass). Template hooks: products:product_detail_bottom, checkout:extra_list (attendee form), profiles:my_account_menu, orders:info, and in the admin panel products:tabs_content and orders:detailed_after_content.
Page cache and block cache
Section titled “Page cache and block cache”The product page output depends on the event, never on the visitor. Seats left come from tickets.availability?product_id=... (JSON, Cache-Control: no-store). The attendee form is on the cart page, which the full page cache never stores. block_cache_properties.post.php puts the license state and the kv_et_events and kv_et_types tables into the block cache.
Scanner API
Section titled “Scanner API”Both calls are POST requests of the admin or vendor panel (with the panel’s security_hash) and answer JSON; both need the scan privilege.
tickets.verify:code,event_id(0 = any),ts(the time of the scan on the device),peek(report without checking in). Answer:result(ok,duplicate,void,invalid,not_found,wrong_event),ticket(holder, type, event, code),first_used_at,first_used_by,counts.tickets.sync:scans= JSON list of{id, code, ts, event_id}; replayed intsorder. Answer: one result per item.
Extending
Section titled “Extending”Tygh\Addons\KvEventTickets\Tickets::scan($raw, $context)is the single door verdict;::setStatus(),::setHolder()are the manual actions.Events::forProduct($product_id)returns the active event of a product with its types;Events::remaining($event, $type)the seats left.- For tests,
Notifier::$spyreceives the e-mails instead of the mailer, and$config['kv_event_tickets_mail_off'] = trueinconfig.local.phpsuppresses them.
Compatibility rules
Section titled “Compatibility rules”PHP 7.4 syntax, Smarty 4 and 5 safe templates (no template plugins; PHP functions used as modifiers are the add-on’s own fn_kv_event_tickets_cart_lines and fn_kv_event_tickets_order_tickets), Twig 2 and 3 safe e-mail templates.
Personal data
Section titled “Personal data”The attendee name and e-mail of every ticket are in kv_et_tickets. schemas/gdpr/user_data.post.php adds them to the core GDPR tools (export and anonymization of a customer: the tickets the customer bought and the tickets that carry the customer’s e-mail). Deleting an order removes the attendee name, e-mail and customer link of its tickets; the voided rows stay for the event counters. Uninstalling the add-on drops all its tables.