Skip to content

feat(donations): add option to flag any WooCommerce product as a donation#4635

Open
leogermani wants to merge 16 commits intotrunkfrom
feat/donation-product-flag-v2
Open

feat(donations): add option to flag any WooCommerce product as a donation#4635
leogermani wants to merge 16 commits intotrunkfrom
feat/donation-product-flag-v2

Conversation

@leogermani
Copy link
Copy Markdown
Contributor

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:

  1. Ensure WooCommerce and WooCommerce Subscriptions are active.
  2. Go to Products > Add New and create a simple product.
  3. In the Product Data panel, verify the "Donation product" checkbox appears alongside "Auto-complete orders."
  4. Check the checkbox, save the product, and reload — verify the checkbox remains checked.
  5. Uncheck the checkbox, save, and reload — verify it's unchecked.
  6. Create a subscription product, check the "Donation product" checkbox, and save.
  7. Add the flagged product to the cart and proceed to checkout — verify the checkout button says "Donate now" and coupons are disabled.
  8. Complete a purchase of the flagged product and verify the order is recognized as a donation order (check Stripe metadata if Stripe is configured).
  9. Verify the contribution meter block includes revenue from the flagged product.
  10. Verify the default Newspack donation product (created via the Donations wizard) still works correctly and is unaffected.
  11. Verify that trashing or deleting a flagged product does not cause errors.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

leogermani and others added 12 commits April 6, 2026 17:32
…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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leogermani leogermani self-assigned this Apr 7, 2026
@leogermani leogermani added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 7, 2026
@leogermani leogermani marked this pull request as ready for review April 7, 2026 19:00
@leogermani leogermani requested a review from a team as a code owner April 7, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants