-
Notifications
You must be signed in to change notification settings - Fork 93
gpi-show-inventory-only-for-logged-in-users.php
: Added snippet to show available inventory message only for logged in user.
#1153
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
Conversation
…how available inventory only for logged in user.
Caution Review failedThe pull request is closed. WalkthroughAdds a PHP module that filters Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
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 detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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.
📒 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.
confirmed by customer |
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