Closed (fixed)
Project:
Commerce Stock
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Anonymous (not verified)
Created:
20 Jan 2012 at 00:20 UTC
Updated:
23 Feb 2017 at 18:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedI should have noted that I've followed all the instructions in the readme
Comment #2
Anonymous (not verified) commentedHere's the stack trace using commerce_devel
Comment #3
Anonymous (not verified) commentedSeems to be a problem in commerce_stock_check_cart_product_level.
The call to commerce_cart_order_load returns an object containing the current order, but something about the way that entity_metadata_wrapper is being called results in $order_wrapper being empty.
Comment #4
rfayThis is most often due to a failure to install the correct fields. Does your product type actually have the stock field on it successfully?
Note that Commerce Repair is made for this situation in general. But more for Commerce core... not sure what it would do here.
But I also note you're using 7.x-2.x of stock? That's pretty experimental still, as far as I understand.
Comment #5
guy_schneerson commenteddouggough@drupal.org thanks for helping test V2
I got a few of questions that may help me figure out the issue:
1) Is this a fresh install and you didn't install stock V1 before the V2 version?
2) Did you only enable the API module without the Simple Stock (should be possible)?
3) Did you clear caches before testing?
Its strange that function commerce_stock_check_cart_product_level() is raising errors as its only checks what the order currently holds for the product (doesn't use the stock field), i have also added this feature to V1 (dev) so would like to make sure the function works.
is it possible for you to give me a archive/copy of your installation site and DB (if it contains no personal info), may make it easier to debug if i cant recreate the issue.
Comment #6
Anonymous (not verified) commented@rfay The stock field is there. I may try to run the repair tool. As far as the version is concerned, I like to live on the edge :)
@guy_schneerson Happy to help with anything that can improve Drupal Commerce.
If I'm following the logic correctly, when the add_to_cart form loads on a product display, commerce_stock_form_alter calls commerce_stock_cart_state_validate, which calls commerce_stock_check_cart_product_level, which calls entity_metadata_wrapper and throws the error.
Comment #7
Anonymous (not verified) commentedAfter looking at http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/f... I'm unclear how the following is meant to function:
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);By calling entity_metadata_wrapper with a custom argument ('commerce_order' rather than 'entity' or 'list') and without $info, wouldn't $order get passed through to EntityValueWrapper which is only supposed to wrap a single value? Since $order is an object, perhaps that's where it's failing.
Comment #8
guy_schneerson commented@douggough@drupal.org the entity_metadata_wrapper call should be ok the syntax expects the $type a commerce_order and $data (object /instance) the actual order and the $info array is optional.
This syntax is used all over commerce in places like the cart module:
// If the user actually has a cart order...
if ($order = commerce_cart_order_load($user->uid)) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);
it is strange that this line of code should fail only on the stock module, are you shore you are not getting this error when the stock module is disabled?
ill try and test on a fresh install of kickstart but it is possible something may have gone wrong with D6 Ubercart using the Migrate import.
Comment #9
Anonymous (not verified) commented@guy_schneerson I'll try tomorrow on a fresh install of Commerce Kickstart with no imported data and no other contrib modules. I haven't tested in every possible context, but the particular error is only occurring when Stock is enabled and I click on a product display title in a list. When the individual product display loads, I get the error.
Comment #10
guy_schneerson commented@douggough@drupal.org lust tested on a fresh install of he latest kickstart with no other modules except stock v2 and the kickstart products and no problems (not that it proves there are no issues).
if you are sure this only happens when stock is enabled the only thing i can suggest is debugging your site if you can provide a sensitized copy.
Comment #11
Anonymous (not verified) commentedI'll do some more digging and debugging later this week. I've got another project that I have to launch before I can get back to the Commerce project. Do you want me to send you the DB and codebase? There's nothing sensitive, so I can zip it up and make it available to you on my Dropbox.
Comment #12
rfayWhy don't you share it with me, and I'll take this one off of Guy's 1000 things to do. I'll PM you the email to dropbox it to.
Comment #13
Anonymous (not verified) commentedSounds good. Thanks.
Comment #14
Anonymous (not verified) commentedFor some strange reason I'm not allowed to view my own contact form on drupal.org. Break out your razor...it's time to start shaving some Yaks.
I'll try contacting you.
Comment #15
guy_schneerson commentedthanks Randy, let me know how you get on
Comment #16
Anonymous (not verified) commentedProblem solved.
After further testing I discovered that the issue only effected the admin user. Any other user could view product displays with no issues. I had been testing the Coupon modules earlier and I created an order as admin, using a coupon. Although I deleted the coupons before uninstalling the Coupon modules, I neglected to delete the order. This resulted in an order entry in the commerce_order table that didn't appear in admin/commerce/orders. I deleted the order entry from the commerce_order table, and the error went away.
Thanks to you both for your help on this. I've learned a lot about the inner workings of Commerce along the way, so hopefully I'll be able to help some other people.
Comment #17
guy_schneerson commentedglad it sorted, let us know how you got on
Comment #18
manos_ws commentedI have the same error
but in another situation.
When in Checkout settings I move the Shipping service pane from the Shipping page to the Checkout page.
When I disable stock api everything is ok with an empty Shipping Page.
I am using the latest commerce and stock v2 dev. my backtrace is:
Thanks in advance for your help
Comment #19
shadowdknight commentedIm facing the same issue on 7.x-1.x, after activating Stock, click add to cart.
Strangely it doesnt happen for anonymous.
Tried uninstall and install again with the same result.
Thanks!
Comment #20
guy_schneerson commentedi think we have a fix for this see http://drupal.org/node/1290842, a fix should be in by monday
Comment #21
GuGuss commentedI have the same issue (2.x-dev). Here are the steps I performed :
Then the site is not available for the admin user (see the attached image) but I still can access the overlays (as an admin) and the site works fine for anonymous user (even the check on stock quantity) !
Hope this can help.
Waiting for monday ;)
GuGuss
Comment #22
guy_schneerson commentedthanks GuGuss, i think i know what the problem is but if my suspicion is correct you must have another module installed most likely shipping.
can you pls confirm if you have other modules installed.
Comment #23
guy_schneerson commentedcommitted a patch for both V1 and V2 that should fix this, dev version tomorrow should include it.
patch @: http://drupal.org/node/1290842#comment-5590174
manos_ws, shadowhitman, GuGuss, pls let me know if this fixes the issue for you.
Comment #24
guy_schneerson commentedComment #25
manos_ws commentedusing the latest dev version fixed the issue for me!
Thanks allot
Comment #26
guy_schneerson commentedComment #27
GuGuss commentedFixed with the dev version !
Thanks