#
How do delivery calculations work?
The calculation is split up in two big parts.
First we will determine the delivery time that is assigned to the product.
The second part is the actual calculation of the delivery time. This will take into account the daily deadlines,
holidays, national holidays and more.
#
1. Determine the delivery time
While determining the delivery time we loop over all possible configurations and priorities that are configured in the plugin, with performance in the back of our head. The priorities are defined here and are crucial for understanding the delivery time calculation. In Shopware standards, we only search for the assigned delivery time. Calculating the delivery time is done in the second step.
#
2. Calculate the actual delivery date
The most complicated part in this plugin is the actual calculation of the delivery date. If a 'determined' delivery time is not accurate, it is probably because it is recalculated in this part. We will go over the different steps:
#
2.1 Recalculating the start date
First thing we do is recalculating the start date if necessary. This is influenced by the shipment during weekends configuration. During weekends: If enabled, we will start calculating from today. If disabled, during weekends we will start calculating only from monday.
#
2.2 Looping over the determined deadlines
Secondly, we fetch the determined deadlines from the first step and loop over them. We do a first calculation with the determined minimum deadline.
#
2.3 Check if we are in a holiday
There are two types of skipping holidays. In both cases the holiday needs to be attached to the manufacturer of this product before it can be taken into account More info about holidays here. We will skip until the end of the holiday, and add the configured holiday delivery time, except if delivering is enabled during the holiday, which is a manufacturer specific configuration.
If we passed a holiday, while doing a first calculation, we will skip to the end of this holiday and start calculating from there.
#
2.5 We take the calculated delivery date
We take the calculated delivery date and do several checks. In these cases we add a day:
- If the calculated date is a sunday
- If the calculated date is a national holiday
Everytime a recalculation is done, we will check the newly calculated day again.