-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[ISM][#18651] TierPrice save float percentage value #19030
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
Hi @SikailoISM. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
*/ | ||
private function getPercentage(array $priceRow) | ||
private function getPercentage(array $priceRow): ?float |
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 @SikailoISM, since Magento 2.2 supports PHP 7.0 you can't use nullable return types as this is a feature of PHP 7.1 and higher. See http://php.net/manual/en/migration71.new-features.php
*/ | ||
private function getPercentage(array $priceRow) | ||
private function getPercentage(array $priceRow): ?float |
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 @SikailoISM, since Magento 2.2 supports PHP 7.0 you can't use nullable return types as this is a feature of PHP 7.1 and higher. See http://php.net/manual/en/migration71.new-features.php
@SikailoISM Thanks for contributing this change! That's great to have tier discounts format aligned with catalog and cart promotions discounts |
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.
Nowadays all changes must be applied to 2.3-develop
first. Please prepare a new pull request, this one should be on hold
until the latter is merged.
{ | ||
return isset($priceRow['percentage_value']) && is_numeric($priceRow['percentage_value']) | ||
? (int)$priceRow['percentage_value'] | ||
? (float)$priceRow['percentage_value'] |
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.
There is no need to cast explicitly to float
, usually + 0
or * 1
is used to convert so that no unneeded int <-> float occur.
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.
• $priceRow['percentage_value'] + 0 or • $priceRow['percentage_value'] * 1
Is it relevant?
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.
Yes, of course.
- removed type conversation
Hi @SikailoISM , please, resolve merge conflicts |
I give up |
Tierprice can't save float percentage value
Description
Problem:
After save tierprice for product,
discount
field lost value after comma.Fix:
Updated getPercentage method in TierPrices:
Fixed Issues
Manual testing scenarios
discount
value "2.5"Contribution checklist