Skip to content

Enhance: include auction products in the vendor product list counts#3277

Open
akzmoudud wants to merge 6 commits into
developfrom
enhance/show-auction-in-product-list
Open

Enhance: include auction products in the vendor product list counts#3277
akzmoudud wants to merge 6 commits into
developfrom
enhance/show-auction-in-product-list

Conversation

@akzmoudud

@akzmoudud akzmoudud commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation

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 auction from the hardcoded list so its exclusion now comes from the dokan_product_listing_exclude_type filter — 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.

booking is 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 adds booking through 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.

-        // Match the list's exclusion scope so tab counts can't drift from it —
-        // Pro modules add `product_pack` etc. via this filter.
-        $exclude_types = array_values(
-            array_unique(
-                array_merge(
-                    [ 'booking', 'auction' ],
-                    (array) apply_filters( 'dokan_product_listing_exclude_type', [] )
-                )
-            )
-        );
+        // Exclusion scope for the status-tab counts. Module-owned types
+        // (auction, product_pack, …) opt out via the filter — the same filter
+        // the list query uses — so list and counts stay in sync. `booking` is
+        // kept as a deliberate defensive default (see inline comment).
+        $exclude_types = array_values(
+            array_unique(
+                array_merge(
+                    [ 'booking' ],
+                    (array) apply_filters( 'dokan_product_listing_exclude_type', [] )
+                )
+            )
+        );

Related Pull Request(s)

Closes

  • Refs getdokan/plugin-internal-tasks#1883

How to test the changes in this Pull Request:

  1. With the Simple Auction module active (and the linked dokan-pro PR), create at least one auction product.
  2. Go to Vendor Dashboard → Products (/dashboard/new/#/products/).
  3. Confirm auction products appear in the list and are included in the status-tab counts ("All", "Published", etc.) — counts match the visible rows.
  4. Confirm the separate Auction dashboard page still lists auctions correctly (unaffected).

Changelog entry

Enhance: include auction products in the vendor product list counts

The product list summary no longer hardcodes auction as an excluded type, so auction products (now managed via the new product editor) are counted consistently with the list contents. booking remains excluded as before (a deliberate defensive default).

PR Self Review Checklist:

  • Follows code style guidelines (PHPCS clean)
  • Self-explanatory change with updated inline comment
  • No behavior change for booking/subscription (booking still excluded via the kept default + its own filter; subscription via the filter)

Summary by CodeRabbit

  • Improvements
    • Updated the product editor to optionally read a product type hint from the page URL (search or hash) and pre-fill the matching type when creating new products.
    • Enhanced the product listing “Product Type” filter to use backend-provided type options when available, keeping the filter options in sync with configuration.
  • Refactor
    • Updated vendor tab product/stock counting exclusions to default to booking only, then extend with configurable exclusions (deduplicated) for more accurate totals.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR refines product type handling across three areas. Backend removes auction from hardcoded product type exclusions and exposes all available product types to the frontend. The REST API preselection layer accepts a type query parameter and pre-fills the corresponding form schema field. The product editor extracts a type query parameter from the URL and passes it to the form initialization endpoint. The product list UI dynamically configures the product type filter from backend settings instead of a static list.

Changes

Auction module integration with product form manager

Layer / File(s) Summary
Product type registry and API preselection contract
includes/REST/ProductController.php, includes/Assets.php, includes/REST/ProductControllerV3.php
Backend removes auction from hardcoded $exclude_types while merging with dokan_product_listing_exclude_type filter; product types are exposed via dokan()->product_editor->get_product_types() and passed to frontend localization; REST API init_form_fields validates and pre-fills a requested product type parameter when present.
Product editor URL type parameter extraction
src/dashboard/product-editor/App.tsx
App component accepts optional location prop with search, extracts type query parameter from URL (with fallback to hash parsing), and appends it to the form init API request via addQueryArgs; useCallback dependency includes location?.search to rerun on URL changes.
Product list dynamic type filter configuration
src/dashboard/products/ProductList.tsx
ProductListingConfig type extended with optional product_types field; type filter options are sourced from backend product_listing config when available, falling back to built-in PRODUCT_TYPE_OPTIONS; type filter Select component uses dynamic typeOptions and dependency list updated for re-renders when config changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • getdokan/dokan#2817: Both PRs modify REST product listing/count logic by changing how product types are excluded via Dokan filter hooks when computing results for product queries.

Suggested reviewers

  • mrabbani

Poem

🐇 Auction takes flight in the new editor today,
No longer hardcoded to stay locked away!
A URL hint, a pre-filled form field,
With filters now dynamic and backend-revealed—
Vendor dashboards bloom in the modern way! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main change: removing hardcoded auction exclusion to include auction products in vendor product list counts.
Linked Issues check ✅ Passed The PR addresses the foundational filtering mechanism for issue #1883, allowing auction products to appear in the product list and be counted in status tabs—critical infrastructure for the broader editor integration objectives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objectives: removing hardcoded exclusions, adding backend-driven type filtering infrastructure, and updating frontend components to use dynamic product type configurations.
Description check ✅ Passed The pull request description comprehensively covers all required sections: changes proposed, related PRs, issue closure, testing instructions, changelog entry, and self-review checklist with items marked as complete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enhance/show-auction-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.

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.
@akzmoudud akzmoudud force-pushed the enhance/show-auction-in-product-list branch from e81646e to 4cb9e7e Compare June 22, 2026 05:16
@akzmoudud akzmoudud self-assigned this Jun 22, 2026

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

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 win

Remove the remaining hardcoded booking exclusion to fully sync counts with listing.

Line 567 still hardcodes booking, but the listing query path uses only dokan_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

📥 Commits

Reviewing files that changed from the base of the PR and between e81646e and 4cb9e7e.

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cb9e7e and 820b312.

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

Comment thread src/dashboard/products/ProductList.tsx Outdated
Comment thread src/dashboard/products/ProductList.tsx Outdated
akzmoudud and others added 3 commits June 23, 2026 14:34
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>
@akzmoudud akzmoudud added the Needs: Discussion Some decisions are needed for this task to be done label Jun 24, 2026
@akzmoudud

akzmoudud commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

discussed with mahbub bhai and anik bhai removing need discussion. Docs maybe needed

@akzmoudud akzmoudud added Needs: Testing This requires further testing Needs: Dev Review It requires a developer review and approval and removed Needs: Discussion Some decisions are needed for this task to be done labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Dev Review It requires a developer review and approval Needs: Testing This requires further testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant