Skip to content

Developer notes

Technical reference for developers who customize Mandatory Product Warnings.

Item Value
Add-on id kv_product_warnings
Function prefix fn_kv_product_warnings_
Language variables kv_product_warnings.*
CSS scope .kv-pwn (storefront), .kv-pwn-admin (admin)
PHP namespace Tygh\Addons\KvProductWarnings
Table Content
?:kv_pwn_warnings One row per warning: owner (company_id, 0 = marketplace), code (unique per owner), type, style, signal word, pictogram, status (A live, D disabled, P waiting for approval), the display flags, ack_mode (N, C), the ship-to rule (geo_mode A/I/E, geo_list), source name and link, verbatim, default token values (JSON), draft (JSON of a vendor edit that waits for approval).
?:kv_pwn_texts Title, text and short text per language.
?:kv_pwn_links Targets: P product, C category (with subcategories), A all products of the warning’s owner; token values per link (JSON).
?:kv_pwn_log Order record: order, warning, the exact filled wording, method (C confirmed, D shown), destination, products, the flags for e-mail and invoice. Unique per order, warning and wording.

The tables are kept on uninstall unless the setting Permanently delete all warnings and order records on uninstall is on (Retention class).

PHP: get_product_data_post (storefront: $product['kv_pwn']), update_product_post (product tab), delete_product_post, clone_product, delete_category_post, delete_company, pre_place_order (refuses the order without the stored confirmation), place_order (order record), delete_order.

Templates (storefront): products:promo_text post (product page), products:quick_view_title post (quick view) and products:product_detail_bottom post (position “below the buy box”), checkout:product_options post (cart and checkout lines), checkout:final_section_customer_notes pre (confirmation boxes), orders:info post, index:scripts post, index:footer post (cart and checkout only). Admin: products:tabs_content post, orders:details_sidebar post.

Controllers: frontend checkout.pre (POST place_order: reads kv_pwn_ack[<warning id>]), checkout.post, orders.post; backend kv_product_warnings, products.post, orders.post.

None.

Tygh\Addons\KvProductWarnings\Resolver::forProducts(array $product_ids, $lang, &$issues = null) returns product_id => [item, ...]. Each item has id, code, type, style, signal, pictogram, title, text (plain, filled), html (escaped, links), short, short_html, ack, the display flags, geo_mode, geo_list, geo_label, source_name, source_url. A warning whose text still has a required token without a value is not returned; $issues[warning_id][product_id] lists the missing token names. Checkout::context($cart, $lang) adds the ship-to filter, Checkout::required($context) lists the warnings that need the checkbox.

The document variable kv_pwn (schemas/documents/order.post.php) is used by two snippets, order_invoice and order_summary, both named kv_product_warnings and inserted after {{ snippet("products_table") }} on install. In Twig: kv_pwn.show_invoice, kv_pwn.rows_invoice, kv_pwn.show_email, kv_pwn.rows_email, kv_pwn.title; each row has signal, title, text (HTML, already escaped) and products. Templates are valid in Twig 2.14 and 3.11.

The product page output does not depend on the visitor: geo-limited cards carry data-kv-pwn-geo-mode and data-kv-pwn-geo. js/addons/kv_product_warnings/func.js reads the cookie kv_pwn_geo (written from the data-kv-pwn-dest element that the cart and checkout pages print in the footer) and hides the cards outside the rule. No session or ?:storage_data write happens on a cached dispatch. The main block of products.view gets the cache key kv_pwn and the tables kv_pwn_*, products_categories, categories as update handlers (schemas/block_manager/blocks.post.php).

schemas/exim/products.post.php adds the column Product warnings; the functions are in schemas/exim/products.functions.php.

Storefront templates live in design/themes/<theme>/templates/addons/kv_product_warnings/ (components/card.tpl is the card). To customize one, copy it to your own theme’s folder; do not edit the add-on’s files, they are replaced on update.

The add-on ships the Kavio Labs licence client (License\Client, Ed25519), the controller kv_product_warnings_license, the admin templates license/*.tpl and the Upgrade Synchronizer (Upgrade\Synchronizer). The client contacts only cs-cart.kaviolabs.com, only from the admin panel or cron, and sends only the licence key, the add-on id and version, the storefront hosts, the CS-Cart version and edition and a nonce.

app/addons/kv_product_warnings/
addon.xml init.php func.php resources/snippet_templates.xml
Tygh/Addons/KvProductWarnings/ Config Geo Text Presets Warnings Links Resolver Checkout View Log Csv Checklist Retention
Documents/{WarningsVariable,TemplatePatcher} License/ Upgrade/
controllers/{backend,frontend}/ schemas/{menu,permissions,block_manager,documents,exim}/
design/backend/templates/addons/kv_product_warnings/ views/kv_product_warnings/{manage,library,update,log,checklist,import}.tpl hooks/ license/
var/themes_repository/responsive/templates/addons/kv_product_warnings/ components/card.tpl hooks/{products,checkout,orders,index}/
js/addons/kv_product_warnings/{func,admin}.js