Skip to content

Conversation

saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3048324137/88279/

Summary

Show Inventory Only For Logged In users only.

https://www.loom.com/share/2d9843302a54456987ed2c66a83612ba

…how available inventory only for logged in user.
Copy link

coderabbitai bot commented Aug 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a PHP module that filters gpi_inventory_available_message so the inventory-available message is shown only to logged-in users and suppressed for guests.

Changes

Cohort / File(s) Summary
Inventory message access control
gp-inventory/gpi-show-inventory-only-for-logged-in-users.php
Adds a filter on gpi_inventory_available_message with callback function( $message ) that returns $message when is_user_logged_in() is true, otherwise returns an empty string. Includes docblock metadata and links.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Visitor
  participant WP as WordPress
  participant GPI as GP Inventory
  participant Filter as Access Control Filter

  Note over Visitor,WP: Render product page
  WP->>GPI: request inventory message
  GPI->>Filter: apply gpi_inventory_available_message(message)
  alt user logged in
    Filter-->>GPI: return original message
    GPI-->>WP: message
    WP-->>Visitor: page with inventory message
  else guest (not logged in)
    Filter-->>GPI: return empty string
    GPI-->>WP: empty message
    WP-->>Visitor: page without inventory message
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • veryspry

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fa9e185 and b6ad84b.

📒 Files selected for processing (1)
  • gp-inventory/gpi-show-inventory-only-for-logged-in-users.php (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch saif/add/88279-hide-available-inventory-message-for-logged-in-user

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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit 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:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

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

Generated by 🚫 dangerJS against fa9e185

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: 1

🧹 Nitpick comments (2)
gp-inventory/gpi-show-inventory-only-for-logged-in-users.php (2)

3-10: Polish docblock wording and capitalization (optional).

Improves clarity and consistency (e.g., “Logged-in Users”).

- * Gravity Perks // Inventory // Show Inventory Only For Logged In users
+ * Gravity Perks // Inventory // Show Inventory Only for Logged-in Users
@@
- * By default the inventory available is shown for everyone, if enabled.
- * Use this filter to show the inventory available only for logged in users.
+ * By default, the available inventory message is shown to everyone (when enabled).
+ * Use this filter to show the available inventory only to logged-in users.

11-16: Optional: be explicit about accepted args and simplify the callback.

No behavior change; just clarity.

-add_filter( 'gpi_inventory_available_message', function( $message ) {
-	if ( is_user_logged_in() ) {
-		return $message;
-	}
-	return '';
-} );
+add_filter( 'gpi_inventory_available_message', function( $message ) {
+	return is_user_logged_in() ? $message : '';
+}, 10, 1 );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0bdeec1 and fa9e185.

📒 Files selected for processing (1)
  • gp-inventory/gpi-show-inventory-only-for-logged-in-users.php (1 hunks)
🧰 Additional context used
🪛 GitHub Check: PHPCS (Files Changed)
gp-inventory/gpi-show-inventory-only-for-logged-in-users.php

[failure] 5-5:
Whitespace found at end of line

🪛 GitHub Actions: PHP Lint (PR)
gp-inventory/gpi-show-inventory-only-for-logged-in-users.php

[error] 5-5: PHPCS: Whitespace found at end of line. (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine)

🔇 Additional comments (2)
gp-inventory/gpi-show-inventory-only-for-logged-in-users.php (2)

11-16: LGTM: Correctly hides available-inventory message for guests.

Behavior matches the PR objective.


11-16: Filter signature confirmed: no change required
The gpi_inventory_available_message filter passes only $message (accepted_args = 1), matching the default add_filter signature. No updates needed.

…how available inventory only for logged in user.
@saifsultanc
Copy link
Contributor Author

confirmed by customer

@saifsultanc saifsultanc merged commit 57b61dd into master Aug 29, 2025
0 of 3 checks passed
@saifsultanc saifsultanc deleted the saif/add/88279-hide-available-inventory-message-for-logged-in-user branch August 29, 2025 06:16
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