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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

Version: 7.x-1.0-beta7 » 7.x-1.x-dev

Oh 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.

BD3’s picture

Ahh, 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!

pcambra’s picture

Doesn'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.

BD3’s picture

Status: Active » Closed (fixed)

Oops, 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!

pcambra’s picture

Status: Closed (fixed) » Active

Reopening this, maybe someone can post a patch for taking care of this automatically

doru.furtuna’s picture

Status: Active » Needs review
FileSize
870 bytes

Hi 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.

bensey’s picture

Issue summary: View changes

This 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.

$bundles = field_info_bundles("commerce_order");
foreach ($bundles as $bundle_name => $bundle_properties) {
    commerce_coupon_order_configuration($bundle_name);
}