Developer / API
Checkout integration
Packetery hooks into the storefront through the shared remote-checkout-scripts view hook
(Plugin::init()), rendering src/templates/shipping-code.twig only when the method passes
Plugin::checkRestrictions() (enabled + within the visibility window). The template loads
https://widget.packeta.com/v6/www/js/library.js and defines initPacketaShipping(), an Alpine
component that:
- Fetches widget options from the site-facing API endpoint (
optionsUrl). - Opens
Packeta.Widget.pick(apiKey, callback, options)with those options. - On pickup-point selection, formats the point and dispatches a
set-action-resultCustomEventwith{ address: <formatted string> }, which the checkout's shipping-option handling consumes. - Listens for a
toggle-packeterywindow event to reset the previously shown selection and re-fetch options.
Site-facing endpoint
packetery/api/options (anonymous, GET) returns the widget configuration derived from the
plugin's settings — this is what optionsUrl in the checkout script points to:
GET /index.php?p=packetery/api/options
{
"webUrl": "https://store.example.com",
"appIdentity": "YSCP-v2",
"country": "sk,cz",
"language": "en",
"valueFormat": "id,carrierId,carrierPickupPointId,name,city,street",
"defaultPrice": 3.5,
"defaultFreeShippingThreshold": 50,
"defaultCurrency": "EUR",
"countryPrices": { "sk": 2.5 },
"countryFreeShippingThresholds": { "sk": 40 },
"weight": 5,
"claimAssistant": "true",
"packetConsignment": "true"
}
weight, claimAssistant, and packetConsignment are only included when the corresponding
settings (Drop-off only of parcels weighing to, Complaint points only, Drop-off points
only) are configured/enabled. Country pricing keys are only populated when Enable
country-specific prices is on.
Shipping method registration
Like every yStore carrier plugin, Plugin implements ShippingMethodRegistryInterface and
registers itself on Plugins::EVENT_AFTER_LOAD_PLUGINS. Plugin::shippingDetails() is the method
metadata consumed by the shipping-methods module (price, restrictions, checkout action config
including the initPacketaShipping() trigger); checkRestrictions() is the single source of truth
for whether the method is currently offered (enabled flag + visibility window).
CP routes worth knowing about
| Route | Purpose |
|---|---|
packetery/dashboard | Shipment statistics dashboard |
packetery/dashboard/save-layout | Persists dashboard widget layout |
packetery/settings | Plugin/shipping method settings form |
packetery/license | License management panel (activate/redeem/revoke/copy token) |
packetery/api/options | Anonymous site-facing endpoint used by the checkout widget |
All routes above except packetery/api/options require a CP request; packetery/api/options is
the only one reachable from the storefront.