The validation breaks with the folowing error message:
EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of /var/www/kenzo/www.kenzo.com/trunk/sites/all/modules/contrib/entity/includes/entity.wrapper.inc). Backtrace:
EntityStructureWrapper->getPropertyValue('type', Array) entity.wrapper.inc:86
EntityMetadataWrapper->value() entity.wrapper.inc:258
EntityValueWrapper->value() commerce_stock.module:425
commerce_stock_checkout_validate(Object) commerce_stock.module:211
commerce_stock_checkout_form_validate(Array, Array) form.inc:1430
form_execute_handlers('validate', Array, Array) form.inc:1371
_form_validate(Array, Array, 'commerce_checkout_form_checkout') form.inc:1106
drupal_validate_form('commerce_checkout_form_checkout', Array, Array) form.inc:833
drupal_process_form('commerce_checkout_form_checkout', Array, Array) form.inc:364
drupal_build_form('commerce_checkout_form_checkout', Array) form.inc:123
drupal_get_form('commerce_checkout_form_checkout', Object, Array) commerce_checkout.pages.inc:58
commerce_checkout_router(Object, Array)
call_user_func_array('commerce_checkout_router', Array) menu.inc:503
menu_execute_active_handler() index.php:21
The problem is, that the shipping is added as a line item in the order.
I made a quick fix for it, you will find the patch file here.
Comments
Comment #1
guy_schneerson commentedHi skipyT
If my understanding is correct commerce_product_line_item_types() should return all line_item types that are products so should exclude shipping line items and the "getBundle() == 'product'" cancels the other part of the condition so other product bundles will get excluded, but havent used "getBundle" before so cant be sure.
I cant recreate the problem and suspect it may be related to other custom or contrib modules ( not ruling out it is to do with stock)
Comment #2
skipyT commentedHi guy_shneerson,
I didn't have time today to check the problem, because I had an urgent deadline, and the project wasn't written by me, I only took it yesterday. I will investigate on Monday and I will return with more information, because you are right about commerce_product_line_item_types().
Comment #3
skipyT commentedI checked it today morning the fatal error is comming from the: $line_item_wrapper->type->value(), when the line item is shipping.
And is not comming from your module. I'm investigating now what is the problem, cause the shipping is not loaded well.
Comment #4
wgsimon commentedHi
I've encountered the same error. It's hard to say which module it's coming from, stock, shipping or entity. I have posted here as the errors are the same and the suggested fixes are to the shipping module. I am using commerce_stock-7.x-1.0-rc2 and commerce_shipping-7.x-1.0 with the 'Example plugin' shipping method. I can post a precise sequence of steps from a fresh install to reproduce the problem if needed.
If I checkout to the point where shipping is added as a line item but then view the cart and click on the checkout button I get the error:
EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 339 of [...]\sites\all\modules\contrib\entity\includes\entity.wrapper.inc).Having got rid this error (see below), if I continue the checkout process, choose the shipping and 'Continue to next step' I get the error mentioned by skipyT above:
EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 440 of [...]\sites\all\modules\contrib\entity\includes\entity.wrapper.inc).This can be fixed using skipyT's suggestion. As mentioned, $line_item_wrapper->type->value() causes the error as this property is not set and $line_item_wrapper->getBundle() can be used instead to get the correct types for product or shipping line items. In
commerce_stock_checkout_form_validate()I replacedwith
... and to fix the first error I was having, in
commerce_stock_form_commerce_cart_validate()I wrappedwith a check for the product
Will
Comment #5
guy_schneerson commentedthanks wgsimon,
i will try and recreate the problem and get back to you if ill need more details,
The problem with skipyT fix is it allows for only the default product bundle and will disable stock checking for any user created bundles.
Comment #6
guy_schneerson commentedthanks skipyT & wgsimon
I have replaced all instances of $line_item_wrapper->type->value() with $line_item_wrapper->getBundle() fixed the issue and is better code thanks to you both.
I will commit the changes to the dev version that also has other improved EntityMetaData code.
If you can test the dev version (git or should refresh by tomorrow) and let me know, would be of great help as i am planning a full stock 7.x-1.0 soon.
Comment #7
guy_schneerson commentedcommitted http://drupalcode.org/project/commerce_stock.git/commit/a5fb37b
Comment #8
skipyT commentedLooks good to me! I just tested it locally, I don't have the error.
Thanks!
Comment #9
wgsimon commentedMany thanks, that works for me too.
Comment #10
guy_schneerson commentedThanks guys for testing (will push this soon to an rc3)
Comment #12
TyrelDenison commentedI am having the same problem with version 2. I have applied the patches manually, as they are meant for version 1, but they do not work. Below is my complete backtrace. Any help would be greatly appreciated as I have been dealing with some manner of this bug ever since the site went live. Stock management was a last minute request that has become a bit of a nightmare.
Comment #13
guy_schneerson commentedok changing the issue to V2
Possibly related to http://drupal.org/node/1606624.
Comment #14
philipz commentedAny progress on V2? I have the same issue and I'm not sure if I should try to use patch #7 and apply it to V2.
EDIT: I've changed all
$line_item_wrapper->type->value()in commerce_stock.module (3 occurances) to$line_item_wrapper->getBundle()and it works fine now.Thanks for this module by the way! Really appriciate it!
Comment #15
guy_schneerson commentedGot loads on but will do it this week, if not before then this weekend.
Comment #16
guy_schneerson commentedThis patch should fix things, it makes for cleaner code using the get getBundle() but the main thing is adding a missing check on the cart validation function.
Comment #17
guy_schneerson commentedcommitted http://drupalcode.org/project/commerce_stock.git/commit/0d6848b
please test the dev version (should refresh by tomorrow, check the date to make sure) or pull from git.
Please let me know and if it works will release as 7.x-2.0-alpha2 !!!!
Comment #18
malberts commentedI got an error similar to #12.
I can confirm that I do not get it any more with 7.x-2.x-dev (2012-Jun-27).
Comment #19
TyrelDenison commentedThis patch did not fix the problem for me. For the record, the patch for v1 (when applied to v1) did not resolve it either. If I am alone in this it may be something else in my configuration. I have disabled the shipping rule that deletes shipping line items on cart update and no longer have the error.
Comment #20
malberts commentedFor the record, my error happened during some commerce_stock call but the Entity* errors were the same.
Comment #21
guy_schneerson commented@TyrelDenison can you provide a the stack call it will allow me to see what code triggers the error
@malberts is #20 before or after the patch, are you still getting errors?
Comment #22
malberts commented@guy_schneerson: #20 is before the patch. I am not getting the error any more (#18). Sorry for the confusion.
Just some more information: I did not capture my backtrace (and I don't have another site to get it from), but the way I got the error was I went to payment and then simulated a failed payment so I ended up back at the review page (/checkout/123/review). When trying to proceed to the next step I would get those Entity* errors. Now that I look at it, my error was actually closer to the OP's error than #12. The key point being that my backtrace mentioned a commerce_stock function call before the Entity* errors appeared.
Comment #23
guy_schneerson commentedHi @malberts that's cool I know where the issue was before the patch, it was cycling through the basket and not checking if line items where products. the backtrace is for @TyrelDenison as he is still getting problems. I cant see how this is related to the stock as this patch should have closed the only hole in the system but a call stack can help identify the issue.
Comment #24
TyrelDenison commented@Guy The backtrace I get is listed in #12. Honestly I'm not even certain that my issue is related to the stock module as it is not mentioned in the backtrace, and I see that it is in the backtrace from the original issue post. All of the symptoms and triggers are the same, but not mention of stock. I think something else may be trying to grab the same stale information that stock was when it was causing the error. Go figure.
Comment #25
guy_schneerson commented@TyrelDenison Dosent look like a stock issue it may be a problem with a damaged/corrupt line item (i have seen them before). try and test with a different loged in user.
setting to fixed but open it if it turns out to be stock
Comment #26
TyrelDenison commentedOddly enough, this only occurs with anonymous users.
Comment #27
guy_schneerson commented@TyrelDenison try anonymous users on different browsers or clear your cookies. if its only on one of them it is most likely damaged/corrupt line item.
Comment #28
TyrelDenison commented@guy_schneerson It is across all browsers and with cleared cookies. I something is trying to access the shipping line items and it panics when they are not there. For this reason, I disabled the shipping rule I mentioned in #19. rszrama says there should be no real side effect of disabling it based on how I'm calculating things. That will have to work for now, as I have other aspects of the site to finish up. If I find out later it does actually have something to do with stock, I'll report back. Thanks for your help.
Comment #29
hadsie commentedI'm in the same boat with this one. The original patch was working for me but doesn't apply against the latest codebase, so I'm attaching a new patch that does. Unfortunately I'm short of time atm to debug this one any further.
Comment #30
guy_schneerson commentedHi @hadsie the patch #16 was already committed see #17 so any previous patches will not work.
as far as the change you include in the patch the second part of the condition is cancelled out by the first.
The function commerce_product_line_item_types() should return 'product' under normal circomstances, what can help is if you try to dump or print_r the autpot of commerce_product_line_item_types() ans let me know what you get, so it would be something like
function commerce_stock_checkout_validate($order_wrapper) {
print_r(commerce_product_line_item_types());
.....
}
output something like:
Array ( [0] => product )
Comment #32
guy_schneerson commentedComment #33
greatmatter commentedI hate to reopen such an old issue, but we suddenly started seeing the same error (different line number), and it's sort of major, because it turns out this actually happened a few months ago, and just didn't have enough data to determine the cause... We cannot seem to artificially reproduce the issue. We are using commerce_stock 7.x-2.1.
EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 438 of /var/www/vhosts/[SITE]/sites/all/modules/entity/includes/entity.wrapper.inc).This seems to happen in a very special but important instance. Our client ran a sale with *very* limited stock; the intent was to sell out within 5 minutes. They had a few hundred people looking to buy.
From what we were able to ascertain from logs, with a little speculation, is this:
Comment #34
guy_schneerson commentedHi @greatmatter
The only rule that's gets triggered after payment is the "Stock: Decrease when completing the order process" a recent patch has been submitted to help in validation of non typical circumstances.
Can you check if the patch fixes it for you:
https://www.drupal.org/node/2446713#comment-9689931
Comment #35
guy_schneerson commentedPushed a related patch, if anyone with this issue can test the dev version hopefully this issue is now fixed
Comment #36
guy_schneerson commentedWill close in a month or so if no one can report that this is still an issue
Comment #37
guy_schneerson commentedI asume this is now fixed, but do re-open if comes up again.