GH#904: fix: reclaim orphan pending_site on WC order completion#912
GH#904: fix: reclaim orphan pending_site on WC order completion#912superdav42 merged 2 commits intomainfrom
Conversation
Hook woocommerce_order_status_completed to check for a pending_site transient keyed by the billing email hash. When found, reactivates the customer's cancelled membership, attaches the pending_site, links the WC order via _wu_membership_id post meta, deletes the transient, and triggers async site provisioning. Also adds a wc_get_order() stub to the test bootstrap and four unit tests covering: hook registration, order-not-found bail, full reclaim flow (membership reactivated + transient cleared + pending_site re-attached), and no-transient skip. Resolves #904
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 59 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge SummaryWhat was implemented: Reclaim path for orphaned Root cause: When a WU membership was cancelled, the pending_site was preserved in a transient ( Fix: Hooked
Verification: 4 unit tests added covering hook registration, order-not-found bail, full reclaim flow, and no-transient skip. Bootstrap includes a Resolves #904 |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for f8f4b2f are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Implements the reclaim path for orphaned
pending_siteobjects — the counterpart to the cancellation-preservation fix.When a WU membership is cancelled,
handle_pending_site_on_cancellationstores thepending_sitein a 24-hour transient keyed bywu_transferable_pending_+md5(email). Previously, nothing consumed that transient when the customer completed a new WooCommerce order. This PR closes that gap.Changes
inc/managers/class-membership-manager.phpwoocommerce_order_status_completed→reclaim_pending_site_on_wc_order_completionininit()reclaim_pending_site_on_wc_order_completion($order_id): looks up the billing email → transient → WP user → WU customer → most-recent cancelled membership; reactivates it, attaches thepending_site, writes_wu_membership_idpost meta on the WC order, deletes the transient, and triggerspublish_pending_site_async()wc_get_ordernot defined), order not found, no transient, no WP user, no WU customer, or no cancelled membershiptests/bootstrap.phpwc_get_order()stub (if WC is not loaded) driven by$GLOBALS['_wu_test_wc_order_email']tests/WP_Ultimo/Managers/Membership_Manager_Test.phptest_init_registers_wc_order_completion_hook— hook registration verifiedtest_reclaim_bails_when_order_not_found— stub returns false, membership stays cancelledtest_reclaim_pending_site_reactivates_membership_and_clears_transient— full flow: transient consumed, membership reactivated,pending_sitere-attachedtest_reclaim_skips_when_no_transient— no transient → membership unchangedunset($GLOBALS['_wu_test_wc_order_email'])totearDown()to prevent test pollutionAcceptance Criteria
Resolves #904
aidevops.sh v3.8.94 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 9m and 27,579 tokens on this as a headless worker.