Developer notes
app/addons/kv_listings_pro/├── addon.xml scheme 3.0, priority 1000, both editions├── init.php hook registration├── func.php hook handlers and settings handlers├── controllers/backend/kv_lpro_listings.php listings page (vendor panel and admin panel)├── controllers/backend/kv_lpro_config.php owner configuration (durations, packages, payments, tools)├── controllers/backend/kv_lpro_cron.php cron entry (CLI dispatch)├── controllers/backend/kv_listings_pro_license.php "Check now" / cron license check├── controllers/backend/{index,products}.post.php expiry reminder├── controllers/frontend/kv_lpro.php pay link (puts the service product in the cart)├── controllers/frontend/products.pre.php service products have no page├── schemas/menu/{menu,menu_vendor}.post.php Products > Listings├── schemas/permissions/{admin,vendor_multivendor}.post.php├── schemas/block_manager/{blocks,block_cache_properties}.post.php└── Tygh/Addons/KvListingsPro/ ├── Config.php Listings.php Quota.php Packages.php Requests.php Sellers.php Actions.php ├── License/Client.php License/Ed25519.php Upgrade/Synchronizer.phpdesign/backend/templates/addons/kv_listings_pro/ views, components/actions.tpl, hooks/companies/general_information.post.tpl, license/*design/backend/css/addons/kv_listings_pro/ styles.less, license.lessvar/themes_repository/responsive/templates/addons/kv_listings_pro/ components/chips.tpl and the hooks belowvar/themes_repository/responsive/css/addons/kv_listings_pro/styles.lessvar/langs/en/addons/kv_listings_pro.poDatabase
Section titled “Database”| Table | Purpose |
|---|---|
kv_lpro_listings |
One row per tracked product: product_id (PK), company_id, state (A active, E expired), created_at, expires_at (0 = never), archived_at, prev_status (A or H, restored on renew), renewed_at, renew_count, bumped_at, bump_count, featured_until, urgent_until. |
kv_lpro_rules |
Duration rules: kind (C category, P vendor plan), object_id, days; unique per kind and object. |
kv_lpro_packages |
Upgrade packages: type, name, days, price, product_id (service product), status. |
kv_lpro_requests |
Upgrade requests: listing, package, token, state (P pending, A applied, X cancelled, F paid but not applicable), order_id. |
kv_lpro_usage |
Every applied upgrade with its source (quota, paid, admin): the free quota is the count of quota rows in the current period. |
kv_lpro_sellers |
Declared seller type per company (P private, T trader). |
The payment flow
Section titled “The payment flow”- The seller chooses a package:
Actions::perform($product_id, $type, 'package', $package_id)checks the licence, the listing’s owner, the state and the package, and creates (or reuses within an hour) a pending request with a random token. - The browser is sent to the storefront
kv_lpro.pay&token=.... The controller puts the package’s service product into the cart withextra.kv_lpro_request_id. pre_add_to_cartrefuses a service product without a payable request and forces the quantity to 1.generate_cart_idmakes every request its own cart line.get_cart_product_dataandget_order_infoname the line “package: listing”.change_order_statusinto a status offn_get_settled_order_statuses()callsRequests::fulfilOrder(). A line counts only when it is the request’s service product (stored on the request), the product is owned by the package owner (company 0 in Multi-Vendor) and the line was paid at least the request price after discounts (Requests::checkLine()).Requests::fulfil()then claims the request withUPDATE ... WHERE state = 'P'and applies the upgrade only when exactly one row changed. A claim that fails for a different order is flaggedtwice#<order>on the request.pre_add_to_cartremoveskv_lpro_request_idfrom every line that is not a service product, andpre_place_orderdrops service lines whose request is no longer payable.
The service product is hidden, download-type (no shipping), quantity 1, lives in a hidden category and belongs to company 0 in Multi-Vendor (the marketplace owner).
PHP hooks used
Section titled “PHP hooks used”| Hook | Handler | Purpose |
|---|---|---|
update_product_post |
fn_kv_listings_pro_update_product_post |
Give a new product its term; refuse switching an archived listing on for a seller |
tools_update_status_before_query |
..._tools_update_status_before_query |
Same for the status switch in the list |
delete_product_post, delete_company |
Clean up | |
products_sorting, get_products |
“Featured first” sort and the bump order (storefront only) | |
gather_additional_products_data_post, get_product_data_post |
$product.kv_lpro (featured, urgent, seller_type, seller_label) for lists and the page |
|
get_company_data_post, update_company |
Seller type on the vendor page; saving the declaration | |
change_order_status |
Apply paid upgrades | |
pre_add_to_cart, generate_cart_id, get_cart_product_data, get_order_info |
Service product handling | |
init_templater_post |
static | Upgrade synchronizer (only while an upgrade is pending) |
Template hooks used
Section titled “Template hooks used”Storefront: products:list_price_block (pre; cards of grid, list and compact), products:main_info_title (post; listing page), companies:top_links (post; vendor page), index:styles. Admin: companies:general_information (post; seller type field), index:styles, the license hooks.
Templates read $product.kv_lpro and $company_data.kv_lpro_seller_label; they never call add-on functions.
Functions and classes
Section titled “Functions and classes”| Call | Purpose |
|---|---|
Listings::durationDays($product_id, $company_id) |
Term of a new listing |
Listings::apply($product_id, $type, $days, $source) |
Apply renew / bump / featured / urgent (single UPDATE ... WHERE state statements) |
Listings::expireDue() / archive() |
Archive due listings |
Quota::left($company_id, $type) |
Free uses left this period (-1 = unlimited) |
Actions::perform(...) |
Every seller action with all checks |
Requests::fulfil($request_id, $order_id) |
Claim and apply a paid request once |
Packages::save() / delete() |
Packages and their service products |
Caching
Section titled “Caching”All storefront output comes from kv_lpro_listings and kv_lpro_sellers and is the same for every visitor, so the full page cache can store it. Product and vendor blocks use both tables as update handlers; the block cache key also contains the license state, the display settings and a five minute bucket (a Featured or Urgent term ends by time, not by a database write). The pay link is a dispatch the full page cache never stores.
License check
Section titled “License check”Tygh\Addons\KvListingsPro\License\Client verifies the license against the Kavio Labs license server (signed answers only). It runs in the admin panel and from cron, never on a storefront request. Config::isOn() is the gate: enabled in the settings and licensed. See Configuration.
License/Ed25519.php is derived from paragonie/sodium_compat, ISC License, Copyright (c) 2016-2023 Paragon Initiative Enterprises and Copyright (c) 2013-2019 Frank Denis. The full license notice is in the file header.
Upgrade synchronizer
Section titled “Upgrade synchronizer”Upgrade\Synchronizer repairs an in-place upgrade (files replaced without the installer): missing tables and columns, settings, language variables, the add-on version. It runs on the first root-admin request after the files change.
Customizing
Section titled “Customizing”- Chips: override
addons/kv_listings_pro/components/chips.tplin your theme. - Listing flags for your own templates:
$product.kv_lpro.featured,.urgent,.seller_label. - A different payment model (for example a vendor balance) can replace step 2 and 4 of the payment flow; the lifecycle (
Listings::apply()) does not depend on it.