TypeError: Argument 1 passed to Drupal\commerce_price\Calculator::multiply() must be of the type string, null given, called in /var/www/draft/drupal/modules/contrib/commerce_klarna_checkout/src/KlarnaManager.php on line 300 in Drupal\commerce_price\Calculator::multiply() (line 72 of modules/contrib/commerce/modules/price/src/Calculator.php).
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | commerce_klarna_checkout-3138226-empty-percentage-2.patch | 676 bytes | ozin |
Comments
Comment #2
ozinComment #3
jsacksick commentedWhy do you have a NULL tax rate in the first place?
Comment #4
jsacksick commentedDid you define a custom tax type plugin? cause the LocalTaxTypeBase has this code:
Are you using the Avatax module by any chance? We should fix this, I realized we're not setting the "percentage" when adding the adjustment:
Comment #5
ozinHi
No, I do not use Avatax module. Probably I miss somewhere `percentage` when creating Tax, or maybe when it is should be Zero percent it set NULL, not sure. I will debug my case and back with more details.
Comment #6
ozinUpdated patch according to lates changes
Comment #7
jsacksick commentedShouldn't we try calculating the percentage? Klarna doesn't complain about a "0" tax rate? Is the tax amount 0 as well?
Comment #8
jsacksick commentedSee https://www.drupal.org/project/commerce_avatax/issues/3138492#comment-13....
Comment #9
jsacksick commentedI'm pretty sure Klarna will crash if we pass a 0 tax_rate (in case a tax amount is positive), so I believe the proper fix is to make sure the tax adjustment has a percentage set on the tax adjustment, or the percentage should be calculated, so not committing this.
Comment #10
ozinI think this issue is more related to my project, so I have to debug more.
Comment #11
zaporylieI've just stepped-into step-debugging mode to learn more about this issue and I believe this is related to how Adjustments are handled in general, meaning it may actually be an issue in commerce core.
from Drupal\commerce_order\Adjustment.php:
So if the tax rate resolves to "0" (which is valid tax rate in some tax zones) the code above will result in Adjustment::percentage member property set to NULL, causing the fatal error in question. However, IMHO this is to be solved in Commerce Core rather than here.
Comment #12
zaporylieCreated #3187199: Adjustment percentage member property cannot be set to 0