Skip to content

Keeping stock levels in sync between online shop and ERP

Overselling and phantom stock rarely come from a single bug. Usually three questions have been left open: which system owns the stock figure, which number is transferred, and what happens to orders placed between two syncs?

  • Who it is forBusinesses with an online shop; developers
  • LevelGuide
  • Reading timeabout 9 minutes
  • Last updated24 October 2026

What you will learn

  • Why exactly one system has to own the stock figure
  • How on-hand stock differs from available stock
  • When a delta sync fits and when a full sync does
  • How to close the gap between two syncs and notice discrepancies

What matters

A stock sync is reliable once three things are settled. One system owns the stock figure; the other only displays it. What is transferred is available stock, not on-hand stock. And orders placed between the moment a stock snapshot is taken and the moment it reaches the shop are deducted rather than overwritten. On top of that come checks that report a discrepancy before a customer finds it.

Two terms first. Overselling means the shop sells more than can actually be delivered. Phantom stock is stock that one system shows but the warehouse does not hold. Both often share a cause: two systems that disagree about the current state.

One system owns it, the other displays it

In most businesses the ERP (enterprise resource planning) or inventory management system owns the stock figure. That is where goods receipts are posted, stocktakes recorded, returns inspected and deliveries booked out. The shop, on the other hand, owns orders: it is the first to know that a customer has bought something.

This gives a clear division. Only the ERP books physical movements; the shop reports orders and cancellations to it. If someone changes a stock figure by hand in the shop, the next sync overwrites it – rightly so. Why this decision has to come before any connection is shown by the example in Connecting Excel, e-mail and business software.

If you sell through several channels, such as your shop and a marketplace, the system of record has to be the one where orders from all channels meet. Otherwise every channel sells the same last item.

Which number is actually transferred?

“Stock” often means different things in conversation. For a sync they must be kept apart:

The shop needs available stock. Sending it on-hand stock sells items that have already been sold.
TermMeaningWho knows it
On-hand stockWhat is physically on the shelf.ERP
ReservedOrdered but not yet shipped.The ERP for orders it knows about, the shop for orders not yet transferred
Safety stockA quantity deliberately not sold online, for example for a physical store or breakage.A business decision
Available stockOn-hand stock minus reservations minus safety stock.The result of a calculation both sides need

Delta or full sync

In a full sync the ERP sends the current figure for every product. In a delta sync it sends only changes, such as “product 4711: plus twelve from goods receipt”. Each has a typical weakness:

  • Full sync: robust, because every run corrects old discrepancies. But with large catalogues it takes longer, and it overwrites anything that changed while it was running.
  • Delta sync: fast and economical, possible several times a minute. But a single lost or double-processed change creates a discrepancy that stays until someone notices it.

In our assessment, the combination works best: changes flow as deltas during the day, and a full sync during a quiet hour resets the figures and reports every discrepancy it corrects. Those reports are valuable – they show where the delta route has gaps. So that a change delivered twice is not booked twice, each one needs a unique identifier; see Preventing duplicate processing. Whether the transfer runs by file or API is a separate decision: CSV import or API integration.

The gap between snapshot and arrival

Every stock snapshot has a point in time. Between the moment the ERP calculates it and the moment the shop applies it, time passes – seconds with an API, half an hour with a nightly export. Orders placed in that gap are unknown to the snapshot. If the shop overwrites its figure with it, they are forgotten.

Three measures close the gap:

  • Fix the order of transfers. Orders are sent to the ERP before it produces a stock snapshot, so that as many as possible are already reserved.
  • Send a timestamp. Each snapshot carries the time it was calculated. When applying it, the shop deducts all of its own orders placed after that time that have not yet reached the ERP.
  • Discard older snapshots. If a snapshot arrives that is older than the last one applied, for example after a retry, it is ignored.

Conflicts still occur, for instance when a return counts as refunded in the shop but has not yet been inspected in the warehouse. The rule from the first section decides: stock rises only when the ERP books the goods back in. Where such steps run with a delay in the background, Background jobs and queues helps.

A hypothetical example

Three oversold orders on Monday morning

A retailer syncs every night at 2 am. The ERP produces its stock export at 1.30 am; shop orders are transferred every hour on the hour. On Sunday evening a promotion is running. Between 1 am and 2 am orders arrive that are neither in the 1.30 export nor transferred by then. At 2 am the sync overwrites the shop figure with the older, higher number. On Monday morning there are three orders for an item that is no longer there.

The fix does not rebuild anything from scratch. The order export runs immediately before the stock export, the stock export carries its timestamp, and the shop deducts later orders when applying it. The nightly full sync stays – but it now reports which products it corrected.

Control totals and monitoring

A sync that silently goes wrong is worse than one that fails loudly. These checks make discrepancies visible:

  • The number of products transferred compared with the number of active products on both sides.
  • The total of all available stock before and after the run, as a rough plausibility check.
  • A list of products whose figures differ between shop and ERP by more than a set quantity.
  • Negative stock – it usually points to a missing or duplicated booking.
  • The age of the last successful run and the number of rejected records.

Each of these checks needs a recipient: a person who reads the alert and knows what to do. How to log errors so that they get noticed is covered in Error handling and logging.

Checklist before building

  1. Decide which system owns on-hand stock and which owns orders.
  2. Write down the formula for available stock: which reservations, which safety stock.
  3. Establish what the stock field in the shop system means.
  4. Delta, full sync or both – and at what intervals.
  5. Fix the order of order and stock transfers and how timestamps are handled.
  6. Name the checks and who receives the alerts.

One example of capture with handheld scanners and storage assignment in retail is our mobile data capture project. We build connections between shop and ERP as part of our API integration work, and for Shopware also through Shopware development.

Common misconceptions

A shorter interval narrows the gap but does not close it. Only timestamps and deducting later orders close it.

The shop needs available stock, after reservations and safety stock. Some shop systems reduce it the moment an order is placed.

It also arises in the sync, for example when a return is booked twice or a cancellation is never transferred. Control totals make both visible.

Further sources

About the author

Fabian Lücker is managing partner of PHP Schmiede KG in Rheine and has worked in software development since 2007. He is responsible for development and design, and writes here about decisions that come up in real projects.

Stock figures that do not match?

Describe how stock and orders currently move between your shop and your ERP. We will show where the gap is and how it can be closed.