Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We can use the code in https://github.com/commerceguys/pricing/blob/master/src/Price.php for an example.
We want a \Drupal\commerce_price\Calculator static class that implements no interface and has the following methods:
- compare
- add
- subtract
- multiply
- divide
- ceil
- floor
- assertAmountFormat
The result should be trimmed of any extra zeroes (since bcmath will add them up to $precision).
Once we have that, we want to introduce the same methods that https://github.com/commerceguys/pricing/blob/master/src/Price.php has to the value object, and use the Calculator inside.
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedWhile we're at it we should also do this:
Comment #3
bojanz CreditAttribution: bojanz at Centarro commentedTagging for dev days. Of course, as long as it's unassigned it can be taken by non-devdays people too :)
Comment #4
bojanz CreditAttribution: bojanz at Centarro commentedComment #5
fbailey CreditAttribution: fbailey commentedComment #6
fbailey CreditAttribution: fbailey commentedhttps://github.com/drupalcommerce/commerce/pull/408
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedCommitted after a series of bikeshed discussions :) Thanks!