-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Price section - Small refactor and style fix #34558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test Results SummaryCommit SHA: 2bc84f4
To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
80ded93 to
eb5120c
Compare
louwie17
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall nice work @octaedro, I just left a couple comments and one in relation to this test instruction:
Create a new product without List price but with a Sale price and verify that the List price is set and the Sale price has been deleted after saving. This should happen after pressing Save draft, or Publish, or Publish & duplicate, or Copy to a new draft.
This only worked for me when I never touched the list price and only added the sale price. But as soon as I edited the list price and cleared it, this logic wouldn't work anymore. I believe this would be the same for existing products.
I left a comment within the code to check for empty string as well.
Also I was curious if this logic would be semi redundant once @mdperez86 PR is in with disabling the action buttons?
|
|
||
| const maybeSetRegularPrice = ( product: Product ) => { | ||
| if ( | ||
| product.regular_price === undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check if regular_price is an empty string?
As this will break as soon as the user edits the list price, but clears it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } ); | ||
| const context = useContext( CurrencyContext ); | ||
| const { getCurrencyConfig } = context; | ||
| const { decimalSeparator } = getCurrencyConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move the above two lines into the sanitizePrice function? given the decimealSeperator isn't used anywhere else, and would needlessly be triggered on every re-render. It's probably not super JS extensive, but it be nice to keep that stuff to a minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I changed it in commit b60ef79
|
Thank you @louwie17 for your review, |
# Conflicts: # plugins/woocommerce-admin/client/products/sections/pricing-section.tsx # Conflicts: # plugins/woocommerce-admin/client/products/sections/pricing-section.tsx
0e65863 to
2bc84f4
Compare
louwie17
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates on this @octaedro, this tested well and changes look good :)
|
Hi @octaedro, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
All Submissions:
Changes proposed in this Pull Request:
This PR fixes a few things related to the prices section and addresses a couple of suggestions made for this PR.
It adds:
Sale pricehas an error.Closes # 38-gh-woocommerce/mothra-private.
How to test the changes in this Pull Request:
Feature this producttooltip looks and works correctly.List pricebut with aSale priceand verify that the error messageSale price cannot be equal to or higher than list price.is being shown after theSale priceloses the focus.Sale priceequal to or higher than theList priceand verify that the warningSale price cannot be equal to or higher than list price.is visible under theSale price.Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: