Skip to content

Conversation

@SebastianWiz
Copy link
Contributor

Context

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

Summary

This PR fixes an issue where the "Populate Days into Radio Field" snippet only displayed the available inventory text when previewing the form. The issue happened because Gravity Forms 2.9+ now calls the global gform_pre_render before the form-specific hook on the frontend, so the snippet ended up overwriting GP Inventory’s “available” text.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Converted Gravity Forms hooks from form-specific to generic and added a form ID check within the callback to limit execution to form 123. Existing population logic remains unchanged for the targeted radio field.

Changes

Cohort / File(s) Summary of Changes
Gravity Forms hook scope adjustment
gp-inventory/gpi-populate-days.php
Replaced gform_pre_render_123/gform_pre_validation_123 with gform_pre_render/gform_pre_validation; added early-return guard to only process when form.id === 123; retained existing radio field population logic.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GF as Gravity Forms
    participant Hook as gform_pre_render / pre_validation
    participant Func as gw_populate_days_into_radio

    GF->>Hook: Trigger on form render/validation
    Hook->>Func: Pass current form
    alt form.id != 123
        Func-->>Hook: Return form unchanged
    else form.id == 123
        Func->>Func: Locate radio field and populate choices
        Func-->>Hook: Return modified form
    end
    Hook-->>GF: Provide final form
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • saifsultanc
  • veryspry

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
Description Check ✅ Passed The pull request description adheres to the repository template by including a Context section with the relevant ticket link and a Summary section that clearly explains the root cause and the resolution of the issue. It provides sufficient background and details to understand the change without omitting any required sections.
Title Check ✅ Passed The title clearly summarizes the primary fix—resolving the issue where inventory availability only appeared in the form preview—and directly relates to the changes in gpi-populate-days.php without including unnecessary details.
✨ 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 seb/fix/90355-gpi-snippet-global-pre-render

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 Oct 8, 2025

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

Generated by 🚫 dangerJS against 1b00479

@saifsultanc saifsultanc changed the title gpi-populate-days.php: Fixed an issue where availabile inventory only displayed when previewing the form. gpi-populate-days.php: Fixed an issue where available inventory only displayed when previewing the form. Oct 16, 2025
@saifsultanc saifsultanc merged commit cb06fa4 into master Oct 16, 2025
4 of 5 checks passed
@saifsultanc saifsultanc deleted the seb/fix/90355-gpi-snippet-global-pre-render branch October 16, 2025 07:15
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