Developer notes for version 2.6

Easy Digital Downloads 2.6 has been released. This version includes numerous important improvements for store owners and just as many or more improvements for developers. We would like to go over the developer-oriented changes here.

Customer meta

We have introduced a metadata API for customers. This API is nearly identical to the standard WordPress postmeta and usermeta APIs except it is for customer records.

The EDD_Customer class has new helper methods for adding, updating, deleting, and retrieving metadata.

  • add_meta()
  • update_meta()
  • delete_meta()
  • get_meta()

These methods work just like the standard WordPress metadata functions, except they are methods within the EDD_Customer class.

$customer = new EDD_Customer( 1 );
$meta = $customer->get_meta( $key, $single = true );

One of the primary advantages of customer meta is that extensions can now store metadata on the customer without requiring that the customer have an associated user account. Up until now, most metadata for customers has been stored in the usermeta table, which made it difficult to support data for customers without user accounts.

New methods for retrieving customer payments

The EDD_Customer class now includes two new methods related to payments:

  • get_payments( $status = array() ) – will return an array of EDD_Payment objects that belong to the customer
  • get_payment_ids() – will return an array of the payment IDs associated with the customer

Additional emails for customers

Customer records can now have multiple email addresses. We have added three methods to the EDD_Customer class that allow developers to add / remove emails from a customer:

  • add_email( $email ) – will add an email address to the customer
  • remove_email( $email ) – will remove an email address from the customer
  • set_primary_email( $email ) – will make the specified email address the primary address for the customer

Customer objects can be instantiated with any registered email address.

Tooltips

Extension developers can now add tooltips to their plugin settings and administration screens. There are two ways to add tooltips.

When registering plugin settings, tooltip_title and tooltip_desc can be included in the array, like so:

'page_settings' => array(
	'id'   => 'page_settings',
	'name' => '<h3>' . __( 'Page Settings', 'easy-digital-downloads' ) . '</h3>',
	'desc' => '',
	'type' => 'header',
	'tooltip_title' => __( 'Page Settings', 'easy-digital-downloads' ),
	'tooltip_desc'  => __( 'Easy Digital Downloads uses the pages below for handling the display of checkout, purchase confirmation, purchase history, and purchase failures. If pages are deleted or removed in some way, they can be recreated manually from the Pages menu. When re-creating the pages, enter the shortcode shown in the page content area.','easy-digital-downloads' ),
),

The tooltip will be automatically added to the settings screen for the setting.

Tool tips can also be added manually like this:

<span alt="f223" class="edd-help-tip dashicons dashicons-editor-help" title="Help text goes here"></span>

REST API V2

2.6 includes v2 of our REST API, which adds several enhancements to the API and introduces a few breaking changes.

If you are not familiar with our API versioning, see our documentation.

V2 of the REST API includes the following changes:

  • /customers/ endpoint now properly shows the customer’s ID instead of the associated user ID
  • /customers/ endpoint now includes the customer’s creation date
  • /customers/ endpoint now accepts a “date” parameter
  • /products/ endpoint now includes product SKUs
  • /products/ endpoint now accepts a “s” parameter for searching
  • /products/ endpoint now accepts a “category” parameter
  • /products/ endpoint now accepts a “tag” parameter
  • /sales/ endpoint now includes more verbose details for “discounts” field

Updated actions, filters, and more

  • The edd_get_payment_status() function now accepts payment IDs and objects.
  • Action hooks have been added to the increase_sales(), increase_earnings(), decrease_sales(), and decrease_earnings() methods of EDD_Download.
  • edd_gateway_loaded JS event now fires when the gateway is changed on checkout.
  • All frontend HTML tables now include a standard edd-table class name.
  • [[downloads]] shortcode now supports a post__in parameter.
  • The EDD_Fees API has been updated to support price option specific fees.
  • Query modes added to the REST API can now be identified as public, meaning they will not require an API key.
  • New filters have been added to the add_fee() and get_fees() methods of EDD_Fees.
  • edd_get_success_page_url() has been deprecated in favor of edd_get_success_page_uri().
  • EDD_Payment is no longer marked as final. Go extend it!

See the complete changelog for a list of all changes.

One response... add one

Leave a Reply

Your email address will not be published. Required fields are marked *