Closed (fixed)
Project:
Commerce Donate
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2012 at 19:47 UTC
Updated:
27 Feb 2013 at 02:40 UTC
To fix this, I added the event "Before saving a commerce line item" to the rule.
Comments
Comment #1
stella commentedAwesome, thanks! I came across the same issue myself when the payment pane was on the main checkout page - it seemed to work fine though when the payment pane was on the Review page. Thanks for tracking this one down. Committed to latest dev.
Comment #3
rvallejo commentedPosting here because I just ran into an issue related to the donation amount/line item price rule with the added event…
I added the "Before saving a commerce line item" event to the main rule and found that to work as far as keeping the donation line item unit price set to the donation amount, EXCEPT when using the Commerce Coupon module with a coupon on the order.
On checkout with both a coupon and a donation on the order, using the authorize.net payment gateway, when I submit an order from the order review page I'd get an error page instead of processing the order. If I had the donation form on the review page, added a donation at that point and submit the order with a valid credit card, it would work; however, if a donation was added before the review step (via checkout pane at an earlier step or a product display), or if a donation was added during review and there was an error with the payment method (ie. review page reloads and must re-enter payment info, the donation having successfully been added at the same time), then I'd get the error page, the order stuck in checkout, and in the error log I'd have an EntityMetadataWrapperException error of type php/commerce_order.
My solution for now was to add a data comparison condition on the donation rule, keeping the "Before saving line item" event, to check if the line item unit price is equal to the donation amount field (return the negative, so the actions fire only when the two values don't match, using php evaluation to multiply the donation amount field by 100, though I'm guessing you could also just compare to the decimal value without adjusting but I didn't try that).
I didn't spend much more time debugging the issue to see if it's actually an issue with the Coupon module, but it seems the issue arises when updating the donation line item (on "Before saving line item" event) while trying to process the order after being triggered by rules for coupons. For now I just wanted the issue fixed and figured I'd post this workaround in case anyone ran into the same issue or something similar, but if anyone wants more information I can put more time into reproducing the issue and pinpointing what's going on.
Full text of the error message from the log, FWIW: EntityMetadataWrapperException: Unable to get the data property commerce_total as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of ... /sites/all/modules/entity/includes/entity.wrapper.inc).