Developer notes
Technical reference for developers who customize US Retail Delivery Fees & All-in Pricing.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_us_fees_allin |
| Function prefix | fn_kv_us_fees_allin_ |
| Language variables | kv_us_fees_allin.* |
| CSS scope | .kv-usf-* |
| PHP namespace | Tygh\Addons\KvUsFeesAllin |
Hooks used
Section titled “Hooks used”PHP: calculate_cart_post (adds the fee lines to $cart['kv_usf_fees'] and to $cart['total']), place_order (stores the lines), change_order_status (strikes or restores fees on cancellation), get_order_info (adds kv_usf_fees to the order), delete_order.
Templates: checkout:checkout_totals (post), checkout:summary (post), orders:order_total (pre), products:prices_block (post), backend orders:totals_content (pre), and the mail hook orders:invoice_shipping (pre). The document variable kvf (label, amount) is added through schemas/documents/order.post.php.
Hooks provided
Section titled “Hooks provided”None.
Database tables
Section titled “Database tables”| Table | Content |
|---|---|
?:kv_usf_rates |
Rate rows: state, label, amount, minimum taxable goods, effective dates, exemptable, strike on cancel, status. |
?:kv_usf_states |
All-in switch and start date per state. |
?:kv_usf_order_fees |
One row per fee line of an order: state, label, amount, taxable base, month, status (C charged, R struck by cancellation), vendor, country (US or the country of a mode; for a country mode state holds the country code). |
?:kv_usf_modes |
Country modes: country (AU, CA, GB), enabled, active_from. |
?:kv_usf_mfees |
Mandatory fee rules of the country modes: country, label, kind (fixed, percent), amount, per (unit, delivery, order), status. |
Storefront endpoint
Section titled “Storefront endpoint”index.php?dispatch=kv_us_fees_allin.estimate&ids=1,2&state=CO&cart=1 returns JSON with the all-in amounts for the listed products and the cart. It is never cached (Cache-Control: no-store); the page markup holds only empty placeholders.
Country modes: index.php?dispatch=kv_us_fees_allin.estimate&ids=1,2&country=AU&cart=1 returns the same JSON plus country, and per product all_in, fee, label, incl and notes. US requests keep the 1.0 shape (no country key). The script remembers the country in the cookie kv_usf_country (30 days).
Engine classes: Engine (US rules), Modes (on(), fees(), compute(), estimateForPrice(), visitorCountry(), check()). calculate_cart_post tries Engine::compute() first and Modes::compute() when it returns nothing, so a US address never reaches a country mode.
Country-mode prices come from Modes::displayedPrice() (core product data plus fn_gather_additional_product_data, so catalog promotions and default options are included). The US estimate still reads the price table row (fn_get_product_price), as in 1.0; that is a known 1.0 limitation and unchanged in 1.1.
Markup hooks for themes: the placeholder .kv-usf-allin[data-kv-usf-id] gets the class kv-usf-allin--mode when it shows a country mode; the original price element it hides is the .ty-price sibling inside .ty-price-update, marked .kv-usf-orig-price. Override the CSS of those classes if your theme prints prices differently.
Template overrides
Section titled “Template overrides”Storefront templates live in design/themes/<theme>/templates/addons/kv_us_fees_allin/. To customize one, copy it to your own theme’s folder; do not edit the add-on’s files, they are replaced on update.
License
Section titled “License”The add-on carries the Kavio Labs license client (Tygh\Addons\KvUsFeesAllin\License\Client). Engine::isActive() is the single gate: without a valid license no fee line or all-in label is added; stored order fee records, the report and the admin pages keep working. Files: License/Client.php, License/Ed25519.php, controllers/backend/kv_us_fees_allin_license.php, design/backend/templates/addons/kv_us_fees_allin/license/.