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

Fix #21725 - Render price on category list with correct precision for current locale #21829

Conversation

Bartlomiejsz
Copy link
Contributor

@Bartlomiejsz Bartlomiejsz commented Mar 18, 2019

Description (*)

This PR changes price rendering on category view to include correct precision for current locale and currency.

Fixed Issues (if relevant)

  1. Fixes Price Precision wrong on product listing pages #21725

Manual testing scenarios (*)

  1. Magento 2.3.0
  2. Default locale set should be for Oman (ar_OM it's not by default available in Magento, need to be added in \Magento\Framework\Locale\Config but didn't check all locales to verify where it also occurs), Oman Rial (OMR) selected as currency
  3. Visit product listing page - see that the products have prices with precision 3.
  4. Visit product details page - see that the products have prices with precision 3.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @Bartlomiejsz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team
Copy link
Contributor

Hi @aleron75, thank you for the review.
ENGCOM-4538 has been created to process this Pull Request

@aleron75
Copy link
Contributor

Hello @Bartlomiejsz thanks for your contribution.

Once merged, don't forget you can easily port this PR (if needed) to other branches with the Porting Tool, read more here.

@VasylShvorak
Copy link
Contributor

Hi @Bartlomiejsz during testing, I found more places when price is rendered with incorrect precision. And subtotal price on cart page is rendered with two comma separators(issue is present on 2.3-develop and not caused by PR). So price inconsistency is still present after your fix.

Manual testing scenario:

  • Create simple product with Price=123,46
  • Set Stores->Configuration->General->General->Locale Options->Arabic (Saudi Arabia)
  • Go Stores->Configuration->General->Currency Setup
  • Set Base Currency=Omani Rial, Default Display Currency=Omani Rial,Allowed Currencies=Omani Rial
  • Check cart page, minicart and checkout page
  • ❌ Price precision is not rendered correctly
    #21829Cart
    #21829CartSubtotal
    #21829Checkout

@sivaschenko Could you check if testing scenario is valid for PR changes?

@sivaschenko
Copy link
Member

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, here is your new Magento instance.
Admin access: https://pr-21829.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@sivaschenko
Copy link
Member

sivaschenko commented Mar 22, 2019

@VasylShvorak the scenario looks valid to me. I think the sum is displayed correctly during checkout (looks like two different commas used)

@Bartlomiejsz would you be able to fix the price precision in the mini cart, shopping cart page and emails for consistency?

@Bartlomiejsz
Copy link
Contributor Author

@sivaschenko yes, I will work on that

@Bartlomiejsz
Copy link
Contributor Author

@VasylShvorak @sivaschenko could you test this one again with newest changes?

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for updates @Bartlomiejsz A couple of minor changes required for backward compatibility: please see my review comments

app/code/Magento/Sales/Model/Order.php Outdated Show resolved Hide resolved
lib/internal/Magento/Framework/Pricing/Render/Amount.php Outdated Show resolved Hide resolved
@sivaschenko sivaschenko added this to the 2.5 milestone Nov 2, 2020
@engcom-Foxtrot engcom-Foxtrot self-assigned this Nov 19, 2020
@engcom-Foxtrot
Copy link
Contributor

@magento run all tests

2 similar comments
@engcom-Foxtrot
Copy link
Contributor

@magento run all tests

@engcom-Foxtrot
Copy link
Contributor

@magento run all tests

* @since 102.0.6
*/
public function getFormattedTierPrice($qty, $product)
{
$price = $product->getTierPrice($qty);
if (is_array($price)) {
foreach (array_keys($price) as $index) {
$price[$index]['formatted_price'] = $this->priceCurrency->convertAndFormat(
$price[$index]['formatted_price'] = $this->amount->convertAndFormatCurrency(
$price[$index]['website_price']
);
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

As done before to improve readability, the return early pattern can also be applied here, returning $price at the end of the loop and avoiding the else statement.

@ihor-sviziev
Copy link
Contributor

Moving to on hold as this PR waiting for opening 2.5 develop branch

@ihor-sviziev
Copy link
Contributor

@Bartlomiejsz Branch 2.5-develop was already created. Could you re-target this PR to the 2.5-develop branch?

@Bartlomiejsz
Copy link
Contributor Author

Yes, @ihor-sviziev I'll try to work on this PR in upcoming days

@Bartlomiejsz Bartlomiejsz force-pushed the feature/fix_21725_price_precision_wrong branch from 5f1858e to 1e846a4 Compare January 15, 2021 21:13
@m2-assistant
Copy link

m2-assistant bot commented Jan 15, 2021

Hi @Bartlomiejsz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@Bartlomiejsz
Copy link
Contributor Author

@sivaschenko didn't really try to close this PR, it got automatically closed when I force pushed changes re-created on 2.5-develop branch, I will create new one for it

@ihor-sviziev
Copy link
Contributor

@Bartlomiejsz seems like you force pushed branch with no changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: MFTF test coverage Component: Checkout Component: Pricing Component: Sales Component: Tax Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Price Precision wrong on product listing pages