feat(donations): add option to flag any WooCommerce product as a donation#4635
Open
leogermani wants to merge 16 commits intotrunkfrom
Open
feat(donations): add option to flag any WooCommerce product as a donation#4635leogermani wants to merge 16 commits intotrunkfrom
leogermani wants to merge 16 commits intotrunkfrom
Conversation
…t screen Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…filter Remove the Additional Donation Products section from the donations wizard, its REST endpoints, and TypeScript types. Add a Donation column and dropdown filter to the WooCommerce products list instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use priority 20 to run after WooCommerce defines its columns, and use array_slice to insert before the last 2 columns (featured + date). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for marking arbitrary WooCommerce products as “donation products” so multiple distinct donation campaigns can share Newspack’s existing donation behaviors.
Changes:
- Adds a “Donation product” boolean option to the WooCommerce product edit UI (persisted to product meta).
- Extends donation detection and contribution meter revenue calculations to include meta-flagged donation products.
- Adds unit tests for donation-product flag detection and retrieval.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
includes/plugins/woocommerce/class-woocommerce-products.php |
Adds the new WooCommerce product-type option/checkbox for donation flagging. |
includes/class-donations.php |
Updates donation-product detection, adds flagged-product ID query, and uses donation detection in cart logic. |
includes/contribution-meter/class-contribution-meter.php |
Includes flagged donation products when computing donation revenue. |
tests/unit-tests/donations.php |
Adds unit tests around donation flag behavior. |
includes/wizards/audience/class-audience-donations.php |
Minor formatting/indentation adjustment in wizard data payload. |
💡 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.
All Submissions:
Changes proposed in this Pull Request:
Adds the ability for publishers to flag any WooCommerce product as a donation. Currently, Newspack only supports a single grouped donation product (with one-time, monthly, and yearly children). This change allows publishers to create multiple distinct donation campaigns — e.g., "Support Local News" vs "Investigative Journalism Fund."
A "Donation product" checkbox is added to the WooCommerce product edit screen. When checked, the product inherits all existing donation behaviors: donation-specific checkout UI ("Donate now" button), coupon disabling, Stripe metadata labeling, reader activation handling, contribution meter tracking, and reporting exclusions.
The existing default donation product continues to work exactly as before — no migration is needed.
How to test the changes in this Pull Request:
Other information: