Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Fix status update for wrong renewal orders #625

Merged
merged 17 commits into from
Jun 13, 2024

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented May 20, 2024

Fixes 4503-gh-woocommerce/woocommerce-subscriptions

Description

Currently, if there are multiple renewal orders with the pending payment status, and you set one of them to completed, then one of the other renewal orders is changed to the processing status. This PR fixes that by checking if the order being handled is the last renewal order from the subscription. It also introduces some new helper functions for subscriptions.

How to test this PR

  1. Purchase a subscription product
  2. Use the "Create pending renewal order" subscription action to create 2 or more renewal orders with the pending payment status for the same subscription.
  3. Set any one of the pending payment renewal orders to completed (not the last one)
  4. On trunk, notice that another one of the pending payment renewal orders has been changed to processing
Screenshot 2024-05-22 at 13 18 24 6. On this branch, that will not happen Screenshot 2024-05-22 at 13 18 33

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes
  • Will this PR affect WooCommerce Payments? yes

@wjrosa wjrosa self-assigned this May 20, 2024
@wjrosa wjrosa changed the title Fix renewal orders wrong status update Fix status update for wrong renewal orders May 22, 2024
@wjrosa wjrosa requested a review from james-allan May 22, 2024 15:45
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @wjrosa. Nice PR.

The changes test well. I confirmed that processing a renewal order which isn't the latest order also causes the latest renewal order to be set to processing.

I left some inline feedback about missing function block descriptions and a suggestion about changing the wcs_get_newest_renewal_orders() to be more general use.

@wjrosa wjrosa requested a review from james-allan May 24, 2024 10:04
@wjrosa wjrosa requested a review from james-allan June 6, 2024 17:21
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good @wjrosa. I've just left two tiny comments. Approving as they aren't blocking. :)

@wjrosa wjrosa merged commit d9609cf into trunk Jun 13, 2024
9 checks passed
@wjrosa wjrosa deleted the fix/renewal-orders-wrong-status branch June 13, 2024 17:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants