I have a Kickstart installation and. I defined a coupon for free shipping and I encountered problems with it, I tried to change the order of checkout so that shipping details were asked for before the coupon, didn't work well, and I went back to my previous solution without free shipping.
After that, I'm now receiving the error message "EntityMetadataWrapperException: Unable to get the data property coupon_id as the parent data structure is not set" when I try to access the Orders view that is predefined by Kickstart. How could I track what could be causing the problem? My first guess is that some db entry is corrupted, but it could be something else. I don't know how to fix it either. I've tried to delete the orders that contain some coupon but it doesn't seem to work. Maybe I haven't been exhaustive.
I'm using version 2.0-rc2 of Commerce Coupon.
Comments
Comment #2
dpico CreditAttribution: dpico commentedI've found that only some orders fail (orders that maybe were using coupons, though there is not coupon configured in the order page, apparently). Viewing them through the Orders view or trying to change their state to completed produces the "EntityMetadataWrapperException: Unable to get the data property coupon_id as the parent data structure is not set" error.
Comment #3
dpico CreditAttribution: dpico commentedOk, I got it. Some coupon definitions had been removed from table commerce_coupon but they were still being refenced elsewhere. I've done some surgery to the database and added fake entries with the coupon_id's that were missing and the error has disappeared.
Comment #4
mglamanSo on coupon delete we need to remove references. Or coupons should not be able to be deleted if referenced, only disabled.
Comment #5
dpico CreditAttribution: dpico commentedYes, that's right. The table that contains the coupons had many references to coupons that didn't exist any more (missing coupon_id in table commerce_coupon) and that seems to be causing the errors I described.
Comment #6
johnmcc CreditAttribution: johnmcc as a volunteer commentedI suffered the same issue, and the information that @dpico offered helped. Here are the exact steps I took to fix the problem, in case anyone else is in the same boat:
In my case, the problem appeared when I was trying to edit the order status in the admin area. Hope this helps someone!
Comment #7
vasikeI think this is duplicate of #2818607: EntityMetadataWrapperException for orders with deleted coupons
Comment #8
sudoman0 CreditAttribution: sudoman0 commentedBased on Johnmcc's advice, these were my SQL commands:
things to change when running the following query: the updated coupon_id and its code name.