Developer notes
Technical reference of Local Delivery Zones, Minimums & Fees: data, hooks, REST API and the full page cache. Back to the overview.
The add-on never changes core files. Add-on ID: kv_local_delivery_zones.
| Table | Content |
|---|---|
?:kv_ldz_zones |
Zones: company_id (0 = marketplace / all storefronts), status, position, name, note, country, postcode rules, radius + centre, fee type / fee / per-unit price / tiers (JSON), free-over, minimum order, weekday mask (Mon..Sun), cut-off, preparation days, closed dates. |
?:kv_ldz_postcodes |
Imported postcode coordinates (country, normalised postcode, lat, lng, place). |
?:kv_ldz_geo |
Nominatim answers cache and the per-visitor hourly lookup counters. |
?:kv_ldz_orders |
Per order and seller: zone id + name, postcode, distance, fee, delivery date. |
The carrier is a CS-Cart realtime shipping service: module kv_local_delivery_zones, code kv_ldz_local, class Tygh\Shippings\Services\KvLocalDeliveryZones. A method has the service parameters configured and zone_ids.
Hooks used
Section titled “Hooks used”shippings_get_shippings_list_post (methods hidden without a valid license), calculate_cart_post (checkout note per product group in $cart['kv_ldz_notes']), pre_place_order (server-side guard), place_order (order rows), get_order_info ($order['kv_ldz']), delete_order, delete_company.
Template hooks: storefront checkout:shipping_methods_list (post), orders:totals_shipping (post), products:product_detail_bottom (post); admin orders:shipping_info (post). Block type kv_local_delivery_zones (“Delivery checker”).
PHP API
Section titled “PHP API”use Tygh\Addons\KvLocalDeliveryZones\Matcher;
$r = Matcher::match(['country' => 'US', 'zipcode' => '10001'], 42.50, $company_id);// $r: deliverable (bool), reason ('' | no_zone | min_order | no_day | no_postcode), zone (array),// fee, shortfall, date (Y-m-d of the next delivery day), distance (null when not needed / unknown), unitDelivery date add-ons can read the allowed weekdays of the zone (Schedule::weekdays($r['zone']['days'])) and the closed dates (Schedule::parseClosed()).
REST API
Section titled “REST API”Entity kv_delivery_zones (administrator API keys; Multi-Vendor vendor administrators reach their own zones).
| Request | Result |
|---|---|
GET /api/kv_delivery_zones |
zones (status, q, company_id filters) |
GET /api/kv_delivery_zones/:id |
one zone |
GET /api/kv_delivery_zones?check=Y&country=US&postcode=10001&subtotal=40 |
zone, fee, shortfall, delivery date for an address |
POST /api/kv_delivery_zones |
create (fields as returned by GET; tiers as "0:6.90; 40:3.90", days as "1111100") |
PUT /api/kv_delivery_zones/:id |
update the sent fields |
DELETE /api/kv_delivery_zones/:id |
delete |
curl -u admin@example.com:APIKEY -H "Content-Type: application/json" \ "https://shop.example.com/api/kv_delivery_zones?check=Y&country=US&postcode=10001&subtotal=40"Storefront checker and caching
Section titled “Storefront checker and caching”The checker block and the product page box print the same static form for every visitor. The answer comes from index.php?dispatch=kv_ldz.check&postcode=..&country=..&product_id=.. (JSON, Cache-Control: no-store, no session writes), and the last postcode is kept in the cookie kv_ldz_pc, read only by the script. The checker is designed to be compatible with the block cache and the CS-Cart 4.21 full page cache. The checkout is never page-cached.
Geocoding
Section titled “Geocoding”Geocoder::postcode() reads ?:kv_ldz_postcodes first and then Nominatim’s structured search (postalcode + countrycodes). Requests to the public service are serialised to one per 1.1 s with a file lock in var/kv_local_delivery_zones/, carry the User-Agent KavioLocalDeliveryZones/<version> (+<store URL>) and a Referer, and are cached. Visitor limits use the add-on’s client IP helper, not fn_get_ip().
Licence gate
Section titled “Licence gate”Without a valid license: no local delivery rates (methods removed from the storefront list), no checker, no checkout notes, no new order rows. Admin pages, zones and stored data stay.
Next: FAQ.