Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #4514358
Date Error Bug - ***FIXED***
Open

Comments

  •  2
    Gary started the conversation

    Hello,

    I’m using your WP Clever – Estimated Delivery Date (Premium) plugin, and I’ve tracked down a weekend logic issue that affects shops using:

    • Skipped days: Saturday & Sunday

    • Dispatch cut-off: e.g. 08:00

    • Working-day based lead times (1–2 / 2–5 working days style)

    I’ll summarise what’s happening, what I’m seeing, and the fix that resolved it.

    My setup

    Global:

    • Skip days: Saturday, Sunday

    • Dispatch cut-off: 08:00

    Shipping methods:

    • Express: Min 1 / Max 2 (label: “1–2 working days”)

    • Standard: Min 2 / Max 5 (label: “2–5 working days”)

    • Free: same as Standard

    Intended behaviour:

    • Weekend orders (Sat/Sun) → treated as Monday dispatch, then:

      • Express: Tue–Wed

      • Standard/Free: Wed–Mon

    So all methods are based on working days after dispatch, consistently.

    What actually happens (bug)

    Example: Order placed Saturday 18:30 with Sat/Sun skipped.

    The plugin output (before fix):

    • Express (1–2): Mon–Tue

    • Standard (2–5): Tue–Fri

    So Monday is being treated as day 1 for the Express window after a weekend order, which is inconsistent with how the same 1–2 range behaves on a normal weekday.

    On a normal working day, Min = 1 behaves like “next working day”.
    On a skipped-origin day (Sat/Sun), Min = 1 behaves like “same (Monday) day”.

    Same Min/Max, different semantics depending on whether the order originated on a skipped day.

    Where it comes from in the code

    In Wpced_Frontend::get_date( $days, $scheduled = '' ):

    • You calculate:

      $current_unix    = current_time( 'U' );
      $current_time    = current_time( 'h:i a' );
      $current_date    = current_time( 'm/d/Y' );
      $current_weekday = current_time( 'w' );
      

    • If today is a skipped day, you fast-forward $current_date to the next non-skipped day and set a flag (effectively: “we started from a skipped date”).

    • You then have two filters:

      • wpced_apply_extra_date_for_skipped_date (default: false)

      • wpced_apply_extra_time_for_skipped_date (default: ! $current_date_skipped)

    Because wpced_apply_extra_date_for_skipped_date defaults to false, when an order originates on a skipped day and is moved to Monday:

    • The extra “+1 day” adjustment is not applied.

    • The loop counts Monday as the first available day ($days starting at 1),

    • So Min = 1 returns Monday instead of aligning with the “next-day” logic used on normal working days.

    That’s what causes the off-by-one / inconsistent behaviour for weekend orders.

    The fix I’m using (works perfectly)

    I’ve corrected this on my site by enabling the intended adjustment for skipped-origin orders:

    add_filter( 'wpced_apply_extra_date_for_skipped_date', '__return_true' );
    

    With that filter enabled:

    • Weekend orders (Sat/Sun) → pushed to Monday,

    • The extra date logic is applied consistently,

    • My estimates now align correctly:

      • Weekend orders:

        • Express (1–2): Tue–Wed

        • Standard/Free (2–5): Wed–Mon

      • Weekday orders still behave as expected with the same Min/Max values.

    In other words: enabling this makes skipped-day starts behave consistently with normal days, which is what store owners expect when they configure working days and cut-offs.

    Suggestion

    For a future update, I’d strongly recommend either:

    1. Setting wpced_apply_extra_date_for_skipped_date to true by default when skip days are enabled, or

    2. Adjusting the get_date() logic so that:

      • When an order is moved from a skipped day to the next working day, that new day is treated the same way as “today” on a normal working day (so Min/Max semantics don’t change).

    This would prevent confusing date ranges for weekend orders without breaking existing setups, and the hook is already there, so it’s a minimal change.

    I have included the screenshots showing:

    • Saturday 18:30 order behaviour before,

    • The corrected behaviour after applying the filter.

    Attached files:  Standard (2-5 wording days) settings.png
      Express (1-2 wording days) settings.png
      Incorrect Estimated dates - Screenshot 2025-11-08 1830pm.png
      Fixed Estimated dates - Screenshot 2025-11-08 1958pm.png

  •  2
    Gary replied

    Here are some additional images that I originally didn't have enough space to upload.

    Attached files:  Default and Free (2-5 wording days) settings.png
      Dispatch cut-off time -8am and Skipped days - Sat and Sun.png