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

Use single price value instead of range in product list #2386

Merged
merged 3 commits into from
Nov 2, 2022

Conversation

Droniu
Copy link
Member

@Droniu Droniu commented Oct 17, 2022

I want to merge this change because it improves product list view. With channel filter selected, we often see price ranges for single-variant products even though the price is constant. This change improves the readability by rendering single price whenever the range is not actually a range.

PR intended to be tested with API branch: main

Screenshots

Before
image

After
image

Pull Request Checklist

  1. This code contains UI changes
  2. All visible strings are translated with proper context including data-formatting
  3. Attributes [data-test-id] are added for new elements
  4. Changes are mentioned in the changelog
  5. The changes are tested in different browsers and in light/dark mode

Test environment config

API_URI=https://automation-dashboard.staging.saleor.cloud/graphql/
MARKETPLACE_URL=https://marketplace-gray.vercel.app/

Do you want to run more stable tests?

To run all tests, just select the stable checkbox. To speed up tests, increase the number of containers. Tests will be re-run only when the "run e2e" label is added.

  1. stable
  2. giftCard
  3. category
  4. collection
  5. attribute
  6. productType
  7. shipping
  8. customer
  9. permissions
  10. menuNavigation
  11. pages
  12. sales
  13. vouchers
  14. homePage
  15. login
  16. orders
  17. products
  18. app
  19. plugins
  20. translations
  21. navigation

CONTAINERS=1

@patrys
Copy link
Member

patrys commented Oct 17, 2022

@github-actions github-actions bot temporarily deployed to saleor-7906-use-single-price-value October 17, 2022 08:49 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-7906-use-single-price-value October 17, 2022 08:49 Inactive
@Droniu Droniu linked an issue Oct 17, 2022 that may be closed by this pull request
@Droniu Droniu requested review from a team, andrzejewsky and orzechdev and removed request for a team October 17, 2022 08:50
@patrys
Copy link
Member

patrys commented Oct 17, 2022

Could we improve it further by using Intl.NumberFormat.formatRange where it's supported (currently only in Safari) and falling back to Intl.NumberFormat.format with a separator otherwise?

formatRange

Intl.NumberFormat("en-US", {style: "currency", currency: "USD"}).formatRange("1.00", "21.00");
// "$1.00 – $21.00"

Intl.NumberFormat("pl-PL", {style: "currency", currency: "USD"}).formatRange("1.00", "21.00");
// "1,00–21,00 USD"

format

Intl.NumberFormat("en-US", {style: "currency", currency: "USD"}).format("123.00");
// "$123.00"

Intl.NumberFormat("pl-PL", {style: "currency", currency: "USD"}).format("123.00");
// "123,00 USD"

@Droniu Droniu marked this pull request as draft October 17, 2022 09:59
@github-actions github-actions bot temporarily deployed to saleor-7906-use-single-price-value October 25, 2022 12:00 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-7906-use-single-price-value October 25, 2022 12:00 Inactive
@Droniu Droniu marked this pull request as ready for review October 25, 2022 12:02
Comment on lines +18 to +47
if (from && to) {
return from.amount === to.amount
? formatMoney(from, locale)
: formatMoneyRange(from, to, locale);
}
if (from && !to) {
return intl.formatMessage(
{
id: "lW5uJO",
defaultMessage: "from {money}",
description: "money",
},
{
money: formatMoney(from, locale),
},
);
}
if (!from && to) {
return intl.formatMessage(
{
id: "hptDxW",
defaultMessage: "to {money}",
description: "money",
},
{
money: formatMoney(to, locale),
},
);
}
return "-";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that is a component, perhaps a format component would be more reasonable here?

@Droniu Droniu requested a review from szczecha November 2, 2022 10:58
@Droniu Droniu merged commit 7387019 into main Nov 2, 2022
@Droniu Droniu deleted the SALEOR-7906-use-single-price-value branch November 2, 2022 11:20
Droniu added a commit that referenced this pull request Nov 3, 2022
* Render single value when amount of money is matching

* Use Intl.NumberFormat in money formatting

* Extract messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't display a price range when only a single product variant
5 participants