Hi,
I encountered an issue while adding a product to the cart when "commerce_coupon_usage" is enabled and "redeem coupon" is enabled to anonymous users (I think it's a possible reason).
The complete error is :
EntityMetadataWrapperException : Missing data values in EntityMetadataWrapper->value() (line 83 in /data/project/repository/modules/contrib/entity/includes/entity.wrapper.inc).
After debugging, I found a bug in "commerce_coupon_usage.module" at line 396, when "$unchanged" is loaded from "$order->original", property which is missing.
I don't know why at the first call this property is missing, and just after it is present.
My suggest is to replace the following code :
<?php
$unchanged = entity_metadata_wrapper('commerce_order', $order->original);
?>
by :
<?php
$unchanged = entity_metadata_wrapper('commerce_order', isset($order->original) ? $order->original : $order);
?>
Do you think it's safe to apply this fix ?
Unfortunately I'm not sure to be able to explain how to reproduce this issue on a clean setup.
However I can test fixes on mine.
Thanks
Comments
Comment #2
sebastien m. commentedHere is a patch.
Comment #3
lunazoid commentedI was having the same problem after upgrading commerce_coupon (from 7.x-1.x) which was preventing some orders from going through. (I'm not sure why it was only some orders, but it may have been a result of the workflow unique to these orders.) Applying the patch in #2 seems to have fixed the problem!
Comment #4
mglamanThe entity controller should ALWAYS be setting ->original.
Are you using Commerce Entitycache?
Comment #5
mglamanComment #6
lunazoid commentedI do not have commerce_entitycache installed...
Comment #7
mglamanOk, because this is part of entity controller
So it looks like an unsaved order is being passed to the function, which doesn't make sense since it looks to be an update hook.
This makes me feel like something else is the issue.
Comment #8
karlsheaI'm also running into this. I narrowed it down to a rule that changes the order status on "Before saving a commerce order". So it's definitely possible for an unsaved order to make it to this function.