Skip to content
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

Gross price display in product variant price detail is not based on the one calculated by a strategy #2506

Open
floze opened this issue Nov 5, 2023 · 2 comments
Assignees
Labels
status: blocked 🚧 Resolution is blocked by some other issue or external factor type: bug 🐛 Something isn't working

Comments

@floze
Copy link
Contributor

floze commented Nov 5, 2023

Describe the bug
The price including taxes displayed in the product-variant-detail section seems to be based on the plain value, i.e. not affected by a ProductVariantPriceCalculationStrategy. Everywhere else though, any "price with tax" seems to be based on the strategy calculation, if set.

To Reproduce
Steps to reproduce the behavior:

  1. Have a productVariantPriceCalculationStrategy configured
  2. Go to /admin/catalog/products/1/variants/1
  3. Scroll down to "Price and tax"
  4. See error

Expected behavior
The displayed gross price should be based on the strategy calculation. Maybe the strategy calculation result should even be displayed as well beside the price input.

Environment (please complete the following information):

  • @vendure/core version: v2.1.0
  • @vendure/admin-ui-plugin v2.1.0
@floze floze added the type: bug 🐛 Something isn't working label Nov 5, 2023
@michaelbromley
Copy link
Member

The issue here is that the ProductVariantPriceCalculationStrategy.calculate() method is one-way: i.e. it takes the "raw" price from the ProductVariantPrice entity in the DB and transforms it in some way.

When updating a price, there is no equivalent reverse operation that can take a "calculated" value and convert it into the "raw" value to be stored in the DB. This is why we currently just use "raw" values in the Admin UI when modifying the price(s) for a variant.

But I do see the issue where there is a mismatch between the value in the price input field and the expected "calculated" value.

So I think the best solution would be along the lines of your suggestion - to keep the existing "raw" input, but additionally show the "calculated" price too.

I would imagine it would also be desirable to be able to live-preview how the calculated price would change in response to changes to the "raw" price. That would require a new query operation to be defined which is capable to running the strategy on-the-fly.

I think for now a simple and acceptable first step is to at least show the "calculated" price near the raw input if it differs.

@dlhck dlhck modified the milestone: v3.2.0 Sep 27, 2024
@dlhck dlhck added the status: blocked 🚧 Resolution is blocked by some other issue or external factor label Sep 27, 2024
@dlhck
Copy link
Collaborator

dlhck commented Sep 27, 2024

Done together with #2903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked 🚧 Resolution is blocked by some other issue or external factor type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants