DanielRiera / estimated-delivery-woocommerce

8 stars 6 forks source link

Calculate delivery date range using only working days #48

Closed elrosa closed 1 year ago

elrosa commented 1 year ago

While using this plugin, I noticed the calculations for delivery date ranges were always using absolute days, and the result wasn't always correct. I would expect delivery dates to be calculated only using working days, and the maximum shipping date to be based on a previously calculated start date.

I believe it was also reported here: https://github.com/DanielRiera/estimated-delivery-woocommerce/issues/41

I made the following changes:

Example: Shipping of my products take 2 to 3 business days. Delivery company doesn't work on Saturdays and Sundays. When users visit my website on Friday, they should see expected delivery on Tuesday-Wednesday next week, but they were shown Monday date only.

This happens because both minimum shipping date and maximum shipping date are calculated independently from each other. Minimum delivery time is 2 days, but Friday + 2 days is Sunday; minimum date is then bumped to Monday. Then, max date is Friday + 3 days: Monday again.

M T W T F S S
today x x
1 2 3
Example 2: Some products are made to order and take up to 10 working days to deliver. Deliveries are not made on weekends. If today is Wednesday, the maximum delivery date is another Wednesday in two weeks - it's calculated as follows: M T W T F S S
today 1 2 x x
3 4 5 6 7 x x
8 9 10
elrosa commented 1 year ago

I prepared a live example:

This is a product with estimated delivery in 2-3 business days (system default): https://22cd831d.cfolks.pl/produkt/simple-product/

This one has a custom delivery range of 2-10 business days: https://22cd831d.cfolks.pl/produkt/product-made-to-order/

DanielRiera commented 1 year ago

Thanks @elrosa i updated plugin to 1.3.3 with this :)