Show auction products in the vendor product list - #3327
Conversation
The new vendor product list and its status-count summary excluded auction/booking/etc. unconditionally. Add two extension points so a Pro module can surface its own product type here: - `include_types` request param (JS filter `dokan_product_list_include_types`) is subtracted from the default exclusion via a new `get_exclude_types()` helper, shared by the listing query and the summary counts so they can't drift. Requests that don't send it (manual order picker, legacy page) keep excluding those types. - `dokan_product_list_type_options` JS filter makes the "Product Type" filter dropdown extensible so the type can be filtered on. The auction module wires both (see dokan-pro), showing auctions in the vendor product list and its Product Type filter. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughProduct type exclusions are centralized in the REST controller. Dashboard listing and summary requests pass matching exclusions, the type filter uses filtered options, and new product editor fields can be preselected from a requested product type. ChangesProduct type filtering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ProductEditor
participant ProductControllerV3
participant WooCommerce
ProductEditor->>ProductControllerV3: Request fields with type
ProductControllerV3->>WooCommerce: Validate requested product type
WooCommerce-->>ProductControllerV3: Return known product types
ProductControllerV3-->>ProductEditor: Return fields with type preselected
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Replace the include-based opt-in with an `exclude_types` request param: the vendor product list (and its summary) send the types to hide — just `booking`, so auctions show — while other requests send nothing and fall back to the `[ auction, booking ]` default. `get_exclude_types()` returns the request set when present, else that default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a `get_exclude_types_param()` schema (array of slug strings, sanitized with wp_parse_slug_list) and register it on the product listing and summary routes. No `default` is declared on purpose: get_exclude_types() relies on a null param to fall back to the `[ auction, booking ]` default, so a default of `[]` would drop the exclusion for requests that send nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@includes/REST/ProductController.php`:
- Around line 603-611: Update includes/REST/ProductController.php lines 603-611
to return the default exclusions only when exclude_types is null, parse string
values as trimmed comma-separated entries while preserving explicit empty
strings as [], and retain legacy array support. Update
src/dashboard/products/hooks/useProducts.ts lines 106-109 and 182-185 to join
the filtered dokan_product_list_exclude_types result into a comma-separated
string for both listing and summary requests.
🪄 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: cf5434b4-50ef-4a9a-938b-9018d3c0f79c
📒 Files selected for processing (3)
includes/REST/ProductController.phpsrc/dashboard/products/ProductList.tsxsrc/dashboard/products/hooks/useProducts.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/dashboard/products/ProductList.tsx
| $exclude_types = $request->get_param( 'exclude_types' ); | ||
|
|
||
| // Null-check before casting: `(array) null` is `[]`, which would make | ||
| // `??` skip the default and drop the exclusion for requests that send | ||
| // nothing (e.g. the manual order picker). | ||
| return null !== $exclude_types | ||
| ? array_values( (array) $exclude_types ) | ||
| : [ 'auction', 'booking' ]; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Fix empty array omission to allow clearing exclusions.
If a Pro module uses the JS filter to return an empty array (intending to show all product types without exclusions), the @wordpress/url addQueryArgs function will completely omit the empty array from the query string. Consequently, PHP will receive null instead of an empty array and incorrectly fall back to the default ['auction', 'booking'] exclusions.
To reliably transmit an empty exclusion state and correctly separate it from "no parameter sent" (which triggers the fallback), join the array into a comma-separated string on the JS side and parse it on the PHP side.
includes/REST/ProductController.php#L603-L611: Parse the comma-separated string to safely handle both explicitly empty strings and multiple exclusions, while retaining support for legacy array formats:$exclude_types = $request->get_param( 'exclude_types' ); if ( null === $exclude_types ) { return [ 'auction', 'booking' ]; } if ( is_string( $exclude_types ) ) { $exclude_types = empty( trim( $exclude_types ) ) ? [] : array_map( 'trim', explode( ',', $exclude_types ) ); } return array_values( (array) $exclude_types );
src/dashboard/products/hooks/useProducts.ts#L106-L109: Join the filtered array into a comma-separated string for the listing request:exclude_types: ( applyFilters( 'dokan_product_list_exclude_types', [ 'booking' ] ) as string[] ).join( ',' ),
src/dashboard/products/hooks/useProducts.ts#L182-L185: Join the filtered array into a comma-separated string for the summary request:exclude_types: ( applyFilters( 'dokan_product_list_exclude_types', [ 'booking' ] ) as string[] ).join( ',' ),
📍 Affects 2 files
includes/REST/ProductController.php#L603-L611(this comment)src/dashboard/products/hooks/useProducts.ts#L106-L109src/dashboard/products/hooks/useProducts.ts#L182-L185
🤖 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 603 - 611, Update
includes/REST/ProductController.php lines 603-611 to return the default
exclusions only when exclude_types is null, parse string values as trimmed
comma-separated entries while preserving explicit empty strings as [], and
retain legacy array support. Update src/dashboard/products/hooks/useProducts.ts
lines 106-109 and 182-185 to join the filtered dokan_product_list_exclude_types
result into a comma-separated string for both listing and summary requests.
"Add New Auction Product" opens #/products/create?type=auction, but the hint was ignored — the client sent only `id` to init/fields and the server always built a simple product. Read `type` from the hash and preselect that (valid) type on the new product's Product Type field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
All Submissions:
Closes
Changes proposed in this Pull Request:
The new (React) vendor product list and its status-count summary excluded product types that live on their own dashboards (auction, booking, subscription's
product_pack, …) unconditionally — a Pro module had no way to surface its own type here. This PR adds two extension points so it can, without dokan-lite carrying any type-specific code:include_typesrequest param — a newget_exclude_types( $request )helper subtracts whatever the request opts in from the default exclusion (dokan_product_listing_exclude_type). It is the single source shared by both the listing query and the summary counts, so the rows and the tab counts can't drift. Requests that don't sendinclude_types(the manual-order product picker, the legacy editor page) keep excluding those types exactly as before.dokan_product_list_include_typesJS filter — the product list (and its summary request) buildinclude_typesfrom this filter, so a Pro module opts its type in client-side. Scoped to this list only.dokan_product_list_type_optionsJS filter — makes the "Product Type" filter dropdown extensible so the opted-in type can be filtered on.An opted-in type needs both JS filters:
include_types(so its products appear) andtype_options(so it appears in the Product Type dropdown). The coupling is documented inline.No default behaviour changes: with no
include_typesin the request,array_diffremoves nothing and every listing stays exactly as it was.Related Pull Request(s)
How to test the changes in this Pull Request:
Changelog entry
Enhancement: allow Pro product types (e.g. auction) to appear in the vendor product list
Previously the vendor product list and its status counts excluded auction/booking-style product types unconditionally. This adds request-scoped opt-in (
include_types) plus JS filters (dokan_product_list_include_types,dokan_product_list_type_options) so a Pro module can show and filter its own type in the list without changing behaviour for any other listing.🤖 Generated with Claude Code
Summary by CodeRabbit
typehint from the current URL hash.