feat: support custom plans in membership renewals - #1693
Conversation
🔨 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: |
📝 WalkthroughWalkthroughThe changes add a pre-total payment action and update membership swaps to recognize custom registered plan product types. Tests cover payment line-item injection, hook flags, custom plan replacement, and addon exclusion. ChangesMembership behavior updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant wu_membership_create_new_payment
participant HookListener
participant PaymentTotals
wu_membership_create_new_payment->>HookListener: fire wu_membership_new_payment_pre_totals
HookListener->>wu_membership_create_new_payment: modify unsaved payment
wu_membership_create_new_payment->>PaymentTotals: recalculate totals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Performance Test Results Performance test results for 3360125 are in 🛎️! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/WP_Ultimo/Models/Membership_Test.php`:
- Around line 1094-1110: Replace the manual Product construction,
skip-validation call, and save in the network product fixture with the
`wu_create_product()` helper, preserving the existing network product
attributes. Assert that the helper result is not a `WP_Error` before using it to
create the cart.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5668977d-f8d7-436c-b5ec-2d4d78a12e8e
📒 Files selected for processing (4)
inc/functions/membership.phpinc/models/class-membership.phptests/WP_Ultimo/Functions/Membership_Functions_Test.phptests/WP_Ultimo/Models/Membership_Test.php
| $network_product = new Product( | ||
| [ | ||
| 'name' => 'Network Plan', | ||
| 'slug' => 'network-plan-' . wp_generate_password(6, false), | ||
| 'description' => 'A custom plan type registered by an addon', | ||
| 'pricing_type' => 'paid', | ||
| 'amount' => 49.00, | ||
| 'currency' => 'USD', | ||
| 'duration' => 1, | ||
| 'duration_unit' => 'month', | ||
| 'type' => 'network', | ||
| 'recurring' => true, | ||
| 'active' => true, | ||
| ] | ||
| ); | ||
| $network_product->set_skip_validation(true); | ||
| $network_product->save(); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use wu_create_product() for the product fixture.
The test rules require wu_create_*() helpers for test data. Assert that the helper does not return WP_Error before creating the cart.
Proposed fix
- $network_product = new Product(
- [
+ $network_product = wu_create_product(
+ [
'name' => 'Network Plan',
'slug' => 'network-plan-' . wp_generate_password(6, false),
'description' => 'A custom plan type registered by an addon',
@@
'active' => true,
+ 'skip_validation' => true,
]
);
- $network_product->set_skip_validation(true);
- $network_product->save();
+ $this->assertNotWPError($network_product);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $network_product = new Product( | |
| [ | |
| 'name' => 'Network Plan', | |
| 'slug' => 'network-plan-' . wp_generate_password(6, false), | |
| 'description' => 'A custom plan type registered by an addon', | |
| 'pricing_type' => 'paid', | |
| 'amount' => 49.00, | |
| 'currency' => 'USD', | |
| 'duration' => 1, | |
| 'duration_unit' => 'month', | |
| 'type' => 'network', | |
| 'recurring' => true, | |
| 'active' => true, | |
| ] | |
| ); | |
| $network_product->set_skip_validation(true); | |
| $network_product->save(); | |
| $network_product = wu_create_product( | |
| [ | |
| 'name' => 'Network Plan', | |
| 'slug' => 'network-plan-' . wp_generate_password(6, false), | |
| 'description' => 'A custom plan type registered by an addon', | |
| 'pricing_type' => 'paid', | |
| 'amount' => 49.00, | |
| 'currency' => 'USD', | |
| 'duration' => 1, | |
| 'duration_unit' => 'month', | |
| 'type' => 'network', | |
| 'recurring' => true, | |
| 'active' => true, | |
| 'skip_validation' => true, | |
| ] | |
| ); | |
| $this->assertNotWPError($network_product); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/WP_Ultimo/Models/Membership_Test.php` around lines 1094 - 1110, Replace
the manual Product construction, skip-validation call, and save in the network
product fixture with the `wu_create_product()` helper, preserving the existing
network product attributes. Assert that the helper result is not a `WP_Error`
before using it to create the cart.
Source: Coding guidelines
|
DISPATCH_CLAIM nonce=0f021b62f6c974caa1c92766fd165b16 runner=superdav42 ts=2026-08-05T17:34:19Z max_age_s=120 version=3.32.226 opencode_version=1.18.9 lease_token=0f021b62f6c974caa1c92766fd165b16 device=device-1783824528-2609248-26808 session=issue-1693 phase=prelaunch expires_at=1785951381 |
|
REVIEW_FOLLOWUP_CREATED source_pr=1693 issue=1694 fingerprint=source-pr-1693 runner=superdav42 ts=2026-08-05T17:34:41Z |
Summary
Verification
vendor/bin/phpunit --filter 'test_membership_create_new_payment_exposes_pre_totals_action|test_swap_replaces_plan_for_registered_custom_plan_type'Dependency context
This is the core prerequisite for the companion Metered Plans hosted active-site billing change.
aidevops.sh v3.32.226 plugin for OpenCode v1.18.9 with gpt-5.6-sol
Summary by CodeRabbit
New Features
Bug Fixes