Setting up CDEK
1. The keys
Paste the account and secure password from the CDEK business cabinet (Integration → API keys) into the module’s settings (Modules → CDEK → the gear). The data screen has a Test it button that asks CDEK for a token there and then, so you learn straight away whether the keys work.
No contract yet? Tick Test environment and leave both fields empty: the module talks to CDEK’s test server with CDEK’s own published test account. Its directory is a sample (about 1 300 pickup points), not the whole country — untick it before the shop goes live.
2. Sync the city directory
Directory and matching (a link in the settings) → Sync the directory.
This pulls CDEK’s ~140 000 Russian cities into m_cdek_cities (about a
minute). It runs as a background task — watch it under Background tasks.
Once the scheduler is running it refreshes itself weekly.
Other countries CDEK serves (BY, KZ, AM, KG, UZ) are added in the Countries setting.
3. Match places to your registry
Match with the registry ties each of your places to a CDEK city code. On the full Russian registry this lands about 93 % of places automatically; the rest are places CDEK does not list or spells differently (“Ростов Великий” is “Ростов” there). A place with no match is simply not offered CDEK. See Place matching.
Unmatched places are listed on the same screen, where you can bind one by hand — a manual binding survives every later re-match. Save the mapping keeps the result as a CSV you can restore on another server.
4. Pickup points
Points are fetched lazily, per city: the first checkout that names a city pays for one request, everyone after reads the table (a day by default). CDEK also answers for the whole country at once, so Fetch all pickup points loads everything in one pass; the scheduler repeats it nightly. With every point loaded, a customer in a village with none is shown the nearest towns that have one.
5. The delivery method
Add a shipping method (Shipping → Methods), set Priced by → CDEK, and choose:
- This method delivers — to a pickup point, or by courier;
- Point types — pickup points, parcel terminals, or both (none ticked = both);
- Tariff — Parcel, Express or Economy parcel;
- You hand parcels to CDEK — at a CDEK office, or CDEK’s courier collects them. Together with the tariff and the customer’s choice this gives the exact CDEK tariff code (136 “склад-склад”, 368 “склад-постамат” …), which is frozen onto the order.
For live prices also set the sender city on the data screen (or give your warehouse a town). Without it the method is priced from your own rate table, which is a supported way to run it.
The price is CDEK’s total_sum: delivery plus VAT plus, with Declare the
goods’ value on, the insurance on the cart total. It is quoted in roubles; a
shop in another currency needs a RUB currency with a rate.
Place matching
CDEK addresses everything by its own integer city code: the points of a
city, a price from one city to another. So each of your places has to carry a
code before a customer types a town — the match is done once, offline, and
stored in m_cdek_place_map.
Why not by name
Russia has dozens of villages with any given name (“Одинцово” alone is in ten regions). Name alone identifies nothing.
Why not by coordinates first
Both sides have coordinates, but CDEK’s are wrong for some of its oldest rows — measured: its Иркутск sits 500 km from Irkutsk, and the Moscow-oblast Чехов is placed on Sakhalin, next to the Sakhalin one. Those old rows are the big towns, exactly the ones that must not be missed. So the administrative names decide and coordinates only break ties:
- name + region + district — CDEK’s
sub_regionagainst your place’s district (“Одинцовский городской округ” on both sides). Most matches land here. - name + region, exactly one in CDEK’s list — and either you have a single place of that name in the region, or the coordinates agree.
- Several in the region: the nearest, within 30 km and at least twice as close as the next one.
- The same across the country — for regions the two sides spell differently.
- A name that is unique in CDEK’s whole directory, when nothing contradicts it.
Region and district names are compared after dropping the words that only say what kind of unit it is (“область”, “республика”, “городской округ” …) and folding ё to е.
What is left over
Places CDEK does not list (or spells differently) stay unmatched and are not offered CDEK. Bind them by hand on the data screen; a manual binding is never overwritten by a later run. Automatic bindings are recomputed on every run, so a city CDEK has dropped stops being offered.
Waybills
An order sent with CDEK gets a CDEK waybill card on its order screen (right column). Staff need the Create and print CDEK waybills permission — separate from setting the integration up.
Before the first one
In the module settings, group Waybills:
- CDEK office you drop parcels at — its code (MSK2 …). Needed for methods where you hand parcels in at an office.
- Sender: company / contact / phone — printed on the waybill.
- Pickup address — needed for methods where CDEK’s courier collects them; the city is the sender city.
Making one
The card starts with the parcel: weight from the goods’ own weights, box from their sizes (or the module’s default parcel), editable. Collect payment on delivery is ticked when something is still owed and the order is not waiting for an online payment; what is collected is exactly what is still owed — a discount, a gift card or a part paid already is not charged again. The goods are declared at their full price either way (CDEK insures them).
Everything else comes from the order as it was placed: the tariff of the point the customer chose (a locker is sent by a different code from an office), the point’s code or the courier’s address, the recipient’s name and phone.
After
CDEK registers an order a little while after it accepts it: the card says being registered… until the CDEK number arrives. Then:
- Print the waybill — the receipt, two copies (one stays with you);
- Print the label — the A6 barcode sticker for the box;
- Refresh — ask CDEK for the status now; the scheduler asks every half hour anyway, until the parcel is delivered or returned;
- Cancel the waybill — only while CDEK does not have the parcel yet. A new
one can then be made; it gets the order number with
-2, because CDEK will not take one number twice.
If CDEK accepts a waybill and then refuses it, the card says why, and the form is back for the next attempt.
The customer sees the CDEK number, with a link to CDEK’s tracking page, on their own order page.
The test environment
CDEK’s public test account cannot collect on delivery: such a waybill is accepted and never numbered, so it cannot be printed. Untick it to try the whole way through. Its own city is Novosibirsk.
Another module can act on a status change through the hook
cdek.waybill.status_changed (['waybill' => …, 'from' => old code]).