Skip to content

Add --days, --weeks, --months arguments for relative date ranges - #214

Open
Niels-R wants to merge 1 commit into
woocommerce:trunkfrom
Niels-R:add-period-date-arguments
Open

Add --days, --weeks, --months arguments for relative date ranges#214
Niels-R wants to merge 1 commit into
woocommerce:trunkfrom
Niels-R:add-period-date-arguments

Conversation

@Niels-R

@Niels-R Niels-R commented May 29, 2026

Copy link
Copy Markdown

All Submissions:

Changes proposed in this Pull Request:

Allows generating orders within a relative time period (e.g. --days=21, --weeks=4, --months=6) without needing to compute explicit calendar dates. The period arguments resolve to a date-start/date-end pair internally, reusing all existing date logic. Adds CLI validation and five new unit tests.

How to test the changes in this Pull Request:

  1. Generate orders using each new argument and verify the created dates fall within the expected range in WooCommerce > Orders:
    wp wc generate orders 10 --days=14
    wp wc generate orders 10 --weeks=4
    wp wc generate orders 10 --months=2

  2. Verify that combining a period argument with --date-start or --date-end produces an error:
    wp wc generate orders 10 --days=7 --date-start=2025-01-01

  3. Verify that passing multiple period arguments or an invalid value produces an error:
    wp wc generate orders 10 --days=7 --weeks=2
    wp wc generate orders 10 --months=0

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Add --days, --weeks, and --months arguments to wp wc generate orders, allowing orders to be generated within a relative time period from today without needing to specify explicit calendar dates.

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

Allows generating orders within a relative time period (e.g. --days=21,
--weeks=4, --months=6) without needing to compute explicit calendar dates.
The period arguments resolve to a date-start/date-end pair internally,
reusing all existing date logic. Adds CLI validation and five new unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant