Developer notes
Technical reference for developers who customize Deposit Return Fees.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_deposit_return |
| Function prefix | fn_kv_deposit_return_ |
| Language variables | kv_deposit_return.* |
| CSS scope | .kv-deposit-return |
| PHP namespace | Tygh\Addons\KvDepositReturn |
Hooks used
Section titled “Hooks used”PHP hooks (registered in init.php): calculate_cart_post (adds the lines to the cart total), place_order (stores the lines), change_order_status (reverses and restores them), get_order_info (adds kv_dep_lines, kv_dep_groups, kv_dep to the order), delete_order, get_products_post (loads assignments of a product list at once), update_product_post, delete_product_post, clone_product_post, delete_company.
Template hooks: storefront products:prices_block, checkout:checkout_totals, checkout:summary, checkout:product_info, orders:order_total; admin products:tabs_content (Deposit tab, registered in controllers/backend/products.post.php), orders:shipping_info (order panel), orders:totals_content, index:styles, addons:manage, addons:tabs_content.
Order documents: the schema schemas/documents/order.post.php adds the variable kvdep (label, amount); the Twig row is inserted between the markers {# kv-dep:begin #} and {# kv-dep:end #}.
REST API (/api/..., JSON):
| Endpoint | Description |
|---|---|
GET /kv_deposit_types, GET /kv_deposit_types/:id |
Container types with rates[] (shared and own). |
POST /kv_deposit_types, PUT /kv_deposit_types/:id |
{"name", "code", "status", "rates": [{"country", "destination_id", "amount", "tax_mode" N/A/I, "tax_rate", "label"}]}; rates replaces the rates (keep one with its rate_id). |
DELETE /kv_deposit_types/:id |
Deletes the type and the product assignments that used it. |
GET /kv_deposit_products/:product_id, PUT |
{"type_id", "units", "variants": {"<variant_id>": {"type_id", "units"}}}; type_id 0 removes the deposit. |
GET /kv_deposits?time_from&time_to&group&country&type_id&orders |
Settlement summary; detail=Y&after=<line_id> lists lines (500 per call). |
GET /kv_deposits/:order_id, PUT |
Lines, returns and summary of an order; {"containers": {"<line_id>": 2}, "note"} records returned containers. |
GET /orders/:id |
The core order response carries kv_dep_lines, kv_dep_groups and kv_dep. |
A vendor administrator reaches only its own orders and types.
Hooks provided
Section titled “Hooks provided”The add-on provides no hooks of its own. Read the deposit of a cart from $cart['kv_dep_lines'] (keyed by cart item id), $cart['kv_dep_total'] and $cart['kv_dep_groups'] after fn_calculate_cart_content().
Database tables
Section titled “Database tables”kv_dep_types, kv_dep_rates (country, zone, amount, VAT mode, rate, label), kv_dep_products (product type and containers per unit), kv_dep_variants (option variant overrides), kv_dep_lines (deposit lines per order), kv_dep_returns (returned containers), kv_dep_company (per vendor / storefront settings). All InnoDB; amounts are in the primary currency. All are dropped on uninstall.
Template overrides
Section titled “Template overrides”Storefront templates live in design/themes/<theme>/templates/addons/kv_deposit_return/. To customize one, copy it to your own theme’s folder; do not edit the add-on’s files, they are replaced on update.