Skip to content

gpnf-hide-quantity-in-summary-field-values.php: Added snippet to hide quantity from GPNF summary field values. #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2929910662/83058

Summary

To remove the quantity from the product data which is display on the Nested Forms Summary table.

The snippet is language independent!

Deutsch:
Screenshot 2025-05-10 at 12 00 08 AM

English:
Screenshot 2025-05-10 at 12 00 23 AM

…de quantity from GPNF summary field values.
Copy link

coderabbitai bot commented May 9, 2025

Walkthrough

A new PHP snippet was added to customize the display of product field values in Gravity Perks Nested Forms. The code hooks into the gpnf_display_value filter to remove the quantity portion from product field labels in summary fields, leaving only the label and price visible.

Changes

File(s) Change Summary
gp-nested-forms/gpnf-hide-quantity-in-summary-field-values.php Added a PHP snippet that filters the display value of product fields to hide the quantity in summary fields.

Sequence Diagram(s)

sequenceDiagram
    participant GravityForms
    participant GPNFPlugin
    participant CustomSnippet

    GravityForms->>GPNFPlugin: Render Nested Form Summary
    GPNFPlugin->>CustomSnippet: Apply gpnf_display_value filter
    CustomSnippet->>CustomSnippet: Check if field type is 'product'
    alt Field is product
        CustomSnippet->>CustomSnippet: Remove quantity from display value
    else Field is not product
        CustomSnippet->>CustomSnippet: Return original display value
    end
    CustomSnippet-->>GPNFPlugin: Return modified display value
    GPNFPlugin-->>GravityForms: Display summary with updated product label
Loading

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented May 9, 2025

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

Generated by 🚫 dangerJS against c8cf326

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-nested-forms/gpnf-hide-quantity-in-summary-field-values.php (1)

8-13: Consider using strict comparison operator.

The conditional check ensures only product fields are affected, which is appropriate. However, consider using the strict comparison operator !== instead of != for better type safety.

-	if ( $field->type != 'product' ) {
+	if ( $field->type !== 'product' ) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3aaf75b and c8cf326.

📒 Files selected for processing (1)
  • gp-nested-forms/gpnf-hide-quantity-in-summary-field-values.php (1 hunks)
🔇 Additional comments (3)
gp-nested-forms/gpnf-hide-quantity-in-summary-field-values.php (3)

1-7: Well-documented snippet purpose and functionality.

The file header clearly explains what the snippet does and includes a link to the relevant documentation. This makes it easy for users to understand the purpose and context of this code.


14-14: Verify regex robustness for all product label formats.

The regex pattern removes the middle portion (quantity) from "Label, Quantity, Price". This works as long as the product labels don't contain commas themselves. If product labels could contain commas, this regex might remove too much content.

Consider testing with product labels that contain commas to ensure the regex behaves as expected. If needed, a more specific pattern that targets numeric quantities might be more robust.


8-17: Good solution that addresses the specific requirement.

The implementation effectively removes the quantity portion from product field display values in the Nested Forms summary, as requested in the PR objective. The approach is clean and focused on the specific problem.

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.

1 participant