Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a site that has two different order types (checkout fields are different based on role) using the Commerce Order Types module. Enabling Commerce Coupon throws the below error when one of the roles using a custom order type logs in.
EntityMetadataWrapperException: Unknown data property commerce_coupon_order_reference. in EntityStructureWrapper->getPropertyInfo() (line 339 of /sites/all/modules/entity/includes/entity.wrapper.inc).
Is it possible to have the coupons be used between multiple order types?
Comment | File | Size | Author |
---|---|---|---|
#6 | commerce_coupon-Add_commerce_order_type_support-1972784.patch | 870 bytes | doru.furtuna |
Comments
Comment #1
pcambraOh yeah, absolutely... coupon order reference is created just for the default bundle, order types generate new bundles so you need either to add the field manually or provide a patch that loops the bundles and adds it automatically.
Comment #2
BD3 CreditAttribution: BD3 commentedAhh, wonderful. I manually added it and am able to checkout as normal. I am however getting the error below now on the cart page and checkout, but everything works as it should.
Notice: Undefined index: path in template_preprocess_entity() (line 1020 of /sites/all/modules/entity/entity.module).
I went to my custom order type and added an existing field (commerce_coupon_order_reference) and kept the same configuration as the regular order type. I then hid the coupon field under Manage Display as the regular order type has this hidden as well. Maybe I am missing one more step to get rid of this error message?
Thanks for your help and quick response!
Comment #3
pcambraDoesn't look related unless the new order types are missing the path property, you can use Commerce Devel to better track the error but it's unlikely that it comes from coupon.
Comment #4
BD3 CreditAttribution: BD3 commentedOops, my bad. It was unrelated. It had to do with a recent upgrade to Drupal Commerce 7.x-1.6 which was throwing that error.
Thanks for all your help!
Comment #5
pcambraReopening this, maybe someone can post a patch for taking care of this automatically
Comment #6
doru.furtuna CreditAttribution: doru.furtuna commentedHi guys,
Just implemented automatic Commerce Order Type support in the patch bellow.
Please review.
To see the changes you have to re-enable the Commerce Coupon module.
Thanks.
Comment #7
bensey CreditAttribution: bensey commentedThis is pretty serious, anyone using multiple order types will have their sites break completely (mine was WSOD-ing for admins looking at orders). Can we get this committed to commerce Coupon?
For those with similar issues, a quick fix for me was executing the below patch code using devel's execute PHP page to adjust all the order types immediately.