PrestaShop Tutorials

How to manage use-by dates, best-before dates and lot numbers in PrestaShop

Selling food, cosmetics or chemical products online means managing a piece of data PrestaShop knows nothing about: the date. Not the order date, the product’s own date, which varies from one batch to another and determines what you can ship.

Three notions not to confuse

The use-by date is expressed as “use by”. It applies to highly perishable foodstuffs. Beyond this date, the product is deemed unsafe: selling it is prohibited, and so is giving it away for free.

The best-before date, or date of minimum durability, is expressed as “best before”. It applies to stable products. Passing it does not prohibit the sale: the product remains consumable, it may simply have lost taste or nutritional qualities. Selling past the best-before date is lawful provided the consumer is informed, and it is common in anti-waste clearance.

The lot number is not a date. It is an identifier that makes it possible to trace all the units produced under the same conditions. It is mandatory on most prepacked foodstuffs and it is the basis of all traceability.

This distinction is not academic: it determines three different behaviours in your shop. A product past its use-by date must be blocked from sale. A product past its best-before date can be sold with information. A recalled lot must be withdrawn regardless of any date.

The data model

This is the point that breaks a naive implementation: the date does not belong to the product, it belongs to the lot.

The same product can have three lots in stock with three different dates. The quantity shown on the product page is the sum of the lots, but the date shown must be that of the lot which will actually ship, that is, the one closest to expiry.

The minimal model therefore has three levels: the product, the lot with its number and date, and the quantity per lot. Any attempt to store a single date on the product page fails at the second restock.

Expiry Date & Batch Manager — Lots, FEFO and Use-By DatesOne batch, one date, an honest stock deduction: use-by and best-before dates finally handled inside PrestaShop.99.00

What to show the customer

In distance selling, the customer cannot turn the packaging over to read the date. Three elements deserve to appear.

A minimum guaranteed shelf life on receipt. “Guaranteed minimum durability: at least 3 months on receipt” is more useful than a precise date, which will change with the next lot and would force you to edit the page constantly.

An explicit notice when selling past the best-before date. On a short-dated or expired lot sold at a reduced price, the information must be visible before the purchase, not discovered on receipt. It is the condition of lawfulness of this sale.

The lot number on the delivery note, or failing that in the order tracking. It allows the customer to contact you precisely if there is a problem.

Order preparation

The allocation rule is FEFO, first expired first out. It differs from classic FIFO: it is not the lot received first that ships, it is the one whose date is closest.

The two rules often coincide, but not always. An emergency restock from another supplier can arrive with shorter dates than the existing stock, and it is that one which must go out first.

In practice, the picking list must indicate, for each line, the lot to pick and its location. Without this indication, the picker takes whatever is in front, and three months later you discover an expired pallet at the back.

Traceability and recall

This is the function that on its own justifies lot management.

In case of a product recall, you must be able to answer two questions within minutes. Which orders contained this lot? And which customers to contact?

That requires the lot number to be recorded on the order line at preparation time, not only in your stock. Lot management that stops at the warehouse allows no targeted recall: you then have to contact every buyer of the product, which costs far more in reputation than a precise recall.

Also keep the trace of shipped lots for the legal retention period applicable to your sector, which often exceeds the product’s shelf life.

The alerts

Three thresholds deserve an automatic alert, to calibrate to your rotation.

A first signal at 60 days out, which leaves time to accelerate the sell-through with a highlight or a promotion. A second at 30 days, where clearance becomes the priority. And an automatic block on the date, which pulls the lot from sale without intervention.

This last point is the most important: on a use-by date, the block must be automatic and not depend on a human check. Shipping past the use-by date engages your liability even if the mistake is unintentional.

The case of bundles and gift sets

An assortment containing six different products carries six dates. The date to retain is the shortest, and it is the one that governs the sale of the entire set.

This rule has a management consequence: a well-selling set can be blocked by a single one of its components. Plan for the substitution of the affected component rather than blocking the assortment.

The Expiry Date and Best-Before Management module handles this chain on PrestaShop 8 and 9: lot-level management with date and quantity, distinct use-by and best-before behaviours, FEFO picking on the preparation slip, lot recording on the order line and expiry alerts.

Keep reading

Related articles