Hello-

I am having an issue with a Drupal Commerce configuration and was hoping to get a push in the right direction on resolving this.

I am using

DC 7.1.8
Drupal 7.26
entityapi 7.1.5

commerce_addressbook
commerce_coupon
commerce_discount
commerce_invoice_receipt
commerce_moa
commerce_price_decimals_formatter

The issue occurs when the coupon module is activated. Coupon can be successfully added to an order as expected, but then moving to review, or going back to cart and then forward to checkout from /cart, produces a WSOD with the following entry:

EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 438 of /mnt/ssl-vhosts/domain.com/htdocs/sites/all/modules/entity/includes/entity.wrapper.inc).

If I disable coupon code fieldset on the checkout config, everything returns to normal. I am using the latest dev on both commerce_coupon and commerce_discount.

Can anyone think of where the culprit is in this? I have run commerce_repair and the error persists.

It may be important to know that this store was originally ubercart and ubercart_migrate was used to roll the existing orders into commerce, but seemed to be successful until we added coupons.

CommentFileSizeAuthor
#24 drupal_commerce-2258373-24.patch1.5 KBJeroenT
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Project: Commerce Core » Commerce Coupon
Version: 7.x-1.8 » 7.x-2.x-dev
Component: Checkout » Code

Moving to the proper queue.

xamount’s picture

Priority: Normal » Critical

Also experiencing this issue (no ubercart migration for me though). Should mention that the site is using Features as well. The exact error I got was:

EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 335 of /....../sites/mysite/modules/contrib/entity/includes/entity.wrapper.inc).

I can confirm that this error only happens when I use the commerce_coupon module version 7.x-1.0-beta7 or 7.x-2.0-beta3

Marking as critical as this module is non-functional without resolving this error.

xamount’s picture

Priority: Critical » Normal

Sorry this error was related to some custom code. Setting back to normal. Carry on.

dpolant’s picture

Status: Active » Closed (works as designed)
dpolant’s picture

Status: Closed (works as designed) » Postponed (maintainer needs more info)

Sorry didn't mean to close, I realize your last post just pertained to the additional problem.

Usually "parent not set" errors mean that the code is trying to do something with properties of an empty wrapper. The first thing I'd try is using the current dev version of both Coupons and Discounts. Then, if the problem persists, try to figure out where the exception is getting thrown using a debugger or some dpm statements.

Please update this issue if you have already identified/fixed the problem or if you have any additional info. If I don't hear back in a little while I'm going to close the issue and assume you found the problem on your end.

torgosPizza’s picture

Status: Postponed (maintainer needs more info) » Active

I'm experiencing this issue now too. I noticed in the commerce_line_item table, line_item_label is empty for coupon line items. (Also the name is commerce_discount, not the expected commerce_coupon, though may I just don't understand how Commerce works.).

I'm not 100% sure if this is the culprit but I'm going to dig into this because this makes the Coupon functionality useless.

I can reproduce every time thusly:

1. Create a Percentage Discount, 15% (0.15 for the amount). No conditions.
2. Create a Coupon code through the UI. Call it whatever you want, nothing special.
3. Go through checkout and apply the coupon. It will apply cleanly.
4. Go to Review page. "Coupons" view in the pane may or may not be blank.
5. Proceed to Payment page. WSOD with the exception listed above.

torgosPizza’s picture

Further testing: went to Payment pane (PayPal as my test, since it has an extra checkout step, it makes it easier to debug).

I get this at WSOD:

/checkout/5342981/review|DatabaseTransactionOutOfOrderException: in DatabaseConnection->rollback() (line 1071 of /mnt/www/html/rifftrax7stg/docroot/includes/database/database.inc).
Oct 10 21:50:25

Then when you browse to any other page, for instance the Discounts admin page, you get a WSOD with this:

EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 438 of /mnt/www/html/rifftrax7stg/docroot/sites/all/modules/entity/includes/entity.wrapper.inc).

Looking back at the commerce_line_item tables for that order_id, I now have 3 copies of the commerce_discount line item type, all with blank line_item_label. Updating those rows does no good; I still get the MetadataWrapperException.

I'm transitioning from our stage server to my local setup to see if I can dig more deeply.

torgosPizza’s picture

And of COURSE I can't reproduce it locally. Man..

UPDATE: I disabled Commerce Entitycache on our staging environment and now I can make it to Payment without any issue. Interesting.

torgosPizza’s picture

Confirming: on Production, I disabled Commerce Entitycache and everything now seems to work.

So it appears there is an incompatibility with caching Order entities and applying line item discounts?

@Dan: see if you can enable Memcache, Entitycache and Commerce Entitycache and if that gets you the bug.

-Mania-’s picture

I'm getting this error too. It seems to happen every time I use a percentage coupon. The fixed one works fine. I don't use Commerce Entitycache module though so what else could be wrong?

This is the error I get:

EntityMetadataWrapperException: Unable to get the data property commerce_unit_price as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 438 of C:\xampp\htdocs\mysite\sites\all\modules\entity\includes\entity.wrapper.inc).

torgosPizza’s picture

Are you using the latest -dev versions of all those modules? (Coupons, Discount, GC)

-Mania-’s picture

Yes, I've tried both the current stable and dev versions.

torgosPizza’s picture

Looks like we're seeing this once again on Production. Coupons are disappearing from an order during the checkout stage, and I can reproduce the EntityMetadataWrapper error by going into the Order Edit page and clicking "Simulate checkout process".

This is when an order has a giftcard coupon attached to it, as well as a percentage off product discount coupon.

I will attempt to debug this further.

hoZt’s picture

I am not seeing any errors or warnings during my testing using the dev modules, but the coupon is being removed from the order on the review page. This is happening with any type of coupon I test.

torgosPizza’s picture

@hoZt, do you notice this issue with only certain payment methods? For instance is it only on PayPal, and not credit card? Or does it not seem to make a difference?

Are you using all of the latest -dev versions of the modules?

I want to make sure we are all attempting to test the same setup because for us, on latest -dev versions, we mainly see this in PayPal EC but I have seen it occasionally with Credit Card as well.

Also, are you able to reproduce it every single time? What are the steps you use to reproduce? Any details are helpful.

tatewaky’s picture

Hi Guys,

having the same exact issue of #14, it seems that if on order settings i unset the property "Always refresh shopping cart orders on shopping cart and checkout form pages regardless of other settings." and i increase the timing to refresh in a lot of seconds helps, but off course the issue still there, and yes i am using the last dev version of both coupon and coupon percentage.

thanks.

dpolant’s picture

@tatewaky
You should not need the commerce coupon percentage module - that is only for sites using coupons 1.x
Try using commerce_discount dev version as well. That module needs a new release badly.

tatewaky’s picture

@dpolant, oh i did not actually check the version of this thread im sorry, however im getting that issue with the version 1.x of the coupon module.

here is my issue:

http://screencast.com/t/EPRVeGHE

dave-at-sherpa’s picture

I'm seeing the same thing as #14. (Similar to OP, too, minus the WSOD.) Coupons apply cleanly, then shipping is selected, and then the coupon is gone in Checkout Review. In all test cases, the coupon is still shown in Checkout Review, but the "Granted Amount" is set to $0.00 and the coupon component is removed from the cart view.

BUT - and this seems like a big difference - the same thing is happening with sales tax and quantity-based discounts. I'm guessing someone else would have mentioned the tax thing if that was happening to them, too.

All elements are applying cleanly in Checkout. Coupons, general discounts, quantity discounts, & tax. All fine in Checkout. But by Checkout Review, they're all gone. Shipping remains, though.

Not using Entitycache.

Ravenight’s picture

I'm now having the same issue as #19.

I don't use the coupon module, but everything applies as normal up until the review checkout page. At which point sales tax, general discounts, etc are not shown nor are they being applied.

torgosPizza’s picture

@Ravenight: If you're not using Commerce Coupon, that is weird, but this is a Coupon issue thread. However there's always the chance these are related, but your issue sounds pretty different - in our case discounts and taxes, etc., all work but Coupons are removed at the point of checkout completion (on occasion).

You might start uninstalling contrib modules one at a time (check on your Rules configs too and make sure they are all intact) and post your issue as a separate one.

dave-at-sherpa’s picture

I found a solution for my problem (see #19), but I doubt it's related to the original post. It might be a solution for some of the others who recently joined the queue.

The culprit was Rules. I found a similar issue posted on drupalcommerce.org (Sales Tax Not Working) that suggested rolling back Rules from the current stable version (7.x-2.8) to the previous stable version (7.x-2.7). That did the trick. Everything is now appearing where and when it's supposed to in my cart: state-based sales tax, quantity-based discounts, coupons, etc.

FWIW - I've had one issue with Coupons that has been occuring longer than the life of the new version of Rules (which came out in Jan 2015). When I add a coupon to an order, but then exit checkout and continue shopping, the coupon would change the granted amount to $0.00. That would happen with or without changes to the cart. The coupon would then have to be removed and re-applied. That issue has now also disappeared with the Rules roll back. I can't explain that, but perhaps it's connected to one of the other changes I attempted along the way, e.g., updating Commerce Feeds from latest stable to dev?

torgosPizza’s picture

Interesting. I know that the issue you're referring to was fixed in a recent commit, so it'd probably be worth testing the Dev version of Rules. See #2324587: Rules might be triggered too early in the bootstrap and #2403851: Drupal Commerce is broken with Rules 7.x-2.8

JeroenT’s picture

Status: Active » Needs review
FileSize
1.5 KB

The problem for me was that the function commerce_coupon_order_discount_ids was looping over a broken line item. The line item was "NULL".

This patch solved the problem for me.

Anonymous’s picture

I had to roll-back Rules a couple months back due to Sales Tax not being applied.

Couple days ago I updated Rules as issue was fixed. Now I find that the sales tax is being applied to full price and not discounted price.

commerce_coupon and commerce_coupon_pct (7.x-1.0-beta7)
rules (7.x-2.9)

torgosPizza’s picture

@daouverson2 That sounds like a completely different issue.

rszrama’s picture

Agreed; maybe just check your rules weights to ensure they're firing in the proper order? If they're all 0, the application order may as well be random.

Anonymous’s picture

Thank you. Can you share link(s) to help with getting weights in order?

I'm not a newbie (been developing with Drupal since 4.7), but the power and flexibility of Rules + Commerce is overwhelming me.

I have 2 very basic e-commerce sites in production, with just a few contrib modules enabled; I'm having issues with order total, sales tax, sub-total, and coupon coming out right.

Thank you, and kind regards,

  • JeroenT authored 387097c on 7.x-2.x
    Issue #2258373 by JeroenT: metadata wrapper fail
    
dpolant’s picture

Status: Needs review » Fixed

@JeroenT Seems like a simple and sound patch. Committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.