Official development blog for Easy Digital Downloads

Commissions 3.4 is nearly here and today we’re releasing the first beta version of it. This is a major update that implements the first of our efforts to move data away from the WordPress posts and postmeta tables and into a custom database schema specifically designed for commission records.

When Easy Digital Downloads was first released over five years ago, nearly all of the data stored by the plugin was kept as custom post types inside of the wp_posts and wp_postmeta tables. This included all data for products and orders, and, as extensions were released (such as Commissions) other data as well. As we, and many others have learned, utilizing the standard WordPress database for eCommerce data storage was a poor decision that has had significant negative consequences. We are committed to constant improvement in our products and one of our primary tasks this year is to move all transactional data safely out of the WordPress tables and into our own set of tables that have been carefully designed for the specific task at hand.

In Commissions 3.4, we have completed the first of several large data migrations and all commission records are now stored in a custom table. This means all site owners will be presented with a dialog instructing them to run an upgrade routine after updating to Commissions 3.4.

Clicking on the “learn more” link will explain what is occurring with this upgrade routine:

There are two ways to run the migration routine:

Through the wp-admin area by clicking on the “here” link inside of the upgrade notice

Via WP CLI by using the wp edd-commissions migrate_commissions command

For large sites, we strongly recommend using the WP CLI command as it will be significantly faster and less prone to server timeouts or browser problems.

This data migration enables significant performance improvements. On one of our own production sites, we saw a 3x increase in the performance of commissions-related queries and tasks. The migration also helps to drastically reduce the size of your database. On one of our own databases, we removed more than 230,000 rows simply by running the migration routine. We’re able to make this kind of improvement because of the design of our new database tables, which are far more performance-minded than the prior WordPress tables.

New database schema

The new database schema introduced in Commissions 3.4 includes two tables, one for the main commission records and one for metadata, and has the following structures:

wp_edd_commissions

id bigint(20)

amount mediumtext

status varchar(20)

download_id bigint(20)

cart_index bigint(20)

price_id bigint(20)

date_created datetime

date_paid datetime

type varchar(20)

rate bigint(20)

currency varchar(10)

wp_edd_commissionmeta

meta_id bigint(20)

commission_id bigint(20)

meta_key varchar(255)

meta_value longtext

During the upgrade routine, all existing data will be moved into the new tables from wp_posts and wp_postmeta. Once the migration is complete, an option to delete all legacy data will be shown.

Please make a backup of your site prior to running the upgrade routine. We have been testing it extensively on our own sites (including our main production sites) and we are confident in its reliability, but it’s still always in your best interest to be extra safe and create backups before making large data changes.

Backwards compatibility

The data generated by EDD Commissions has been stored as a post type with postmeta for several years now, meaning there is a very good likelihood that developers have added their own functionality and are interacting with the data inside of wp_posts and wp_postmeta. In an effort to maintain complete backwards compatibility, we have included a compatibility layer that helps to translate queries to the legacy data structure and reroute it to the new tables.

In this first beta, we have included a compatibility layer that intercepts all calls to get_post_meta() with known meta keys and re-routes those queries to the new database tables. This means queries like the one below will continue to work even though the data is no longer in wp_postmeta:

get_post_meta( $commission_id, '_edd_commission_info', true );

We have also included backwards compatibility layers for add/update/delete_post_meta() for all data related to commission records. Meaning the following calls will continue to function properly:

update_post_meta( $commission_id, 'some_custom_key', 'Value' );

delete_post_meta( $commission_id, 'some_custom_key' );

Note: we cannot possibly know exactly how developers have integrated with the commission data so we’re doing the best we can to predict how it’s being used. If you’re aware of a case that we can account for, please let us know so we can include it in our backwards compatibility layer.

We have also supported mapping custom meta keys in our backwards compatibility layer. If you would like to register a meta key to be re-routed, use the eddc_post_meta_backwards_compat_keys filter.

Other improvements and fixes

Along with the migration to custom tables, there are a number of other improvements in version 3.4:

Commission notification emails now support template tags for {commission_id}, {item_price}, and {item_tax}

The export tool now allows commissions of specific statuses to be exported

The Commission add/edit screen now includes better data validation

A new hook called eddc_before_commissions_overview has been added to the Commissions Overview screen

A new hook called eddc_commissions_overview_table_head has been added to the Commissions Overview screen

A new hook called eddc_commissions_overview_table_row has been added to the Commissions Overview screen

A new hook called eddc_after_commissions_overview has been added to the Commissions Overview screen

Admin screens now have improved responsiveness

Product name was incorrectly shown for commissions created without a download ID specified

Beta testing

Since this is a fairly large change to how the Commissions extension works, we have opted to release it first as a beta before sending it into the wild. We would appreciate any feedback you can provide before the final release date to ensure that the the update goes smoothly. The beta is 100% backwards compatible, so no need to worry about having to reconfigure commissions on your existing products. In short, there’s no good reason you can’t help us with testing the latest release! So how do you get your hands on the beta?

Notes:

Access to the beta is restricted to active license holders. Don’t have one? Purchase one today.

You will need Easy Digital Downloads 2.6.17 or later in order to use the automatic beta install option.

Please let us know what you think! If you notice any problems, you may let us know in the comments below or by submitting a support ticket.