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

Cart Total is NaN in some circumstances #18027

Closed
rauberdaniel opened this issue Sep 12, 2018 · 24 comments
Closed

Cart Total is NaN in some circumstances #18027

rauberdaniel opened this issue Sep 12, 2018 · 24 comments
Assignees
Labels
Component: Checkout Component: Tax Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@rauberdaniel
Copy link

rauberdaniel commented Sep 12, 2018

Preconditions

  1. Magento 2.2.5
  2. PHP 7.1
  3. MySQL 5.6.27

Steps to reproduce

  1. Put two items in the cart, in our case this is one product at 59,80€ incl. Tax and one product at 9,49€ incl. Tax, Shipping is free
  2. Apply a coupon code (cart price rule) with 100% discount

Or in comment -> #18027 (comment)

Expected result

  1. Cart Total should be 0,00 €

Actual result

  1. Cart Total is NaN,N €

This issue might be a parsing issue in the frontend or a rounding issue in the backend, as the /rest/default/V1/guests-cart/…/totals-information returns a JSON response including "grand_total":1.4210854715202e-14 (which is basically 0). Either the Frontend has an issue parsing this value or the backend shouldn’t even return a value that hasn’t been rounded. In some cases this value can even be negative and would result in -NaN,N €.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Sep 12, 2018
@magento-engcom-team
Copy link
Contributor

Hi @rauberdaniel. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.

@rauberdaniel do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@ghost ghost self-assigned this Sep 12, 2018
@ghost ghost added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Sep 12, 2018
@rauberdaniel
Copy link
Author

@magento-engcom-team give me 2.2.5 instance

@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team
Copy link
Contributor

Hi @rauberdaniel, here is your Magento instance.
Admin access: https://i-18027-2-2-5.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost
Copy link

ghost commented Sep 12, 2018

Hi @rauberdaniel I'm not able to reproduce following steps your described.
selection_077

@rauberdaniel
Copy link
Author

This only appears in conditions where floating point calculations are not accurate. I assume it has to do with taxes (7% in my case).

I tried reproducing in the magento instance you offered me, but that instance does not update its index automatically (I assume no cronjob running) and therefore does not allow to create any products (refresh index on save doesn’t seem to work either and manual reindex is only possible using command line).

@ghost
Copy link

ghost commented Sep 12, 2018

@rauberdaniel I try several times but same result, tax 7% and do reindex, cron run cache clean, but not have an NaN
selection_078

@ghost
Copy link

ghost commented Sep 12, 2018

@rauberdaniel And rest api result Any update ?
selection_079

@rauberdaniel
Copy link
Author

Guess I need to set up a vanilla Magento 2.2.5 instance to reproduce this, as the one offered above is not working correctly. However, I don’t currently have time for that. Might also have to do something with tax and discount calculation (post or pre tax). Will let you know as soon as I had time for it. Thank you!

@ghost
Copy link

ghost commented Sep 12, 2018

@rauberdaniel ok somehow i'm get this result but not in grand total
selection_080

@ghost
Copy link

ghost commented Sep 12, 2018

@rauberdaniel yes finally i'm reproduce this :)
selection_081

@ghost ghost added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Progress: needs update labels Sep 12, 2018
@rauberdaniel
Copy link
Author

Great to hear, thank you very much for the help! This is a critical issue for us, as it prevents going past the payment method step in checkout, as no payment methods are available for a NaN price.

@ghost ghost added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Tax Component: Checkout labels Sep 12, 2018
@ghost
Copy link

ghost commented Sep 12, 2018

@rauberdaniel, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost removed their assignment Sep 12, 2018
@jayankaghosh
Copy link
Contributor

What can I do to reproduce this issue? I have tried as the OP mentioned and got 0.00 as the total

@jayankaghosh
Copy link
Contributor

jayankaghosh commented Sep 21, 2018

Ok nevermind. I reproduced it. Seems to be a floating point precision error. We could round the floating point number to 2 digits, since that's the max precision Magento uses to display prices

@jayankaghosh jayankaghosh self-assigned this Sep 21, 2018
@jayankaghosh
Copy link
Contributor

I am working on this

nirav-kadiya added a commit to nirav-kadiya/magento2 that referenced this issue Feb 1, 2019
* Escaped output of html attributes

* MAGETWO-97466: Refreshing checkout page deletes shipping address on guest checkout

* MAGETWO-96711: One page Checkout resets Customer data if Product Qty was changed

* MAGETWO-72879: Update product from mini shopping cart doesn't reflect in the shopping cart

* meassage icon alignment issue resolved

* ENGCOM-3851: Static test fix.

* ENGCOM-3893: Static test fix.

* MAGETWO-96711: One page Checkout resets Customer data if Product Qty was changed

* MAGETWO-97826: Skipped Randomly failing MFTF test AdminCheckingCreditMemoTotalsTest

* MAGETWO-97825: Skipped Randomly failing test AdminCreateCreditMemoWhenCartRuleDeletedTest

* Fixed-19800: Contact us : design improvement.

* Fixed 19800 Contact us : design improvement

* Fixed 19800 Contact us : design improvement

* Fixed 19800 Contact us : design improvement

* Fixed 19800 Contact us : design improvement

* Fixed 19800 Contact us : design improvement

* ENGCOM-3763: Static test fix.

* Fixed-19791: Logo vertical misalignment.

* Fixed-Checkbox-Alignement: Checkbox alignment issue.

* MAGETWO-72879: Update product from mini shopping cart doesn't reflect in the shopping cart

* MAGETWO-96711: One page Checkout resets Customer data if Product Qty was changed

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* magento#18362: Fixed static tests

* Added constants to unit codes to make it easier to reuse it if necessary.

* ENGCOM-3774: Static test fix.

* MAGETWO-96815: There is no option to remove the Store Credit from the payment page of checkout

* Fix negative credit memo bug caused by credit memo discount total calculator

* ENGCOM-3720: Static test fix.

* Added required error message.

If any JSON error occurs user will be be shown error message if the app mode is not in Production.

* Fixed Unused Local variable

* Fixed unused local variable

* Removed use of Class ObjectManager in Construct

* Updated to show error message to all Env.

* Update lib/internal/Magento/Framework/Serialize/Serializer/Json.php

Co-Authored-By: vinogcs <vinogcs@users.noreply.github.com>

* ENGCOM-3782: Static test fix.

* Add useful debug info for which website has not been found

* Add with code/with id text

* MAGETWO-73598: CLONE - Quans: Orders API without key/value on ADDITIONAL_INFORMATION (only values)

* MAGETWO-96815: There is no option to remove the Store Credit from the payment page of checkout

* Issue fixed magento#19985 Send email confirmation popup close button area overlapping to content

Issue fixed magento#19985 Send email confirmation popup close button area overlapping to content

* Issue fixed magento#19985 Send email confirmation popup close button area overlapping

Issue fixed magento#19985 Send email confirmation popup close button area overlapping

* Order API resources updated.

* 'wishlist-page-edit-remove-item-misalign' :: On wish list page edit, remove item misalign in 640 X 767 resolution

* Order-view-invoices :: Order view invoices template not display proper on ipad

* Updated CancelOrderItemObserver.php

Fixed Issue magento#20121 Cancel order increases stock although "Set Items' Status to be In Stock When Order is Cancelled" is set to No

* ENGCOM-3845: Static test fix.

* MAGETWO-74604: Event clean_cache_by_tags didn't clean all tags pointed in getIdentity

* MAGETWO-73598: CLONE - Quans: Orders API without key/value on ADDITIONAL_INFORMATION (only values)

* MAGETWO-97899: [FT] [MFTF] AdminAvailabilityCreditMemoWithNoPaymentTest fails because of bad design

* MAGETWO-94157: Issue with products with customizable options

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* MAGETWO-93832: Automate with MFTF Copy Single Update to Another Update

* MAGETWO-73598: CLONE - Quans: Orders API without key/value on ADDITIONAL_INFORMATION (only values)

* Static test fix.

* MAGETWO-95276: Varnish "Connection reset by peer" error when large catalog is reindexed on schedule

* MAGETWO-95176: Detaching category from product causes massive product url regeneration

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* MAGETWO-73625: Products change in one category will cause cache miss for other categories (Only reproducible by unassigning products from backend category page)

* admin-order-info-issue2.2

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* Fix static test.

* MAGETWO-95176: Detaching category from product causes massive product url regeneration

* magento#20376 Fix issue with file uploading if an upload field is disabled

* magento#20461 Add translate component

* (Fixes issue magento#18027) Round the total amount to 4 decimal places, to avoid floating point overflows

* round the total amount only if it is float

* round base total amount

* cast formatted number to float

* thousand separator removed from number format

* use round instead of number_format to round the total amount

* unnecessary comments removed

* ENGCOM-3464: Static tests fixed.

* fixed Negative order amount in dashboard - magento#18754

* Fix static test.

* Update styles-old.less

* update-button-issue-while-updating-billing-and-shipping-address

* MAGETWO-95752: Unable to create Configurations for Configurable Products

* issue fixed magento#20563 Go to shipping information, Update qty & Addresses and Enter a new address button Not aligned from left and right in 767px screen size

issue fixed magento#20563 Go to shipping information, Update qty & Addresses and Enter a new address button Not aligned from left and right in 767px screen size

* recent-order-product-title-misaligned

* Fix static tests.

* Fix static tests.

* MAGETWO-94348: The cart rule cannot affect the Bundle product with Fixed Price

* MAGETWO-95752: Unable to create Configurations for Configurable Products

* MAGETWO-95752: Unable to create Configurations for Configurable Products

* MAGETWO-95752: Unable to create Configurations for Configurable Products

* MAGETWO-94114: Cannot refresh Captcha image in production mode

* MQE-1420: Bump MFTF version in Magento

- MFTF version bump + allure-codeception dependency update.

* MQE-1420: Bump MFTF version in Magento

- changing argument from its own attribute to part of the command

* Fixed issue of Lifetime update syntax error

* Fix static test.
@AndyJAllen
Copy link

AndyJAllen commented Feb 7, 2020

Still experiencing this on 2.3.3; despite the existence of this line in Total.php:
$amount = is_float($amount) ? round($amount, 4) : $amount;

These were the values I was working with:
Subtotal: $26.00
Shipping & Handling: 14.16
Discount: -$40.16 (Used coupon code for 100% discount)
Tax: $0.00

Even though it showed isNaN on the order summary; it still let me check out and create the order.

@shikhamis11
@jayankaghosh

@krzysztofkuzniar
Copy link

krzysztofkuzniar commented Apr 15, 2020

@AndyJAllen I confirm, in 2.3.3 still display NaN value in that case.

@ghost ghost unassigned jayankaghosh Apr 15, 2020
@ghost ghost removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Apr 15, 2020
@jayankaghosh jayankaghosh self-assigned this Apr 16, 2020
@m2-assistant
Copy link

m2-assistant bot commented Apr 16, 2020

Hi @jayankaghosh. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!


@jayankaghosh jayankaghosh removed their assignment Apr 16, 2020
@engcom-Delta engcom-Delta self-assigned this Apr 29, 2020
@m2-assistant
Copy link

m2-assistant bot commented Apr 29, 2020

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta engcom-Delta removed the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Apr 29, 2020
@engcom-Delta
Copy link
Contributor

HI @krzysztofkuzniar . I am not able to reproduce issue by steps from comment on 2.4-develop.
#18027issue

Are you facing with this issue on branch 2.4-develop?

@engcom-Delta
Copy link
Contributor

@krzysztofkuzniar, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Checkout Component: Tax Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

6 participants