Skip to content

Developer notes

Table Purpose
?:kv_agv_rules Rules: object_type C category / P product / V vendor, object_id, min_age (0 = no limit), set_by A (exact) / V (can only raise).
?:kv_agv_cat_index Effective age per category (nearest rule on the id_path), used to build the product index.
?:kv_agv_index Restricted products (min_age > 0). Used only to hide products in lists.
?:kv_agv_log Checks: order_id (0 = refused attempt), company_id, user_id, required_age, method D/C/R/N, result P/F, age, dob (only when the setting is on), country, reason.
?:kv_agv_customers Signed-in customers: highest age confirmed by date of birth.

The effective age of a product is computed live from the rules for the gate, the checkout and the order card (Rules::productAges()): an exact product rule wins; otherwise the highest of its categories and its vendor default; a raise-only product rule can only increase it.

Hook Use
get_products Hiding: NOT EXISTS on ?:kv_agv_index above the visitor’s confirmed age (storefront only).
update_product_post, clone_product, delete_product_post Product field, index refresh.
update_category_post, update_category_parent_post, delete_category_post, import_post Category field, index rebuild.
delete_company, post_delete_user, delete_order Clean-up.
pre_place_order Safety net: $allow = false on the storefront when a restricted cart has no passed check in the session.
place_order Writes the check record of each order (parent and vendor orders).
dispatch_before_display Assigns the gate configuration of the page.

Controllers: checkout.pre.php (validation on checkout.place_order), checkout.post.php (checkout card), products.post.php / categories.post.php / companies.post.php (page age, storefront), backend products.post.php / categories.post.php / orders.post.php, and the add-on’s own kv_age_verification controller.

Template hooks: storefront index:footer (gate), checkout:final_section_customer_notes (checkout card); admin products:detailed_content, categories:detailed_content, orders:details_sidebar.

  • The gate HTML depends only on the settings and the page (product, category, vendor), never on the visitor, so the same cached page serves every guest. The script js/addons/kv_age_verification/func.js reads the cookie and opens the dialog. Nothing is written to the session or the database by the gate.
  • The cookie kv_agv has the form <age>.<expiry unix time>, SameSite=Lax, Secure on HTTPS. It is a declaration by the visitor and can be edited by them; the checkout check is the control that blocks orders.
  • Hiding adds a block cache key (fn_kv_age_verification_cache_key, callable handler on product blocks and the main content of category, search, vendor and home pages) and the kv_agv_index table as an update handler. With the full_page_cache add-on active, guests never get the cookie bonus.

Log entries and remembered customer ages older than the retention period are deleted automatically, at most once a day, by Log::maybeCleanup() (called from admin requests and order placement; the last run is kept in the core storage data key kv_agv_last_cleanup). You can also run it at once with the admin action kv_age_verification.cleanup (POST) or call \Tygh\Addons\KvAgeVerification\Log::cleanup() from your own cron script.

Config::isOn() = add-on active + Enable + License\Client::isActive(). Gated: gate, hiding, checkout check, new order records. Admin pages, rules, the log and stored records keep working.

app/addons/kv_age_verification/
addon.xml init.php func.php
controllers/backend/{kv_age_verification,products.post,categories.post,orders.post,kv_age_verification_license}.php
controllers/frontend/{checkout.pre,checkout.post,products.post,categories.post,companies.post}.php
schemas/menu/menu.post.php schemas/permissions/{admin,vendor_multivendor}.post.php schemas/block_manager/blocks.post.php
Tygh/Addons/KvAgeVerification/{Age,Config,Rules,Index,Log,Checkout,Gate}.php License/ Upgrade/
design/backend/templates/addons/kv_age_verification/
views/kv_age_verification/{manage,products,vendors,vendor,log}.tpl components/{tabs,age_field,product_rules}.tpl
hooks/{products,categories}/detailed_content.post.tpl hooks/orders/details_sidebar.post.tpl hooks/index/ license/
design/backend/css/addons/kv_age_verification/{admin,license}.less
var/themes_repository/responsive/templates/addons/kv_age_verification/
hooks/index/{footer,styles,scripts}.post.tpl hooks/checkout/final_section_customer_notes.post.tpl components/dob_fields.tpl
var/themes_repository/responsive/css/addons/kv_age_verification/styles.less
js/addons/kv_age_verification/{func,admin}.js
var/langs/en/addons/kv_age_verification.po