-
Notifications
You must be signed in to change notification settings - Fork 213
fix: Admin reports order data not reflecting after updated the orders data. #2754
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: Admin reports order data not reflecting after updated the orders data. #2754
Conversation
…in the setup guide.
""" WalkthroughThe changes introduce an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Admin
participant WooCommerce
participant VendorBalanceUpdateHandler
participant Commission
participant DB
participant Cache
Admin->>WooCommerce: Edit order total
WooCommerce->>VendorBalanceUpdateHandler: Trigger update_dokan_order_table(order_id)
VendorBalanceUpdateHandler->>Commission: get_earning_from_order_table(order_id, 'seller', true)
Commission->>DB: Fetch order earning data
Commission-->>VendorBalanceUpdateHandler: Return {net_amount, order_total}
VendorBalanceUpdateHandler->>DB: Update dokan_orders table with new values if changed
VendorBalanceUpdateHandler->>Cache: Delete cache for order_id + "_true"
Cache->>VendorBalanceUpdateHandler: Trigger dokan_cache_deleted action
VendorBalanceUpdateHandler->>Cache: Remove raw cache variant
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
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. 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 8000 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: 0
🧹 Nitpick comments (1)
includes/Commission.php (1)
326-327
: Use wp_json_encode() instead of json_encode() for WordPress standards.WordPress coding standards recommend using
wp_json_encode()
instead ofjson_encode()
for better compatibility and error handling.Apply this diff to follow WordPress coding standards:
- $raw_key = json_encode( $raw ); + $raw_key = wp_json_encode( $raw );🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[warning] 326-326:
json_encode() is discouraged. Use wp_json_encode() instead.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
includes/Commission.php
(2 hunks)includes/Order/VendorBalanceUpdateHandler.php
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: Run PHPCS inspection
includes/Commission.php
[warning] 326-326:
json_encode() is discouraged. Use wp_json_encode() instead.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: e2e tests (3, 3)
- GitHub Check: e2e tests (2, 3)
- GitHub Check: api tests (1, 1)
- GitHub Check: e2e tests (1, 3)
🔇 Additional comments (6)
includes/Order/VendorBalanceUpdateHandler.php (4)
158-158
: LGTM: Proper type casting.Explicit float casting ensures type consistency and prevents potential type-related issues in calculations.
164-167
: LGTM: Enhanced data retrieval with proper type safety.The changes correctly utilize the new
$raw
parameter to retrieve detailed earning data as an array, with proper float casting for bothnet_amount
andorder_total
. The order totals calculation is also properly cast to float for consistency.
172-172
: LGTM: Improved conditional logic.The enhanced conditional check now compares both order total and net earning, providing more accurate validation before skipping the database update. This should help ensure admin reports reflect the actual order state.
191-191
: LGTM: Cache key consistency.The cache deletion key correctly includes the "_true" suffix to match the updated cache key format that incorporates the
$raw
parameter.includes/Commission.php (2)
321-323
: LGTM: Well-designed API enhancement.The addition of the optional
$raw
parameter with a default value offalse
maintains backward compatibility while enabling new functionality. The updated return type annotation correctly reflects that the method can now return either a float or an array.
345-352
: LGTM: Clean conditional logic implementation.The conditional logic properly handles both the raw array return (with explicit float casting) and the legacy calculated value return based on context. The implementation maintains the existing behavior when
$raw
is false while providing the new detailed data when$raw
is true.
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
includes/Commission.php
(2 hunks)includes/Order/VendorBalanceUpdateHandler.php
(3 hunks)includes/Traits/ObjectCache.php
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- includes/Order/VendorBalanceUpdateHandler.php
🧰 Additional context used
🪛 GitHub Check: Run PHPCS inspection
includes/Commission.php
[failure] 330-330:
Expected 1 space after ":"; 2 found
🪛 GitHub Actions: Inspections
includes/Commission.php
[error] 1-1: PHP CodeSniffer: Expected 1 space after ":"; 2 found.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: e2e tests (3, 3)
- GitHub Check: e2e tests (1, 3)
- GitHub Check: e2e tests (2, 3)
- GitHub Check: api tests (1, 1)
🔇 Additional comments (3)
includes/Traits/ObjectCache.php (1)
133-146
: LGTM! Well-designed cache deletion notification.The implementation correctly maintains the original method behavior while adding a useful notification mechanism. The action hook
dokan_cache_deleted
provides a clean way for other components to react to cache deletions without modifying core logic.includes/Commission.php (2)
320-324
: Excellent enhancement for raw data retrieval.The addition of the
$raw
parameter is well-implemented:
- Maintains backward compatibility with default parameter value
- Proper separation of cache keys for raw vs computed data
- Correct calculation logic using the raw earning array
- Good use of filter hooks for extensibility
The functionality will enable more detailed analysis of earning data while preserving existing behavior.
Also applies to: 346-373
327-331
: Efficient dual caching strategy.The separate cache keys for raw and computed data (
cache_key
andcache_key_raw
) is an excellent approach that:
- Eliminates redundant database queries
- Provides flexible data access patterns
- Integrates well with the cache deletion notification system
The cache population strategy ensures both variants are available after a single database query.
Also applies to: 355-356
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 330-330:
Expected 1 space after ":"; 2 found
…oved data handling
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
fix: Admin reports was not reflecting after orders data was updated.
Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.
Before Changes
Describe the issue before changes with screenshots(s).
After Changes
Describe the issue after changes with screenshot(s).
Feature Video (optional)
Link of detailed video if this PR is for a feature.
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
Bug Fixes
Chores