-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set paid and completed dates #143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Tests well!
@coreymckrill Thanks for the quick review. I went ahead and added that offset to the payment date as well. Looking in the DB table for Would you mind taking one more quick look that all is well? |
@mikkamp looks good! Another thing just occurred to me, though. In some cases, adding up to 36 hours to the paid/completed date could end up making those dates be in the future. That doesn't seem great to me, but I could be convinced otherwise. If we want to prevent that, we could potentially do something like this: min( strtotime( $date ) + ( wp_rand( 0, 36 ) * HOUR_IN_SECONDS ), time() ) |
That is true, but considering that we are also able to generate orders in the future, with something like: I didn't think it would be such a big deal to have payment dates in the future. If they would really want to prevent that then they could always specify an older date range to prevent it from getting anything in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Thanks for the PR
All Submissions:
Changes proposed in this Pull Request:
When we generate orders we are able to generate them over a range of dates. This works correctly when setting the order creation date. However other dates will default to the current date.
So if we generate a set of orders for the Analytics reports the
date_paid
will all be at the time of when the order was generated. Which isn't very useful for populating some test data for these reports.This PR changes that behaviour and allows setting both the paid date as well as the order completed date. This is set based on the chosen status of the order. Paid date is set for both processing and completed. Completed date is set for only completed orders. The date is set by adding a random amount of 0 to 36 hours to the creation date.
How to test the changes in this Pull Request:
wp wc generate orders 10 --date-start=2024-01-01 --date-end=2024-01-31
Other information:
Changelog entry
FOR PR REVIEWER ONLY: