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

Document the use of a NULL total price for empty carts in 2.x #15

Open
rszrama opened this issue Apr 15, 2024 · 0 comments
Open

Document the use of a NULL total price for empty carts in 2.x #15

rszrama opened this issue Apr 15, 2024 · 0 comments

Comments

@rszrama
Copy link
Collaborator

rszrama commented Apr 15, 2024

Commerce 1.x's function commerce_order_calculate_total() will always initialize a total price with $0 (defaulting to the default currency of the site in a case where there are no items on the order to say otherwise). Commerce 2.x uses NULL, which means you cannot blindly pass the total price field's value to Twig and render it with price formatting - that would result in NaN when the template is rendered. We should document this difference in the section:

https://docs.drupalcommerce.org/v2/developer-guide/adapting-from-1x/

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

No branches or pull requests

1 participant