← DevLog

3 min read

Keep the ERP out of your checkout

Every live ERP call in the checkout adds the ERP to the list of things that can stop an order. Import the data in the background and let the checkout read its own table.

A ticket asked for something reasonable on a B2B shop: when a customer enters a postcode, show which branch will deliver. The ERP knows the answer. The first design was the obvious one. Call the ERP when the postcode is entered, and cache the answer for a day.

We did not build that, and the reason is worth more than the feature.

What a live call costs

The ERP sits behind a middleware layer. Measured that day, the first call took about two seconds and every call after it about 230 milliseconds. A cache hides the warm calls. It does not hide the cold ones, and it does not help at all when the ERP is down, slow or being upgraded on a Saturday morning.

A live call in the checkout makes the ERP part of the checkout. Its maintenance window becomes yours. Its slow day becomes your conversion rate. I wrote earlier about a client with no timeout, where one quiet ERP held up carts with nothing in any log. That is what a dependency in the request path looks like on a bad day.

What we do instead

Import the data in the background, store it in a table of our own, and have the shop read only that table.

  • An importer fetches the data from the ERP and replaces the local rows only after a fetch fully succeeds. A failed import leaves yesterday's data in place instead of an empty table.

  • Imports go through a queue. A login, a row that has gone stale or a nightly job puts work on it, and it runs at its own pace.

  • The storefront and checkout read the local table. They never wait for the ERP, so they cannot be held up by it.

It is the same pattern the shop already used for company data. The postcode data will follow it, and so will the next piece of ERP data anyone asks for.

Fresh enough is a decision

The objection is always freshness. The answer is to decide how fresh it needs to be, in minutes, and schedule the import to match. Branch assignments change a few times a year. Stock changes every hour. Both can be imported. Neither needs a live call in the checkout.

Some things can wait until after the order

The same shop lets customers order when no price is available, for example while the ERP is unreachable. The order goes through and the price is settled afterwards. For a B2B customer ordering the same products every month, that is a far better experience than a checkout that refuses to work because a system they have never heard of is having a bad morning.

Ask your team

List every system your checkout calls while the customer waits. For each one: what happens to an order when it is down for an hour? If the answer is "the customer cannot order", decide whether that is a choice you would make on purpose.