You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the "Time Since" rule logic. The code currently calculates the difference between the current date and the order date by only considering the difference in days (d). For example, if the order was made on 2024-10-15, the calculated difference on 2024-11-18 is 3 (18 - 15). However, the correct value should be 34, taking into account the full time interval, including months and years.
The issue arises because the d property of the TimeInterval object is used in the calculation. This property only provides the day difference and ignores other components of the date. Replacing d with the days property seems to resolve the issue, as days provides the total difference in days.
Step-by-step reproduction instructions
Set a Woocommerce "Time Since Order" rule.
First Order.
Greater than
31
The rule will never be true.
Expected behavior
The "Time Since" rule should calculate the correct time difference in days, considering the full time interval between the two dates. For example, from 2024-10-15 to 2024-11-18, the expected result is 34 days.
Actual behavior
The "Time Since" rule calculates the time difference as 3 days, ignoring the months and other components of the date interval.
Screenshots or screen recording (optional)
No screenshots available, but the bug can be reproduced with the steps provided.
System information
Block Visibility version: e.g., "3.7.0"
Block Visibility Pro version: "Not installed"
WordPress version: "6.7.0"
Gutenberg version: "Not installed"
Are all plugins except Block Visibility, Block Visibility Pro (if installed), and Gutenberg (if installed) deactivated? No
Are you using a default theme (e.g., Twenty Twenty-One)? No
The text was updated successfully, but these errors were encountered:
Description
There is a bug in the "Time Since" rule logic. The code currently calculates the difference between the current date and the order date by only considering the difference in days (
d
). For example, if the order was made on 2024-10-15, the calculated difference on 2024-11-18 is3
(18 - 15). However, the correct value should be34
, taking into account the full time interval, including months and years.The issue arises because the
d
property of theTimeInterval
object is used in the calculation. This property only provides the day difference and ignores other components of the date. Replacingd
with thedays
property seems to resolve the issue, asdays
provides the total difference in days.Step-by-step reproduction instructions
Expected behavior
The "Time Since" rule should calculate the correct time difference in days, considering the full time interval between the two dates. For example, from 2024-10-15 to 2024-11-18, the expected result is
34
days.Actual behavior
The "Time Since" rule calculates the time difference as
3
days, ignoring the months and other components of the date interval.Screenshots or screen recording (optional)
No screenshots available, but the bug can be reproduced with the steps provided.
System information
The text was updated successfully, but these errors were encountered: