Developer notes
Technical reference for developers who customize Skroutz Smart Cart Orders.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_skroutz_smart_cart |
| Function prefix | fn_kv_skroutz_smart_cart_ |
| Language variables | kv_skroutz_smart_cart.* |
| CSS scope | .kv-skroutz-smart-cart |
| PHP namespace | Tygh\Addons\KvSkroutzSmartCart |
Official sources (every endpoint, field, state and error below is from these pages)
Section titled “Official sources (every endpoint, field, state and error below is from these pages)”- Overview and flow: https://developer.skroutz.gr/smart_cart/
- Orders API: https://developer.skroutz.gr/smart_cart/orders_api
- Orders webhook: https://developer.skroutz.gr/smart_cart/orders_webhook
Orders API (base https://api.skroutz.gr)
Section titled “Orders API (base https://api.skroutz.gr)”Headers on every call (Orders API > Authorization): Authorization: Bearer <token> and Accept: application/vnd.skroutz+json; version=3.0. JSON bodies are sent as application/json; charset=utf-8.
Add-on call (Client\Api) |
Endpoint | Body |
|---|---|---|
order() |
GET /merchants/ecommerce/orders/:code (?action_options=1) |
|
accept() |
POST .../:code/accept |
{number_of_parcels, pickup_location, pickup_window}; the window id belongs to the location ("20191204T1000-20191204T1200", local Greek time) |
reject() |
POST .../:code/reject |
{line_items:[{id, reason_id, available_quantity?}]} (reason 4 requires available_quantity) or {rejection_reason_other} |
setReady() |
POST .../:code/set_as_ready, .../set_as_not_ready |
none |
trackingDetails() |
POST .../:code/tracking_details |
{tracking_details:[{courier, tracking_code}]}, FBM only, couriers acs, dhl, geniki_taxydromiki, dpd, gls |
uploadInvoice() |
POST .../:code/invoices (invoice_file), .../credit_invoices (credit_invoice_file) |
multipart, pdf/png/jpg, 7 MB |
reschedule(), relocate(), requestVoucher() |
reschedule_pickup, relocate_pickup, request_voucher |
implemented in the client, no admin screen in 1.0.0 |
Errors: {"errors":[{"code":"order_status","messages":["Order already accepted."]}]} (HTTP 422); the same for “Order already rejected.”. The add-on treats these two as success after a read-back (Skroutz\Mapper::alreadyDone).
There is NO endpoint that lists orders and none that updates stock: the polling fallback re-reads known orders by code, and new orders are found through the webhook or “Import by order code”.
Webhook
Section titled “Webhook”POST, JSON, User-Agent: Skroutz OrderNotifier v1, {event_type: new_order|order_updated, event_time, order, changes?}, answer HTTP 200, retried 4 times within 20 minutes. The order object is the one the API returns. The docs list sender IP ranges (Webhook::IPV4, IPV6) and no signature.
Verification used by the add-on: (1) token in the URL, compared with hash_equals against the sealed account token; (2) optional IP range check with ClientIp::clientIp() (never X-Forwarded-For unless the Client IP settings trust the proxy); (3) the stored event only names the order, which is read back through the API (confirm_api, default on). The controller stores a job (wh:<account>:<md5 of code and body>: a Skroutz retry is the same job) and answers 200 at once; the job payload is wiped when the job finishes (it carries the buyer’s name and address).
Structure
Section titled “Structure”| Class | Role |
|---|---|
Client\BaseClient, Client\Api |
HTTP (cURL, TLS verification, timeouts), static Bearer token, error mapping, masked logging; Api = the Skroutz calls |
Skroutz\Mapper |
Pure mapping: order object to the normalized order, accept / reject bodies, pickup choice, UTF-8 safe text cuts. Unit tested with the official examples |
Orders |
Import and status follow. Claim (placing_at), per-order lock, adoption of an order placed before a crash ((skroutz <code>) in the notes), forward-only state |
Actions |
accept, reject, set as ready, tracking, invoice, import by code. Lock + read-back + atomic flag + documented 422 handling |
Products |
Line to product (variation code, shop_uid as product code / ID, EAN / MPN) and the stock decision |
Options, StatusMap |
Rules per account, state to CS-Cart status map, forward-only rules |
Jobs, Queue, JobException |
webhook, refresh, act jobs; back-off 5 / 15 / 60 / 180 / 720 minutes |
Accounts, Secret, Config, Access |
Sealed token (AES-256-GCM), pause after 401 / 403, owner mode, vendor scope (canAct) |
Webhook, ClientIp |
Token / IP helpers and the client IP policy |
Database tables
Section titled “Database tables”| Table | Purpose |
|---|---|
?:kv_skroutz_smart_cart_accounts |
Sealed API token and webhook token per company, last connection check (check_ok Y / N / P = paused) |
?:kv_skroutz_smart_cart_order_map |
One row per Skroutz order code: state, CS-Cart order, flags, voucher, pickup, last pickup / reject options, error and retry time |
?:kv_skroutz_smart_cart_options, _log, _jobs |
Rules, log, queue |
Hooks used
Section titled “Hooks used”PHP: get_notification_rules (no shop e-mail while an order is imported), create_shipment_post (tracking of FBM shipments, queued), update_product_amount (no stock movement for FBS and return orders, also at later status changes), mve_place_order (Multi-Vendor: in per-vendor mode the core payout of an imported order gets exclude_from_balance = Y), init_templater_post (upgrade synchronizer, only while pending). Template hook: orders:tabs_extra (the Skroutz tab on the CS-Cart order page).
Published examples with typos
Section titled “Published examples with typos”Two webhook examples (Example 3 “cancellation”: a missing comma after dispatch_until; Example 5 “courier voucher creation”: unquoted from) are not valid JSON as published. tests/fixtures keeps every example byte for byte (index.tsv names the page and section); tests/unit.php and the mock repair exactly these two typos. Where the docs show no answer body (401, 406, line item validation errors, FBM-only error text) the mock marks the body as a guess in tests/mock-server/server.js.
Test the HTTP layer without Skroutz
Section titled “Test the HTTP layer without Skroutz”$config['kv_skroutz_smart_cart_base_url'] = 'http://127.0.0.1:11831';node tests/mock-server/server.js 11831 starts the mock; node tests/e2e/e2e.mjs --store ... --db ... runs the HTTP end-to-end test (refuses to run unless the store points at 127.0.0.1); php tests/unit.php runs the unit tests.
Template overrides
Section titled “Template overrides”Admin templates live in design/backend/templates/addons/kv_skroutz_smart_cart/. Do not edit them in a store; they are replaced on update.