Skip to content

Developer notes

Technical reference for developers who customize COD Control.

Item Value
Add-on id kv_cod_control
Function prefix fn_kv_cod_control_
Language variables kv_cod_control.*
CSS scope .kv-cod-*
PHP namespace Tygh\Addons\KvCodControl
Depends on kv_payment_fee_rules

prepare_checkout_payment_methods_before_get_payments and ..._after_get_payments (hide COD; the decision is part of the fn_get_payments() parameters so the core’s static cache cannot leak it between carts), checkout_select_default_payment_method, allow_place_order_post (server check, storefront only), place_order (COD record), get_order_info (adds $order_info.kv_cod), change_order_status (outcomes, WhatsApp answers), delete_order, delete_company.

Template hooks: checkout:payments (notice), checkout:order_confirmation and orders:info (storefront card), orders:customer_info (admin order panel).

The COD fee is not computed here. Fees::createRule() calls Tygh\Addons\KvPaymentFeeRules\Rules::save() with the COD methods as payment_ids; Fees::quote() calls Engine::quote(). No table of that add-on is read or written directly. What counts as a COD method is Methods::payment($id)['kind'] === 'cod' of the same add-on.

Confirm::driver() returns a Drivers\DriverInterface implementation: PhoneOtpLoginDriver (uses Config::providers() of Phone OTP Login: WhatsApp Cloud API template, Twilio, generic HTTP, with that add-on’s fallback order), SmsNotificationsDriver (uses Service::outbox()->sendNow()), or the development route TestDriver that is active only while define('KV_COD_CONTROL_TEST_OTP', true); is in config.local.php (the code is returned to the page, nothing is sent; never use it in production).

$order_info.kv_cod (Smarty) / order_info.kv_cod (Twig): confirm_state (N none, P pending, C confirmed, F declined, E expired), confirm_text, outcome (O open, D delivered, R refused, T returned, X cancelled), outcome_text, channel, fee, total, lost_cost, reason, confirmed_at, deadline, flags, confirm_url (signed customer link).

Table Content
?:kv_cod_rules Availability rules (effect, conditions, vendor / storefront company).
?:kv_cod_people Hashed buyer keys with refusals, deliveries, status (neutral / blocked / trusted) and scope.
?:kv_cod_orders One row per COD order, including Multi-Vendor sub-orders: confirmation, outcome, fee, code hash and counters.
?:kv_cod_log Events of an order, and “COD hidden” events (order 0).

index.php?dispatch=kv_cod_confirm.cron&key=<cron key> answers JSON ({"ok":true,"on":true,"cancelled":n}), 403 with a wrong key; or php admin.php --dispatch=kv_cod.cron from the console.

The add-on prints nothing on cacheable dispatches. The notice is on checkout.*, the card on the thank-you and order pages, and the confirmation page kv_cod_confirm.view is private, no-store and noindex. Customer links carry an HMAC of the order id; every POST of that page needs it again.

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

Without a valid license the checks, new COD records, new confirmation codes and the automation are off; existing data and settings are kept, and a confirmation that already started can be completed.