You can't set the value of a order's line_items when has been wrapped. The reason is that the values are formatted as fields with the LANGUAGE_NONE array while entity_metadata expects them to be directly only the order object. For some wrapped methods this will cause php fatal errors, while others just don't work.

Comments

googletorp’s picture

The fix at github

googletorp’s picture

Status: Active » Needs review

And updated the status

rszrama’s picture

Status: Needs review » Closed (won't fix)

This was related to #979846: Rules line items list and also I believe to our questions to fago in #1013428: EntityListWrapper::value() lacks support for fully loaded entities. It's taken me a while to get my head around this, but I think our approach is incorrect. Instead of adding the line_items field manually to the order property info, we should just let the Entity module take care of that and remove our integration altogether. The solution then to accessing an order's line item data is to include an "Entity has field" condition, and then the line_items field will be available to data selectors in later conditions and any actions.

Thanks for the report, though - I remembered your issue and was able to trace it back to the original integration when I was doing some metadata work on removing items from the shopping cart. : )

pieterdc’s picture

The solution then to accessing an order's line item data is to include an "Entity has field" condition,...

How would I do that?
I have a rule acting upon 'After updating an existing order'.
I add a condition and choose 'Entity has field'.
I can then type 'order' in the Entity form field but I don't get 'line_items' or such as an option in the Field select box...

Ps: I'm using Drupal Commerce 7.x-1.0-alpha4

rszrama’s picture

Hmm, I see it as the second option in the list. : ?

https://skitch.com/rszrama/rewd3/add-a-new-condition-set-and-drupal-comm...

pieterdc’s picture

Thanks for your quick response.

The items in my list are:
comment_body
body
field_tags
field_image
purchase_price
unit_price
total
product

I did a fresh install, but I didn't use your install profile...
Anyhow, our install must differ somehow.

rszrama’s picture

Yeah, very weird... are orders actually getting configured properly with the line item reference field?

pieterdc’s picture

When trying to add something to cart, I'm getting:
EntityMetadataWrapperException: Unknown data property line_items. in EntityStructureWrapper->getPropertyInfo() (regel 294 van Sites/drupal7commerce/sites/all/modules/entity/includes/entity.wrapper.inc).

And when viewing admin/commerce/config/order/fields, I'm getting:
No fields are present yet.

Ps: I'm using todays' Drupal Commerce dev version

rszrama’s picture

Ok, in that case something screwed up on installation that prevented your line items field from being created. : ?

I guess installation order bugs are still alive and kicking... can you rebuild with step by step module installation in the order of dependencies?