Business Logic for Delivery Date Selection
You are probably fond of the idea of specifying the delivery date for your e-commerce order.
"Behind the scenes" part to this is pretty complex. Most people misunderstand how the lead time calculation is done and it's fair to say that this logic is somewhat counter intuitive.
The main thing to calculate is "when is the earliest delivery date" which is calculated based on
- Non-operational dates for the warehouse
- Cut-off time
- Area-based lead-time
How is the earliest deliverable date calculated?
Let's say your warehouse is in Chiba, Japan, your customer is in Tokyo, and the shipping provider is Yamato. Typically Chiba to Tokyo takes just 1 day from ship out to delivery.
So if you (who lives in Tokyo) make an order right now, does it mean that you will receive the package tomorrow? You can easily guess no from your past purchase experiences that how fast your package arrives depends on situations, but to elaborate more, when you get the package depends on when the product can be shipped out.
When the product can be shipped out first depends on if the warehouse is operational today or tomorrow or whenever the next non operational day is. So to manage this, we need the date of when are the warehouse operational, or non operational. This is the first component to the math.
Secondly, even if today the warehouse is operational, if you make an order at 23:50, that could end up with different results from if you had made an order before noon. This is where the concept of "cut-off time" comes in. If the cut-off time is 1pm, then making an order before or after that would mean that the earliest deliverable date would change.
In the warehouse, first they need to wait for the order data to come in. This may come realtime or near realtime in more modern environments, but it could be only once or twice a day that this order data is sent from e-commerce systems to the warehouse. Also after receiving order data, the warehouse needs to print picking lists, shipping slips, and pick / pack the products. Typically shipping providers such as Yamato or Sagawa comes pick up the packed boxes in evening hours, so if we calculate back from this evening time, realistically it would be around 11am ~ 1pm that the warehouse can accept orders and ship out on the same day. Note that not all warehouses ship out the same day, and some have an extra days or even more as lead time to do all this preparation process.
Lastly, the lead-time it takes for the shipping provider to delivery the goods after receiving it from the warehouse depends on the geography. I mentioned that Chiba to Tokyo is typically a day, but Chiba to Okinawa would take at least 3 days. This lead time may be set to something like "4 days" for some stores, but it could be per-prefecture, or even per-city, or per-postcode. It really just depends on the policy of the merchant and warehouse / e-commerce system capabilities, but its more likely that the system doesn't need to waste time for the consumer if the lead time is setup as close as possible to the shipping provider's capability.
So when we add up all of these components, when the user comes to the shipping step in your store's checkout, the math can be done and the system can propose to the customer the deliverable dates.
This covers the basics, however the actual logic is somewhat more complex, and because each merchant / warehouse is different, there may be more elements to consider.
I hope this answered your questions!