Skip to content

fix: clear vendor dashboard sale price when the field is blanked#3300

Merged
kzamanbd merged 2 commits into
developfrom
fix/vendor-dashboard-sale-price-not-cleared
Jul 6, 2026
Merged

fix: clear vendor dashboard sale price when the field is blanked#3300
kzamanbd merged 2 commits into
developfrom
fix/vendor-dashboard-sale-price-not-cleared

Conversation

@MdAsifHossainNadim

@MdAsifHossainNadim MdAsifHossainNadim commented Jun 30, 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
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

In the new vendor-dashboard product editor, the price input (PriceEdit) converted its value with Number( rawValue ). When a price field is cleared, rawValue is an empty string and Number( '' ) is 0, so blanking the Sale Price stored and sent sale_price: 0. WooCommerce then saved _sale_price = 0, which marks the product as on sale for 0, and the storefront displayed 0 instead of falling back to the Regular Price.

This PR preserves a cleared price field as an empty string ('') instead of coercing it to 0:

// Keep a cleared field empty, not 0, so blanking it clears the value instead of saving 0.
const value = rawValue === '' ? '' : Number( rawValue );

WooCommerce treats an empty sale_price as "remove the sale price" (set_sale_price( '' )), so the product correctly reverts to its Regular Price. The server-side PayloadResolver already passes an empty string through unchanged, so no backend change is needed. The fix lives in the shared PriceEdit component (used for every price field), so it is generic rather than specific to one field, and touches no global/shared components.

Related Pull Request(s)

  • N/A

Closes

  • Closes getdokan/dokan-pro#5823

How to test the changes in this Pull Request:

  1. As a vendor, open the new dashboard product editor for a simple product.
  2. Set a Regular Price (e.g. 100) and a Sale Price (e.g. 60), then Update.
  3. Edit the product again, clear the Sale Price field (leave it blank), then Update.
  4. Reload the editor — the Sale Price field should be blank (not 0).
  5. Visit the product on the storefront (incognito) — it should show the Regular Price, not 0.

Changelog entry

Fix — Vendor dashboard Sale Price could not be removed once set

Previously, clearing the Sale Price field in the new vendor dashboard product editor saved the sale price as 0 instead of removing it, so the storefront showed the product price as 0. Now, blanking the Sale Price removes it and the product falls back to its Regular Price.

Before Changes

Clearing the Sale Price and saving stored _sale_price = 0; the product stayed "on sale" at 0 and the storefront showed 0 (verified: _sale_price=0, _price=0).

After Changes

Clearing the Sale Price and saving removes _sale_price; the product is no longer on sale and the storefront shows the Regular Price (verified: _sale_price='', _price=100, is_on_sale=no). Setting a Sale Price still works (verified: _sale_price=60, on sale).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Empty price fields now remain blank instead of being automatically changed to 0.
    • Vendor earnings continue to recalculate correctly based on the entered amount, even when the price field is cleared.

The new product editor's price input coerced a cleared value with
Number( '' ), which is 0, so blanking a sale price saved _sale_price = 0
and put the product on sale for 0 — the storefront then showed 0 instead
of falling back to the regular price. Preserve a cleared price field as an
empty string so WooCommerce removes the sale price instead of saving 0.

Fixes getdokan/dokan-pro#5823

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MdAsifHossainNadim MdAsifHossainNadim self-assigned this Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 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: dbd5aaf5-9757-4567-9335-ac1933af0662

📥 Commits

Reviewing files that changed from the base of the PR and between 50765a0 and 9a14440.

📒 Files selected for processing (1)
  • src/dashboard/product-editor/components/PriceEdit.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/dashboard/product-editor/components/PriceEdit.tsx

📝 Walkthrough

Walkthrough

PriceEdit.tsx now keeps a cleared sale price as an empty string instead of 0, while still passing a numeric value into vendorEarningHandler for earning calculations.

Changes

Empty price field fix

Layer / File(s) Summary
DokanPriceInput onChange empty value handling
src/dashboard/product-editor/components/PriceEdit.tsx
Clearing the input stores '' instead of 0, and the earning handler is called with Number(value).

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • getdokan/dokan#3263: Modifies the same DokanPriceInput handler in PriceEdit.tsx, changing value-handling logic in the same code path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main fix: clearing a vendor dashboard sale price without saving 0.
Description check ✅ Passed The description follows the template well and includes the required change summary, issue link, testing steps, and changelog.
Linked Issues check ✅ Passed The code change satisfies #5823 by preserving blank sale prices as empty strings so the storefront falls back to the regular price.
Out of Scope Changes check ✅ Passed The diff is narrowly scoped to the price input fix and does not introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 fix/vendor-dashboard-sale-price-not-cleared

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.

@MdAsifHossainNadim MdAsifHossainNadim added Needs: Testing This requires further testing Needs: Dev Review It requires a developer review and approval labels Jun 30, 2026
@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 6, 2026
@kzamanbd kzamanbd merged commit e3391ac into develop Jul 6, 2026
16 of 17 checks passed
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 [Products] 🎉 QA Approved This PR is approved by the QA team [Vendor Dashboard]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants