Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

Fix status update for wrong renewal orders #625

Closed wjrosa closed 2 weeks ago

wjrosa commented 1 month ago

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
  5. On this branch, that will not happen Screenshot 2024-05-22 at 13 18 33

Product impact