-
Notifications
You must be signed in to change notification settings - Fork 152
fix: show recurring and trial info on subscription #1549
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
fix: show recurring and trial info on subscription #1549
Conversation
WalkthroughThis update standardizes the use of meta keys related to trial duration and recurring payment options throughout the subscription-related classes and templates. It replaces direct string comparisons for recurring payment checks with a helper function for improved robustness and changes key references from non-underscored to underscored versions for trial-related metadata. Additionally, conditional logic for displaying featured items and post counts in subscription templates is refined, and a debug log statement is added for recurring payment checks in the frontend account logic. Changes
Assessment against linked issues
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
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:
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)
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: 2
🧹 Nitpick comments (1)
templates/dashboard/subscription.php (1)
16-16: Refine the featured item display condition.The condition now ensures that the featured item count is only shown when it's unlimited (-1). This provides better clarity for users when viewing their subscription details.
Note: There's a small formatting issue with the indentation that should be fixed.
- if ( ! empty( $user_sub['total_feature_item'] ) && -1 === $user_sub['total_feature_item'] ) { ?> + if ( ! empty( $user_sub['total_feature_item'] ) && -1 === $user_sub['total_feature_item'] ) { ?>🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 16-16:
Closing PHP tag must be on a line by itself
[failure] 16-16:
Line indented incorrectly; expected 3 tabs, found 3 tabs and 1 spaces
[warning] 16-16:
Found precision alignment of 1 spaces.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
class/subscription.php(2 hunks)includes/Admin/Subscription.php(2 hunks)includes/Frontend/Frontend_Account.php(1 hunks)templates/dashboard/subscription.php(2 hunks)templates/subscriptions/pack-details.php(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
templates/subscriptions/pack-details.php (1)
wpuf-functions.php (1)
wpuf_is_checkbox_or_toggle_on(5445-5447)
includes/Admin/Subscription.php (2)
class/subscription.php (1)
get_cycle_label(914-923)wpuf-functions.php (1)
wpuf_is_checkbox_or_toggle_on(5445-5447)
class/subscription.php (1)
includes/Admin/Subscription.php (1)
get_cycle_label(935-944)
🪛 GitHub Check: Run PHPCS inspection
templates/dashboard/subscription.php
[failure] 16-16:
Closing PHP tag must be on a line by itself
[failure] 16-16:
Line indented incorrectly; expected 3 tabs, found 3 tabs and 1 spaces
[warning] 16-16:
Found precision alignment of 1 spaces.
🪛 GitHub Actions: Inspections
class/subscription.php
[error] 1-1: PHP CodeSniffer: Expected 1 space after opening PHP tag; 2 found.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (8)
templates/dashboard/subscription.php (1)
27-27: Improved skip condition for post counts.The condition now properly skips both zero and unlimited (-1) post counts when iterating through the available posts. This is a logical improvement since both values should be treated similarly in the display context.
templates/subscriptions/pack-details.php (2)
18-18: Code cleanup: Removed trailing space in h3 tag.This is a minor but welcome formatting improvement.
31-31: Enhanced recurring payment check using helper function.Replacing the direct string comparison with
wpuf_is_checkbox_or_toggle_on()makes the code more robust by handling various representations of "on" states ('yes', 'on', 'true', '1'). This standardizes how checkbox values are evaluated throughout the application.includes/Frontend/Frontend_Account.php (3)
230-231: Enhanced recurring payment check with debug logging.The code now uses the
wpuf_is_checkbox_or_toggle_on()helper function instead of a direct string comparison for better robustness. The added debug logging will be helpful for troubleshooting subscription-related issues.
237-237: Updated meta key to use standardized format.The meta key for trial duration type has been updated to use the underscored format (
_trial_duration_type), which aligns with WordPress conventions for private meta keys and ensures consistency across the codebase.
239-241: Refined billing limit display condition.The condition for appending the billing limit description has been improved to only display when the billing limit is not empty and equals -1 (unlimited). This makes the display logic more precise and prevents potential confusion in the UI.
class/subscription.php (2)
394-394: Updated trial duration type meta key to use standardized format.The code now uses the underscored version of the meta key (
_trial_duration_type) which is consistent with the changes in other files and follows WordPress conventions for private meta keys.
958-958: Consistent usage of underscored meta key format.The code correctly uses the
_trial_duration_typemeta key in the recurring description formatting, which aligns with the standardization of meta keys across the codebase.
| if ( $billing_amount && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['recurring_pay'] ) && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['_trial_status'] ) ) { | ||
| //phpcs:ignore | ||
| $duration = _n( $pack->meta_value['trial_duration_type'], $pack->meta_value['trial_duration_type'] . 's', $pack->meta_value['trial_duration'], 'wp-user-frontend' ); | ||
| $duration = _n( $pack->meta_value['_trial_duration_type'], $pack->meta_value['_trial_duration_type'] . 's', $pack->meta_value['_trial_duration'], 'wp-user-frontend' ); | ||
| /* translators: %s: trial days */ | ||
| $trial_des = sprintf( __( 'Trial available for first %1$s %2$s', 'wp-user-frontend' ), $pack->meta_value['trial_duration'], $duration ); | ||
| $trial_des = sprintf( __( 'Trial available for first %1$s %2$s', 'wp-user-frontend' ), $pack->meta_value['_trial_duration'], $duration ); |
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.
🛠️ Refactor suggestion
Standardized trial metadata handling
This change improves code consistency in two ways:
- Uses
wpuf_is_checkbox_or_toggle_on()for both recurring payment and trial status checks - Properly references underscored trial metadata keys (
_trial_duration_type) which aligns with the metadata storage approach throughout the codebase
This standardization helps prevent potential bugs from inconsistent meta key references.
|
Wrong info showing @sapayth vai |
please have a look now |


fixes #724 fixes #723
Summary by CodeRabbit