feat(integrations): add subscription and donation metadata#4597
Open
chickenn00dle wants to merge 4 commits intotrunkfrom
Open
feat(integrations): add subscription and donation metadata#4597chickenn00dle wants to merge 4 commits intotrunkfrom
chickenn00dle wants to merge 4 commits intotrunkfrom
Conversation
0980297 to
ec9dfe1
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ec9dfe1 to
33c8baf
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Reader Activation contact metadata for WooCommerce Subscriptions and Donations so ESP syncs can include richer subscription/donation lifecycle fields.
Changes:
- Implemented
Subscription::get_metadata()with 13 subscription-related fields (status, counts, dates, billing, product, coupon, last payment, cancellation reason). - Implemented
Donation::get_metadata()by extendingSubscription, filtering to donation-only, and adding donor status + one-time donation fallbacks and previous amount tracking. - Added unit tests + expanded WooCommerce test mocks; added a shared date formatter in the Contact_Metadata base class and extra sync logging.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/reader-activation-sync/class-test-subscription-metadata.php | New unit tests covering Subscription metadata fields and edge cases. |
| tests/unit-tests/reader-activation-sync/class-test-donation-metadata.php | New unit tests covering Donation metadata fields, donor labels, and switch/previous amount logic. |
| tests/mocks/wc-mocks.php | Extends WC mocks to support new metadata logic (products/items, coupons, related orders, order lookup). |
| includes/reader-activation/sync/contact-metadata/class-subscription.php | Implements Subscription metadata retrieval with caching and helpers. |
| includes/reader-activation/sync/contact-metadata/class-donation.php | Implements Donation metadata by reusing Subscription helpers + donation-specific fallbacks. |
| includes/reader-activation/sync/class-contact-sync.php | Adds additional logging around contact sync calls. |
| includes/reader-activation/sync/class-contact-metadata.php | Adds a shared date format constant and formatter helper. |
Comments suppressed due to low confidence (1)
tests/mocks/wc-mocks.php:318
- The mock WC_Subscription::get_date() only accepts one parameter, but production WC_Subscription::get_date() is commonly called with a timezone/context argument (e.g., get_date('start','site')). The new Subscription metadata code passes a second argument, which can trigger warnings/errors in tests on newer PHP versions; update the mock signature to accept an optional second parameter (and ignore it).
public function get_date( $type ) {
return $this->data['dates'][ $type ] ?? 0;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
includes/reader-activation/sync/contact-metadata/class-donation.php
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/mocks/wc-mocks.php:318
- WC_Subscription::get_date() in this test mock only accepts one argument, but the new metadata code calls
$subscription->get_date( ..., 'site' )(matching the real WooCommerce Subscriptions signature). In PHP 8 this will throw an ArgumentCountError in unit tests. Update the mock method signature to accept the optional timezone/context parameter (or use variadic args) and ignore it as needed so tests exercise the production call shape.
public function get_date( $type ) {
return $this->data['dates'][ $type ] ?? 0;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_metadata()for theSubscriptioncontact metadata class with 13 get methods covering subscriber status, active count, dates, billing cycle, payments, product names, coupon codes, and cancellation reasons — all filtered to non-donation subscriptions only.get_metadata()for theDonationclass by extendingSubscription, inverting the filter to donation-only, and adding donor status labels (Monthly/Yearly/Ex-* Donor), one-time donation fallbacks, and previous donation amount tracking.Closes NPPD-1388
Test plan
wp-config.php:🤖 Generated with Claude Code