Enhance: include auction products in the vendor product list counts#3277
Enhance: include auction products in the vendor product list counts#3277akzmoudud wants to merge 6 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR refines product type handling across three areas. Backend removes ChangesAuction module integration with product form manager
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The product list summary hardcoded `[ 'booking', 'auction' ]` as excluded product types, so auction products were left out of the status-tab counts even when they appear in the list. Remove only `auction` from that list so auctions are counted consistently with the list contents; `booking` stays excluded as before.
e81646e to
4cb9e7e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
includes/REST/ProductController.php (1)
564-571:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove the remaining hardcoded
bookingexclusion to fully sync counts with listing.Line 567 still hardcodes
booking, but the listing query path uses onlydokan_product_listing_exclude_type; this can reintroduce count/list drift if filter output changes.Suggested fix
- $exclude_types = array_values( - array_unique( - array_merge( - [ 'booking' ], - (array) apply_filters( 'dokan_product_listing_exclude_type', [] ) - ) - ) - ); + $exclude_types = array_values( + array_unique( + (array) apply_filters( 'dokan_product_listing_exclude_type', [] ) + ) + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@includes/REST/ProductController.php` around lines 564 - 571, Remove the hardcoded 'booking' value from the array_merge() call in the exclude_types variable within ProductController. Instead of merging a hardcoded array containing 'booking' with the filter result from dokan_product_listing_exclude_type, use only the filter result to ensure the product count logic stays synchronized with the product listing query logic that relies solely on the same filter.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@includes/REST/ProductController.php`:
- Around line 564-571: Remove the hardcoded 'booking' value from the
array_merge() call in the exclude_types variable within ProductController.
Instead of merging a hardcoded array containing 'booking' with the filter result
from dokan_product_listing_exclude_type, use only the filter result to ensure
the product count logic stays synchronized with the product listing query logic
that relies solely on the same filter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8eaa2081-9ed4-4b65-b15b-e4ec005f8e02
📒 Files selected for processing (1)
includes/REST/ProductController.php
- init_form_fields() honors a `?type=` param for brand-new products, validated against the editor's registered product types, and sets the Product Type field accordingly. - The product editor forwards the URL's `?type=` to the init/fields request on create, so links like /products/create?type=auction open with that type selected.
- Localize the editor's registered product types so the list's Product Type
filter offers module-registered types (e.g. auction) only when active.
- Render auction rows with their own type icon, in-stock state, and price markup
("Starting bid: ..."), matching the dedicated auction list; other types unchanged.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/dashboard/products/ProductList.tsx`:
- Around line 347-361: The issue is that the early return checking `!item.price`
executes before the auction-specific logic that renders `price_html`, causing
auction items with empty `price` but valid `price_html` to incorrectly display
'—' instead of the intended auction markup. Reorder the conditions so the
auction check (verifying `item.type === 'auction' && item.price_html`) executes
first, before the empty price return statement. This ensures auction items with
price_html will properly render their markup even when the price field is empty.
- Around line 353-359: The span element using dangerouslySetInnerHTML with
item.price_html is injecting unsanitized HTML content, which poses a security
risk. Import the sanitizeHTML utility from '`@src/utilities`' at the top of the
ProductList.tsx file, then wrap the item.price_html value with the sanitizeHTML
function when passing it to the dangerouslySetInnerHTML prop to ensure the HTML
is properly sanitized before rendering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8a17781e-8ff2-4de9-8f64-6864d0175e19
📒 Files selected for processing (4)
includes/Assets.phpincludes/REST/ProductControllerV3.phpsrc/dashboard/product-editor/App.tsxsrc/dashboard/products/ProductList.tsx
Drop the auction-specific type label, Gavel icon, stock cell, and price-cell branches from ProductList.tsx. Auction rows are now rendered by the Pro auction module through the existing `dokan_product_list_table_fields` filter, so dokan-lite no longer references the Pro-only `auction` product type. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the manual query-string concatenation (and encodeURIComponent) for the product-editor init request with `@wordpress/url`'s `addQueryArgs`, matching how the rest of dokan-lite builds apiFetch paths. Behavior is unchanged: `?id=` for new products and an optional, auto-encoded `type` hint when present. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Expand the inline comment in get_product_summary() to explain that `booking` is a deliberate defensive default (so booking products never inflate the regular product counts), redundant with the Booking module's own filter handler while that module is active, and that all other module-owned types opt out through the shared `dokan_product_listing_exclude_type` filter — the same scope the list query uses. Prevents this from being re-flagged as count drift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
discussed with mahbub bhai and anik bhai removing need discussion. Docs maybe needed |
All Submissions:
Changes proposed in this Pull Request:
The vendor product list summary (
get_product_summary) hardcoded[ 'booking', 'auction' ]as excluded product types when building the status-tab counts. With the Auction module now integrated into the new product editor and surfaced in the product list, that hardcode left auction products out of the tab counts — so the list could show auctions while "All (N)" / status counts didn't include them.This removes
auctionfrom the hardcoded list so its exclusion now comes from thedokan_product_listing_exclude_typefilter — the same filter the list query (prepare_objects_query) uses — keeping list contents and tab counts in sync for auction. Pro modules that own a separate dashboard (booking, subscription, …) register their own types through that filter; auction simply stops opting itself out.bookingis intentionally kept in the hardcoded default (not a drift bug): booking products have always been a separate dashboard concept and must never inflate the regular product counts. The Booking module also addsbookingthrough the filter, so the hardcode is redundant while that module is active and only matters in the edge case where booking products exist but the module (and thus its filter handler) is inactive.Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
/dashboard/new/#/products/).Changelog entry
Enhance: include auction products in the vendor product list counts
The product list summary no longer hardcodes
auctionas an excluded type, so auction products (now managed via the new product editor) are counted consistently with the list contents.bookingremains excluded as before (a deliberate defensive default).PR Self Review Checklist:
Summary by CodeRabbit