Skip to main content
Version: 2.0.0

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:

  1. Fetches widget options from the site-facing API endpoint (optionsUrl).
  2. Opens Packeta.Widget.pick(apiKey, callback, options) with those options.
  3. On pickup-point selection, formats the point and dispatches a set-action-result CustomEvent with { address: <formatted string> }, which the checkout's shipping-option handling consumes.
  4. Listens for a toggle-packetery window 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

RoutePurpose
packetery/dashboardShipment statistics dashboard
packetery/dashboard/save-layoutPersists dashboard widget layout
packetery/settingsPlugin/shipping method settings form
packetery/licenseLicense management panel (activate/redeem/revoke/copy token)
packetery/api/optionsAnonymous 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.