Skip to content

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

@rszrama

Description

@rszrama

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions