Commerce coupon upgrade guide

Commerce coupon beta4 has been out there for a while and the majority of changes have been implemented in the dev version, so if you're upgrading from beta4 to beta5, you may have problems in the process. This page will provide tips and process documentation, feel free to complete it with your use case.

Major changes in the module

The changes happening in this module can be reviewed in more detail in the roadmap issue, but as an outline, this has happened:

  • There's now two independent projects for Percentage Coupons and Fixed amount coupons.
  • Basic coupon type is not used anymore.
  • Coupon log entity has been removed for good.
  • Coupon reference has been transformed to Entity Reference.

Upgrade tips

As the changes have happened in a quite long time lapse, you may find some issues in the way, most of them related with the coupon reference fields.
Please review the upgrade path in a sandbox before doing the process in a production site
The upgrade path will transform the coupon reference field into an entity reference, so please make sure you've got the last version of entity reference installed.
The log will be transformed into a coupon reference field attached to the commerce order for getting the historic data.
If you've got issues related with field not deleted and stopping you from uninstall/upgrade, you may want to take a look to field_delete_field function instead of messing with the database directly. Also cron is your friend.
Another issue you may have is doing the update and no udpate function is triggered, clear your cache, maybe registry rebuild and try again.

Upgrade from beta4+25 version

First, you'll need to uninstall "beta4+25" version.

  1. Change line 237 from commerce_delete_fields('commerce_coupon_reference'); to commerce_delete_field('commerce_coupon_reference'); at "commerce_coupon.install" file. See this issue "Uninstall does not delete reference fields". As you notice, beta4+25 does not have those 2 lines from the issue, so i replaced only one line.. Plus if you don't do this change, you will probably get this error when you uninstall commerce coupon module: "Invalid argument supplied for foreach() in commerce_product_reference_entity_info_alter() (line 823....."
  2. Disable all Coupon modules. If you can't disable "commerce_coupon" module beacuse there is a blocked field at Coupon line item, just drush -> "drush field-delete commerce_coupon_reference".
  3. Now you can install latest version.

Note: if you keep sutck with this issue, it may be help to delete the previous orders.

From base coupons to percentage/fixed

There's an upgrade process that will try to transform all your basic coupons into pct/fixed ones, you'll find this process UI in admin/commerce/coupons/settings