Skip to content

Show auction products in the vendor product list - #3327

Merged
MdAsifHossainNadim merged 4 commits into
developfrom
enhance/auction-products-in-product-list
Jul 21, 2026
Merged

Show auction products in the vendor product list#3327
MdAsifHossainNadim merged 4 commits into
developfrom
enhance/auction-products-in-product-list

Conversation

@akzmoudud

@akzmoudud akzmoudud commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s)

Closes

  • Closes getdokan/plugin-internal-tasks#2184

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:

  1. include_types request param — a new get_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 send include_types (the manual-order product picker, the legacy editor page) keep excluding those types exactly as before.
  2. dokan_product_list_include_types JS filter — the product list (and its summary request) build include_types from this filter, so a Pro module opts its type in client-side. Scoped to this list only.
  3. dokan_product_list_type_options JS 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) and type_options (so it appears in the Product Type dropdown). The coupling is documented inline.

No default behaviour changes: with no include_types in the request, array_diff removes nothing and every listing stays exactly as it was.

Related Pull Request(s)

How to test the changes in this Pull Request:

  1. With the Simple Auction module active, log in as a vendor and open Vendor Dashboard → Products.
  2. Auction products now appear in the list alongside other products (previously hidden).
  3. Open the Product Type filter → Auction is now an option; selecting it shows only the vendor's auctions.
  4. Open Vendor Dashboard → Orders → Add order → Add products (manual order picker) — auctions are not listed there (that request doesn't opt them in), so orders still can't be hand-created from an auction.

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

  • Bug Fixes
    • Product listings, status/summary badges, and related queries now use the same excluded product types, keeping the table and counts in sync.
  • Improvements
    • The “Product Type” filter now derives its available options from the configured option set, updating reliably when options change.
  • New Features
    • When creating a new product, the editor can now preselect the product type from the incoming request.
    • The product editor can also request field data using an optional type hint from the current URL hash.

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>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5854e37b-a3f8-44e2-bf69-a97e62eb91ee

📥 Commits

Reviewing files that changed from the base of the PR and between fda5e1a and 2b7f924.

📒 Files selected for processing (2)
  • includes/REST/ProductControllerV3.php
  • src/dashboard/product-editor/App.tsx

📝 Walkthrough

Walkthrough

Product 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.

Changes

Product type filtering

Layer / File(s) Summary
Centralize REST exclusion rules
includes/REST/ProductController.php
Product summaries and queries accept request-provided exclusions through get_exclude_types(), with auction and booking defaults.
Filter configurable product types
src/dashboard/products/ProductList.tsx
The product type selector derives options through dokan_product_list_type_options and updates when those options change.
Pass excluded types to listing APIs
src/dashboard/products/hooks/useProducts.ts
Product and summary requests include exclusions from dokan_product_list_exclude_types.
Preselect new product types
src/dashboard/product-editor/App.tsx, includes/REST/ProductControllerV3.php
The editor forwards a requested type, and new product fields preselect it after WooCommerce type validation.

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
Loading

Possibly related PRs

  • getdokan/dokan#2817: Both changes modify how REST product listing exclusions are derived from request or filter inputs.

Suggested reviewers: mrabbani, mdasifhossainnadim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: showing auction products in the vendor product list.
Description check ✅ Passed The description covers the required change summary, related PR, testing steps, and changelog entry, matching the template well.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enhance/auction-products-in-product-list

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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>
@mrabbani mrabbani added Needs: Testing This requires further testing Dev Review Done labels Jul 20, 2026
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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 90441ca and 01e3bef.

📒 Files selected for processing (3)
  • includes/REST/ProductController.php
  • src/dashboard/products/ProductList.tsx
  • src/dashboard/products/hooks/useProducts.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/dashboard/products/ProductList.tsx

Comment on lines +603 to +611
$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' ];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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-L109
  • src/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.

@dev-shahed dev-shahed added 🎉 QA Approved This PR is approved by the QA team and removed Needs: Testing This requires further testing labels Jul 20, 2026
@akzmoudud akzmoudud self-assigned this Jul 20, 2026
"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>
@MdAsifHossainNadim
MdAsifHossainNadim merged commit f430ee2 into develop Jul 21, 2026
16 of 17 checks passed
@MdAsifHossainNadim
MdAsifHossainNadim deleted the enhance/auction-products-in-product-list branch July 21, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dev Review Done 🎉 QA Approved This PR is approved by the QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants