Problem/Motivation
According to OrderInterface the return value of getTotalPrice can be NULL. Same goes for getUnitPrice on the order item. In that case FacebookCommerce throws an error since the price rounder expects a Price object.
I have practically encountered this error in a customized checkout process.
Proposed resolution
Sent 0 as the price if there is no order total/order item unit price set.
Issue fork facebook_pixel-3300892
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
anybody@krystalcode thank you, the MR looks good. But to be sure this won't break anything and won't break in the future it would be great to have some tests for this. Could you please do that?
Did you already test this manually for all possible cases?
Comment #4
krystalcode commentedWriting test will be difficult at this time, especially since there's no test already for this to build on top of.
I have done some limited manual testing, I can report back after running the patch on production for some time.
Comment #5
anybodyThanks @krystalcode that would be helpful. Anyway users complaining about issues here, should start adding tests to improve the situation. This is open source and we're paid 0 cent for this... ;) Just like you.
Comment #6
anybody@krystalcode any updates here? And could you help adding tests to the module?
Comment #7
krystalcode commented@anybody
Comment #8
grevil commentedA similar problem arises in the module file, if the price is null:
Let's fix that here as well.
Comment #9
grevil commentedCleaned up the existing code a bit and fixed the module file implementation. Please review!
Note, that by the official meta documentation, "value" doesn't seem to support NULL values, so let's use "0" where we can.
Comment #10
anybodyNice, good enough to fix the issue. Can't be perfect, I think...
Comment #11
anybodyComment #13
grevil commentedThanks all!