0

How can we round up the tax to 2 decimals, but the last decimal should be either 0 or 5. I have this rule for the round up:

if ($decimal % 10 <= 2) {
  // Here, the last decimal should be 0.
}
else if ($decimal%10 > 2 && $decimal%10 <=7) {
  // Here, the last decimal should be 5.
}
else {
  // Here, the decimal should be incremented by 1, while making the last decimal 0.
}

For examples:

  • 10.24, rounds up to 10.25
  • 10.67 rounds up to 10.65
  • 10.88 rounds up to 10.90
  • 10.99 rounds up to 11.00

Can I alter the tax adjustment somewhere? Also, I would like to calculate it on the full order price, not individually for all order items.

2
  • Welcome to Drupal Answers! Are you asking how to achieve what described with code, or with a module?
    – apaderno
    Dec 17, 2021 at 19:19
  • With code if it is possible, even with a patch on commerce that I could attach Dec 17, 2021 at 23:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.