Developer notes
Technical reference of Restaurant Online Ordering: data, hooks, endpoints, caching and the theme surface. Back to the overview.
The add-on never changes core files. Add-on ID: kv_restaurant_ordering.
| Table | Content |
|---|---|
?:kv_rso_restaurants |
One row per restaurant (company): enabled, preparation minutes, minimum order, price level, ASAP / scheduled switches, order-ahead days, slot step, slot capacity, lead minutes, busy until (UNIX time), busy extra minutes. |
?:kv_rso_hours |
Weekly opening rows: weekday 1 (Monday) to 7, open_min, close_min in minutes after local midnight; close_min above 1440 means after midnight. |
?:kv_rso_closures |
Closed days (date_from, date_to, note). A closure removes the openings that start on those dates. |
?:kv_rso_cuisines, ?:kv_rso_company_cuisines |
Cuisine list and the cuisines of a restaurant. |
?:kv_rso_groups, ?:kv_rso_items |
Choice groups of a product (min / max choices, status) and their choices (price, preselected, sold_out_date, status). |
?:kv_rso_orders |
One row per restaurant order (child order on Multi-Vendor): mode (A = ASAP, S = scheduled), preparation minutes, target time (UNIX), kitchen state, placed / state / printed times. |
?:kv_rso_log |
Event log: placed, kitchen moves, busy mode. |
A restaurant is a company: a Multi-Vendor vendor, an Ultimate storefront or the single CS-Cart company. Times are wall-clock hours in the store time zone (date_default_timezone_get()), expanded per day with DateTimeImmutable, so daylight saving changes move the real time but not the printed one (a nonexistent local time moves forward, an ambiguous one takes the first occurrence).
Hooks used
Section titled “Hooks used”PHP: pre_add_to_cart (validate and normalise choices, refuse closed restaurants), generate_cart_id (a combination is its own cart line), apply_option_modifiers_post (price of the choices; prices are read from the database, the stored extra is only a fallback for a deleted choice), gather_additional_products_data_pre and gather_additional_product_data_post (has_options, sheet data), pre_place_order (re-check), place_order (kitchen record), get_order_info (choices as product options, kv_rso_tracks), change_order_status (state follows the status), delete_order, update_product_post, clone_product, delete_product_post, delete_company. All have identical arguments in 4.17.2 and 4.21.2.
Template hooks: storefront products:product_option_content (post), checkout:extra_list (post), checkout:summary (post), checkout:product_options (post), block_checkout:product_extra (post), checkout:minicart_product_info (post), orders:info (post), checkout:order_confirmation (post), companies:products (pre); admin products:detailed_content (post).
Cart data
Section titled “Cart data”Choices are kept in the cart item extra kv_rso: sel (group id => choice ids), lines (group id, group name, choices with id, name, price), price, text. The same extra is stored with the order item, so an order is readable after the menu changes or the add-on is removed. get_order_info appends one display-only entry (flag kv_rso = true) per group to product_options of the order item; that is how invoices, documents and e-mails show them. The entries are rebuilt on every read and never saved.
PHP API
Section titled “PHP API”use Tygh\Addons\KvRestaurantOrdering\Restaurants;
$a = Restaurants::availability($company_id);// open, busy, holiday, can_asap, can_scheduled, reason ('' | closed | busy | holiday | off), opens_at, closes_at, prep, eta_from, eta_to$slots = Restaurants::scheduleSlots($company_id); // ['Y-m-d' => [UNIX time, ...]]$ok = Restaurants::slotAllowed($company_id, $ts); // hours, horizon, prep time, capacity$cards = Restaurants::cards([$company_id]); // static card data for themesSchedule (pure functions, no database): windows(), state(), slots(), contains(), normalizePair(). Modifiers::resolve($product_id, $posted) validates a selection and returns price and text; Kitchen::move($order_id, $state, $scope, $user_id) moves an order (atomic claim, status change through core).
Storefront endpoints
Section titled “Storefront endpoints”| Request | Result |
|---|---|
GET index.php?dispatch=kv_rso.status&ids=1,2 |
JSON: per restaurant open, busy, can_asap, can_scheduled, label, eta_text, opens_label, preorder, min_order. Cache-Control: no-store, private, up to 60 ids, no session write. |
GET kv_rso.track&order_id=N |
JSON kitchen steps of an order of the signed-in customer (or a guest’s own order); 403 for anybody else. |
POST kv_rso.when |
Stores the ASAP / scheduled choice in the cart and returns the current problems. The same data posted with the checkout form is read by checkout.pre.php; the server decides at place_order. |
GET kv_rso.restaurants |
Restaurant list page. |
Full page cache (4.21)
Section titled “Full page cache (4.21)”Cacheable dispatches (index.index, products.view, categories.view, companies.products) print only data that is the same for every visitor: menu groups, prices, card data, weekly hours as text. The open / closed label, the ETA and the sold-out state of the current minute come from kv_rso.status or from the block cache key (fn_kv_restaurant_ordering_cache_key(): licence state + store day) and the table tags of the menu tables, so a changed menu refreshes the pages. Cart, checkout, order pages and every endpoint above are not cacheable dispatches. Nothing is written to ?:storage_data at runtime.
Security
Section titled “Security”- Every rule runs on the server: choices at
pre_add_to_cart, opening hours and timing atpre_place_orderandcheckout.place_order; client code only shows the state. - Posted choice ids are matched against the product’s active groups; unknown groups or choices, sold-out choices, duplicates and counts outside min / max are refused; prices always come from the database.
- Vendor and storefront access: every admin action compares the order’s or product’s company with
runtime.company_id; the cuisine list is root-only. Moves use an atomicUPDATE ... WHERE kitchen_state = old. - All names are escaped in templates; HTML is stripped when a name is saved.
Theme surface
Section titled “Theme surface”See notes/THEME-HOOKS.md of the add-on source (block list, BEM classes, CSS tokens, script events).
License
Section titled “License”Without a valid license the choice and opening-hours rules, new kitchen records and the kitchen board actions are off; orders already placed and all stored data are kept. The check contacts only cs-cart.kaviolabs.com, only from the admin panel or cron, and sends only the license key, add-on ID and version, storefront hosts, CS-Cart version and edition and a nonce.
File map
Section titled “File map”app/addons/kv_restaurant_ordering/ addon.xml init.php func.php controllers/backend/kv_rso.php, products.post.php controllers/frontend/kv_rso.php, checkout.pre.php, checkout.post.php, companies.post.php schemas/{menu,permissions,settings,block_manager}/ Tygh/Addons/KvRestaurantOrdering/{Config,Schedule,Restaurants,Modifiers,Cart,Kitchen,Installer}.php Tygh/Addons/KvRestaurantOrdering/{License,Upgrade}/design/backend/templates/addons/kv_restaurant_ordering/{views/kv_rso,hooks,license}/var/themes_repository/responsive/templates/addons/kv_restaurant_ordering/{blocks,components,hooks,views}/var/themes_repository/responsive/css/addons/kv_restaurant_ordering/styles.lessjs/addons/kv_restaurant_ordering/{func.js,admin.js}