Skip to content

Conversation

@SebastianWiz
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3130050786/92261?viewId=3808239

Summary

Added a new snippet that filters GPLS to count only entries with payment status Paid. This prevents failed or pending payments from blocking resubmissions while still enforcing limits after a successful payment.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

A new PHP hook file for Gravity Perks: Limit Submissions is added. The hook intercepts queries before execution, applies a form-specific filter for Form ID 123, and appends WHERE clause logic to count only paid or unset payment statuses. A static cache prevents reprocessing the same rule instance.

Changes

Cohort / File(s) Change Summary
New Hook Implementation
gp-limit-submissions/gpls-limit-by-paid-entries-only.php
Adds a new hook handler for gpls_before_query that filters entries by payment status, extends query logic to include only paid or null/empty payment statuses, and implements static caching to prevent duplicate rule processing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file addition with focused, clear purpose
  • Moderate logic complexity involving static caching and query manipulation—requires familiarity with Gravity Perks hooks and patterns
  • Pay special attention to:
    • The static cache pattern and its effectiveness in preventing rule reprocessing
    • The WHERE clause logic and its correctness for payment status filtering
    • Integration with the gpls_before_query hook and form filter application

Suggested reviewers

  • saifsultanc

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a new PHP snippet for limiting Gravity Perks submissions by paid entries only, matching the file addition and PR objectives.
Description check ✅ Passed The description includes both required sections (Context with ticket link and Summary explaining the change), though it lacks optional Notion and Slack references.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch SebastianWiz-patch-3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Fails
🚫

Commit message 'gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only' needs to end in a period or exclamation.

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 41f01ef

@SebastianWiz SebastianWiz changed the title gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only. Nov 6, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
gp-limit-submissions/gpls-limit-by-paid-entries-only.php (1)

24-24: No changes required; code is correct as-is.

The payment status value 'Paid' with capital P is correct per Gravity Forms documentation which lists "Paid" as a valid entry payment status. The logic correctly includes NULL and empty statuses to support forms without payment fields while filtering out failed/pending entries. This pattern is consistent throughout the codebase.

The WHERE clause array approach matches the established pattern used elsewhere in the repository (e.g., gravity-forms/gw-inventory.php).

Optional: Consider adding an inline comment for clarity:

+	// Include NULL/empty to allow forms without payment fields while excluding Failed/Pending statuses
 	$ruletest->where[] = "( e.payment_status = 'Paid' OR e.payment_status IS NULL OR e.payment_status = '' )";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3324f97 and 41f01ef.

📒 Files selected for processing (1)
  • gp-limit-submissions/gpls-limit-by-paid-entries-only.php (1 hunks)
🔇 Additional comments (4)
gp-limit-submissions/gpls-limit-by-paid-entries-only.php (4)

1-7: LGTM! Clear documentation.

The documentation clearly explains the snippet's purpose and use case.


10-15: Excellent form filtering implementation.

The logic correctly handles both targeted filtering (specific form IDs) and universal application (empty array), with proper type safety using intval and strict comparison.


17-22: Good use of static caching to prevent reprocessing.

Using spl_object_hash with a static cache is an appropriate pattern to ensure each rule instance is only processed once per request.


26-26: Caching pattern correctly completed.

The processed flag is set after the WHERE clause modification, completing the static cache pattern.

Copy link
Contributor

@saifsultanc saifsultanc left a comment

Choose a reason for hiding this comment

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

LGTM!

@SebastianWiz SebastianWiz merged commit e502a8c into master Nov 6, 2025
4 of 5 checks passed
@SebastianWiz SebastianWiz deleted the SebastianWiz-patch-3 branch November 6, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants