Skip to content

feat(content-gate): dynamic product button for content banners#4482

Draft
miguelpeixe wants to merge 12 commits intotrunkfrom
feat/content-banner-dynamic-product-button
Draft

feat(content-gate): dynamic product button for content banners#4482
miguelpeixe wants to merge 12 commits intotrunkfrom
feat/content-banner-dynamic-product-button

Conversation

@miguelpeixe
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe commented Feb 12, 2026

All Submissions:

Changes proposed in this Pull Request:

NPPD-1086

The content banner's subscribe button now dynamically resolves which products to offer based on the content gate's access rules, instead of requiring a manually selected product.

  • Adds Content_Gate::get_gate_access_product_ids() to extract subscription product IDs from a gate's custom access rules, with a newspack_gate_access_product_ids filter for other restriction strategies to contribute product IDs.
  • Adds Memberships integration via filter_gate_access_product_ids so membership plan products are included when no subscription rules exist.
  • Refactors Subscriptions_Tiers to separate product resolution (resolve_purchasable_products) from frequency grouping (get_products_by_frequency), and adds support for receiving an array of products in get_tiers() and render_form().
  • Introduces render_checkout_button() and deferred modal rendering so tiers modals are output in wp_footer outside banner wrappers.
  • Removes the manual cta_product_id setting from the countdown banner and content gifting CTA configuration — the product is now derived automatically from gate access rules.

How to test the changes in this Pull Request:

  1. Set up a content gate with metering and custom access rules that include a simple and a variable subscription.
  2. Enable the metered countdown banner and set the subscribe button action to "Product".
  3. Visit a gated post as a non-logged-in user and verify that the countdown banner appears with a subscribe button that opens a tiers modal with the correct subscription products from the gate's access rules.
  4. Configure a content gate with multiple subscription products across multiple access rule groups — verify the tiers modal shows all unique products, properly grouped by frequency.
  5. Enable WooCommerce Memberships and create a plan with the same restriction rules
  6. Verify the subscribe button resolves the membership plan's products.
  7. Verify the subscribe button still works with the "Landing page" CTA type, redirecting to the configured URL.
  8. Go to the Audience > Content Gates settings — verify the countdown banner and content gifting CTA settings no longer show a product selector when "Product" CTA type is selected, and instead show a help message that the product is automatically set by the access rules.

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?

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

This PR updates Content Gate-related CTAs so “Subscribe” buttons in content banners can dynamically open the appropriate checkout/tiers modal based on the current post’s access rules (instead of a manually selected product ID).

Changes:

  • Removes manual cta_product_id configuration for countdown/content-gifting banners and derives products from gate access rules.
  • Adds a deferred-rendering tiers modal + inline CTA button flow (render button in banner, render modal(s) in wp_footer).
  • Introduces a centralized Content_Gate::get_gate_access_product_ids() API (and filter) to resolve access product IDs, including a Memberships integration.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/wizards/audience/views/setup/countdown-banner.js Removes product picker UI and updates CTA help/preview logic for dynamic product selection.
src/wizards/audience/views/setup/content-gifting.js Removes product picker UI and updates CTA help/preview logic for dynamic product selection.
src/content-gate/content-banner.js Adds click handling to open deferred tiers modals from banner CTA buttons.
includes/wizards/audience/class-audience-wizard.php Stops persisting cta_product_id for content gifting settings.
includes/wizards/audience/class-audience-content-gates.php Removes cta_product_id from REST endpoint args and update handlers.
includes/plugins/woocommerce-subscriptions/class-subscriptions-tiers.php Adds product-resolution helpers, deferred modal rendering, and a new checkout-button renderer.
includes/plugins/wc-memberships/class-memberships.php Supplies access product IDs via the new newspack_gate_access_product_ids filter when Memberships restrict content.
includes/content-gate/content-gifting/class-content-gifting.php Removes cta_product_id from content gifting settings payload.
includes/content-gate/content-gifting/class-content-gifting-cta.php Uses gate access product IDs to render a dynamic checkout CTA (no hardcoded product).
includes/content-gate/class-metering-countdown.php Uses gate access product IDs to render a dynamic checkout CTA (no hardcoded product).
includes/content-gate/class-content-gate.php Introduces get_gate_access_product_ids() to extract subscription product IDs from access rules and expose a filter hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wizards/audience/views/setup/countdown-banner.js
Comment thread src/wizards/audience/views/setup/content-gifting.js
Comment thread includes/plugins/woocommerce-subscriptions/class-subscriptions-tiers.php Outdated
Comment thread includes/content-gate/class-content-gate.php
@miguelpeixe miguelpeixe self-assigned this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants