Closed (works as designed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Line item
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2012 at 22:16 UTC
Updated:
9 Jul 2013 at 03:34 UTC
This sounds similar to solved issue http://drupal.org/node/1060002
Calling commerce_line_item_delete() from inside an implementation of hook_commerce_cart_product_remove() throws the following error:
EntityMetadataWrapperException: Unable to get the data property commerce_total as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of /var/www/vhosts/scmedia/sub/asauthors/web/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
Comments
Comment #1
rszrama commentedCan you please post the actual code you're executing and export the Rule? We have to be able to duplicate an issue to fix it, but we don't have time to recreate every issue from descriptions. : )
Comment #2
hitfactory commentedSure. This is my current hook which now works since I am using commerce_cart_order_product_line_item_delete().
When I used commerce_line_item_delete() instead of commerce_cart_order_product_line_item_delete() that's when I got the error.
The use case is removing a product when another is removed from the cart.
Comment #3
rszrama commentedAny reason you would use the one API function instead of the other? It sounds like you're basically creating a scenario that breaks referential integrity amongst the entities involved. : ?
Comment #4
hitfactory commentedI am only using commerce_cart_order_product_line_item_delete() as a temporary workaround simply because it works.
I assume the commerce_line_item_delete() is the better function as it removes the line item from all entities.
I'll try an equivalent bit of code on a kickstart install and report back.
Comment #5
rszrama commentedThis issue's been dormant for a while, but I'd still recommend the function chosen. That said, in a recent commit we added more clean-up protection for line item references, so you should probably be able to use a straight commerce_line_item_delete() in the future.