-
Notifications
You must be signed in to change notification settings - Fork 219
Fix products incorrectly marked as discounted #11386
Fix products incorrectly marked as discounted #11386
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +10 B (0%) Total Size: 1.53 MB
ℹ️ View Unchanged
|
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 working on this, @tarhi-saad. On the Cart and Checkout blocks, the change works as expected. However, I noticed that on the product page, the old price logic is still visible.
While it's obvious to us, that @woocommerce/rubik maintains the Cart and Checkout blocks, while @woocommerce/woo-fse maintains all other blocks, for external folks, this might not be obvious. They might be wondering why this PR only partially changes the logic of how we display discounted prices.
I wonder if we should get someone from @woocommerce/woo-fse involved, to ensure that we change the display logic of all discounted prices. Or if we should create a follow-up ticket for them and ensure that both PRs will land in the same release.
Before merging this PR, I would suggest adding E2E tests to catch future potential regression. It should not require a lot of time and it could help us in the long term. There is dedicated documentation that explains how testing filters and actions: https://github.com/woocommerce/woocommerce-blocks/blob/7403a5a4c2a23f1f5e94041e2ac1a7dde6dc8805/tests/e2e/mocks/custom-plugins/readme.md |
Right. I haven't thought about that. Thanks for pointing this out, @gigitux. |
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.
My previous comment was answered in #11386 (comment). Let's ⛴️ this change, @tarhi-saad.
Please
+1 on this. @tarhi-saad don't merge this without adding a test. Let's strive to add automated tests to all our bug fixes. |
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.
I'd be happy to pair and add E2E test cases with you! Let me know. 🙂
} ) => { | ||
await installPluginFromPHPFile( | ||
`${ __dirname }/update-price-plugin.php` | ||
); |
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.
Hi, @gigitux! I followed the guidance from Testing WordPress actions and filters but didn't achieve the expected outcome. The custom plugin that's supposed to alter product prices in the Cart didn't seem to work; it showed the original prices instead. I tried debugging this issue yesterday without success. Could you help me in identifying any potential steps I might have overlooked?
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.
Hi, @tarhi-saad!
I tried to run the test, and the price is updated.
I don't think that it is related, but the only change that I made was to add the suffix .side_effects
. This is necessary because the filter could impact other tests (Mini Cart - for example), so it has to be run NOT in parallel.
f684f69
to
b8c504d
Compare
We don't want to mark a product as having a discount when price includes additional costs
c75deb2
to
c1c031f
Compare
All tests are passing! I'll merge this PR! |
What
We are incorrectly displaying some products as discounted when their price is updated to add some extra cost.
Fixes #10433
Why
Revised the
isDiscounted
logic. Now, the discount is applied only when the new price is lower than theregularPrice
, rather than just being different.Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Order Summary
section, confirm that the discount label is only visible next to the discounted product.Order summary
section, Confirm that both products reflect the new price (50) and neither displays a discount label.Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog