feat(donations): add option to flag any WooCommerce product as a donation#4635
feat(donations): add option to flag any WooCommerce product as a donation#4635leogermani wants to merge 18 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>
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.
miguelpeixe
left a comment
There was a problem hiding this comment.
Tests well! I have a concern with the variable subscription setup:
| 'label' => __( 'Donation product', 'newspack-plugin' ), | ||
| 'description' => __( 'Flag this product as a donation. Donation products use donation-specific checkout, reporting, and reader activation behaviors.', 'newspack-plugin' ), | ||
| 'default' => 'no', | ||
| 'product_types' => [ 'simple', 'subscription', 'grouped', 'variable', 'variation', 'subscription_variation', 'variable-subscription' ], |
There was a problem hiding this comment.
For the variable-subscription type, I believe the flag should be inherited from the parent and not be applied to the single subscription_variation.
|
@miguelpeixe addressed in b189cb4 (re:
|
|
@leogermani I think you forgot to push |
oops. it's there now |
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: