Developer notes
Add-on identity
Section titled “Add-on identity”- Add-on id
kv_myparcel, namespaceTygh\Addons\KvMyparcel, folderapp/addons/kv_myparcel. - PHP 7.4 syntax floor, runs on PHP 7.2.5 to 8.3 depending on the CS-Cart version. Smarty 4 and 5.
- Editions: CS-Cart, CS-Cart Ultimate, Multi-Vendor, Multi-Vendor Ultimate (gated with
fn_allowed_for).
Structure
Section titled “Structure”app/addons/kv_myparcel/ addon.xml, init.php, func.php controllers/backend/kv_myparcel.php shipments list, connection, vendors, log, jobs, label actions controllers/backend/orders.post.php data of the MyParcel tab on the order page controllers/frontend/kv_myparcel.php webhook, cron (secret key), checkout AJAX (options, choose) schemas/permissions (admin + vendor_multivendor), schemas/menu, schemas/settings Tygh/Shippings/Services/KvMyparcel.php shipping service (flat rate) Tygh/Addons/KvMyparcel/ Client/BaseClient.php, Client/Api.php the only code that talks HTTP / knows MyParcel endpoints Carriers, Mapper pure: carrier ids, package types, address / shipment / status mapping Shipments idempotent create, label, sync, core shipment, cancel, webhook matching Choices MyParcel shipping methods and the customer's checkout choice Accounts, Contracts, Access, Config connection (sealed key), vendor contract modes, privileges, settings Queue, Jobs, Log, Idempotency, Secret job queue with retries, locks, masked log, AES-256-GCM MultiParcel/Adapter.php carrier adapter for Multi-Parcel Packing License/, Upgrade/ licence client and self-healing upgradesdesign/backend/templates/addons/kv_myparcel/ order tab, pages, shipping method settings, licence cardvar/themes_repository/responsive/... checkout picker, order page lines, stylesjs/addons/kv_myparcel/func.js checkout picker (AJAX)Official API reference (every endpoint, header, field and status used)
Section titled “Official API reference (every endpoint, header, field and status used)”Source: https://developer.myparcel.nl/ (read 2026-11-11). Section numbers are those of the API reference pages.
| What | Reference | Used for |
|---|---|---|
Base URL https://api.myparcel.nl |
01.requests 1.A | MyParcel NL accounts (platform myparcel) |
https://api.sendmyparcel.be |
06.shipments 6.B.4 (“Create bpost shipment with BE pickup location”) | SendMyParcel BE accounts (platform belgie) |
Authorization: bearer BASE64_ENCODED_API_KEY |
05.authentication, 02.responses 401 | every call |
User-Agent: MyParcel-<integration>/<version> <cms>/<version> <backend>/<version> |
01.requests 1.B | we send MyParcel-KvMyparcel/1.0.0 CsCart/<version> PHP/<version> |
| Rate limits (429, sliding window; shipments 500 / 5 min, tracktraces 300 / 5 min) | 01.requests 1.D | 429 is retried after Retry-After or 5 minutes; the schedule refreshes at most 60 shipments per run |
GET /webhook_subscriptions |
10.B | “Test connection” (authenticated, no side effects) |
POST /webhook_subscriptions body {"data":{"webhook_subscriptions":[{"hook":"shipment_status_change","url":...}]}} -> {"data":{"ids":[{"id":n}]}} |
10.A, 11.A | webhook subscription; https and lower-case URL |
DELETE /webhook_subscriptions/{id} |
10.C | not used by the add-on (a repeated POST replaces the subscription, 10.A) |
Webhook call: body {"data":{"hooks":[{shipment_id, account_id, shop_id, status, barcode, shipment_reference_identifier, order_id}]}}, headers X-MyParcel-Hook, X-MyParcel-HookId, X-MyParcel-Authorization: <Base64 of your API key> |
11.B | webhook endpoint; the authorization header identifies the account |
POST /shipments, Content-Type: application/vnd.shipment+json;charset=utf-8;version=1.1, body {"data":{"shipments":[Shipment]}} -> {"data":{"ids":[{"id","reference_identifier"}]}} |
06.shipments 6.B.2, 6.B.4 | create a shipment (concept) |
Shipment fields reference_identifier, recipient, options, carrier, pickup, physical_properties.weight (grams), secondary_shipments |
7.A, 7.B, 7.C, 7.N, 7.O | see Mapper |
Address fields cc, postal_code, city, street, number, number_suffix, box_number (BE), person (40 chars), company, email, phone, street_additional_info |
7.B | recipient |
Options package_type, only_recipient, signature, age_check, delivery_type, delivery_date, label_description |
7.C, 6.A.3 | label options |
| Package types: 1 package, 2 mailbox package (PostNL NL, DPD NL, bpost BE) | 04.data-types, 6.A.1, 6.B.4 examples | method setting / order form |
Delivery types: 1 morning, 2 standard, 3 evening, 4 pickup; pickup needs signature, morning / evening need only_recipient |
6.A.2, 6.A.4 | checkout choice -> label |
| Carrier ids: 1 PostNL, 2 bpost (only sendmyparcel.be), 4 DPD, 9 DHL For You | 04.data-types | carriers |
GET /shipments?reference_identifier= |
6.E.2, 6.E.3 | idempotent retry: look the reference up before creating |
GET /shipments/{id} (fields id, status, barcode, secondary_shipments, carrier_id) |
6.E | barcode and status |
GET /shipment_labels/{id}?format= Accept: application/pdf (A4 / A6, paper_size a4 / a6); 402 = payment required; one request returns all labels of a multi collo shipment |
6.F | label PDF; creating the label registers the shipment |
DELETE /shipments/{id} (only status 1, concept; 204) |
6.C | “Delete shipment” for a concept |
GET /tracktraces/{id[;id]} (status.current, description, link_tracktrace, link_consumer_portal) |
6.G, 7.L | tracking link and text |
| Shipment status 1-19 (30-38 inactive) | 04.data-types shipment_status | status mapping in Mapper::statusClass() |
GET /delivery_options (cc, postal_code, number, carrier, platform, cutoff_time, dropoff_days, dropoff_delay, deliverydays_window), Accept: application/json;charset=utf-8;version=2.0; answer data.delivery[{date, time[{start,end,price{amount,currency},type or name}]}] |
08.delivery-options 8.A, 9.A | checkout dates and times |
GET /pickup_locations (same query); answer data.pickup[{location, street, number, postal_code, city, distance, opening_hours, location_code, time[]}] |
8.A.2, 9.B | NL PostNL pickup points |
Multi collo: secondary_shipments: [{}, {}] on POST |
6.H.2, 6.B.4 | N parcels = main shipment + N-1 secondary shipments |
Error object {"errors":[{"code","message","human"}]}, codes 3xxx |
8.A.2, 15.user-exceptions | messages shown to the merchant (3505 postal code, 3510 name length, 3705 options, 3723 delete, 3733 package type, 3735 / 3739 multi collo …) |
Flagged: not stated (or inconsistent) in the reference, handled defensively
Section titled “Flagged: not stated (or inconsistent) in the reference, handled defensively”- Rate quote. The reference has no price quote endpoint: shipping cost is the merchant’s flat rate per method; delivery option prices (euro) can be added.
- Webhook signature. None is documented. The only credential is
X-MyParcel-Authorization(base64 of the API key): it is compared in constant time with the stored keys and selects the account. The payload is only a notification: the shipment is read again with the account’s own key. Do not expose the webhook URL as a trust boundary beyond that. - Multi collo answer. The reference does not show
GET /shipments/{id}of a multi collo shipment. We readsecondary_shipments[].barcode(the field is documented as “an array of shipment”). Fixturetests/fixtures/shipment_get_multicollo.jsonis an assumed shape; if MyParcel returns the barcodes differently, the main number is still stored and the other parcels show on the next refresh. - Filtered shipment list. The answer shape of
?reference_identifier=is not shown (only theqsearch:data.search_results.shipments); bothdata.shipmentsanddata.search_results.shipmentsare read. - Repeated reference_identifier. Whether a second POST with the same reference creates a second shipment is not documented: the add-on never relies on it (own row before the POST, lookup before every create).
- Label
formatcase. The data type listsa4/a6, an example usesA4; the add-on sends lower case. - Delivery options
carriervalues.postnlandbpostappear in the examples;dpdanddhlforyouonly in the checkout module’s configuration. Date / pickup choices are offered for PostNL and bpost only.ccis sent lower case as in the examples. - Delivery option type field. The object definition says
type, the examples sayname: both are read. - BE pickup points. A Belgian pickup shipment needs
retail_network_id(7.O example); the pickup answer fields do not list it: Belgian pickup is not offered. - Belgium base URL. 6.B.4 shows both
api.myparcel.nl(bpost example) andapi.sendmyparcel.be(BE pickup example). The add-on usesapi.sendmyparcel.befor the SendMyParcel platform. - No sandbox. The reference describes no test environment; the add-on has one mode (live) and is tested against a local mock of the documented API.
- Limits we chose. Up to 10 parcels per multi collo shipment (the reference only names error 3739),
label_descriptioncut at 45 characters, EU destinations and NL / BE only (customs declarations, 7.E, are not built). - Tracking URL. There is no documented URL pattern; the link of the track & trace object is stored (
link_tracktrace, elselink_consumer_portal).
Database tables
Section titled “Database tables”kv_myparcel_accounts (company 0 = owner, key sealed), kv_myparcel_shipments (one row per MyParcel shipment; request key unique; remote id, barcode, extra barcodes, label PDF, status, core shipment id), kv_myparcel_choices (customer choice per order), kv_myparcel_vendors (contract mode per vendor), kv_myparcel_jobs, kv_myparcel_log.
Idempotency (a retry looks up before it creates)
Section titled “Idempotency (a retry looks up before it creates)”- Per order a database lock (
GET_LOCK) serialises create / retry / double click. - The row with its reference (
kv-myp-<order>-<attempt>, unique) is stored in stateQBEFORE the POST. - A retry first calls
GET /shipments?reference_identifier=and adopts what exists; only when nothing exists is the POST sent. - The MyParcel id is stored the moment the POST answers; the label (which registers the shipment and creates the barcode) is a separate, repeatable step: 402 payment required keeps the shipment and only repeats the label after payment.
- A 4xx validation answer before the shipment exists deletes the empty row, so the merchant can correct the address.
- The schedule resumes rows that were interrupted (
Shipments::unfinished()). - Status updates (webhook, cron, button) are serialised per shipment and a final status (delivered, cancelled) is never downgraded.
Hooks used
Section titled “Hooks used”change_order_status_post (label at an order status), get_order_info, place_order, place_suborders, delete_order, template_document_order_context_init, kv_multi_parcel_adapters (signatures identical in 4.17.2 and 4.21.2). Template hooks: checkout:shipping_method, orders:totals_shipping, index:scripts, index:styles, orders:tabs_extra (admin), addons:* (licence).
Full page cache (4.21)
Section titled “Full page cache (4.21)”Nothing per visitor is printed into a cacheable page. The checkout picker is an empty container filled by an AJAX call (kv_myparcel.options, kv_myparcel.choose, never cached); the choice lives in the session cart. kv qa fpc checks the storefront pages.
Multi-Parcel Packing adapter
Section titled “Multi-Parcel Packing adapter”fn_kv_myparcel_kv_multi_parcel_adapters() registers Tygh\Addons\KvMyparcel\MultiParcel\Adapter (code myparcel): N parcels become one multi collo shipment with N tracking numbers; the reference identifier of the order is the request_key idempotency key; a retry adopts the shipment. Packing keeps its own core shipment and e-mail (this path passes no_core). Cancelling works only for concepts (6.C).
php81 tests/unit.phpandphp83 tests/unit.php: pure logic, mapping, HTTP client against a mock transport (fixtures from the reference intests/fixtures).node tests/mock-server/server.js <port>: local mock of the documented API;tests/php/store_test.phpandtests/e2e/e2e.mjsrun on a dev store pointed at it ($config['kv_myparcel_base_url']). They refuse to run otherwise: a test never reaches the real API.tests/qa-gate.mjsforkv qa lic.
License
Section titled “License”The add-on checks its license once a day (domain name only) and gates new work with fn_kv_myparcel_is_active(). Work already under way (queue, webhooks, tracking) never depends on it.
Delivery options answer shapes (8.A.4)
Section titled “Delivery options answer shapes (8.A.4)”The reference documents two answers for GET /delivery_options with Accept: ...;version=2.0: data.delivery[] {date, time[]} (9.A) and, for a request with cutoff_time / dropoff_days / deliverydays_window, data.deliveries[] {date{date}, possibilities[{name, delivery_time_frames}]}. Api::deliveryOptions() reads both (the second through Api::fromDeliveries(), price 0 because that answer carries none); an answer with neither key is logged as a warning. The mock answers deliveries for PostNL and delivery for bpost.