Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

Checkout Fields Manager – Getting Meta Data

The Checkout Fields Manager extensionallows you to make custom fields for your checkout form. This makes it easy to gather data from your customers. You can see it easily on the Payment History page, but what if you want to have it printed on the receipt for the customer to see? This document will help with that.

Radio Buttons Example

In this example we’re going to use a custom radio buttons field, titled “Are you happy with this purchase process?”. The meta key for this field was automatically generated as are_you_happy_with_this_purchase_process, and we’ve simply made a Yes/No answer option. See below.

Since we’re going to be rendering this information on the customer receipt, let’s take a look at that template. The template we want is called shortcode-receipt.php. Read our docs on how to move this template to your theme.

Near the top of that file you’ll find this code:

$payment = get_post( $edd_receipt_args['id'] );

which creates an object for this payment. In the rest of this file we can now find the ID for this payment under $payment->ID.

In the example above the Meta Key is are_you_happy_with_this_purchase_process. Now that we have both the ID and the Meta Key we can get the value with this code:

get_post_meta( $payment->ID, 'are_you_happy_with_this_purchase_process', true )

Note: the ‘true’ in the example above indicates that we’re expecting a single value from get_post_meta(). Checkout Fields Manager returns a single value for all field types it offers.

Printing to the Receipt

In the above example we got the value we wanted, but now we want to render it nicely in receipts. In shortcode-receipt.php you’ll find a HTML table with a CSS ID of edd_purchase_receipt. You can copy this table and change the values. Here’s an example of a table header:

Then we can print a table row for the above question, like this:

Multi-answer Example

Some field types allow for multiple answers from a customer. Check boxes allow the customer to select multiple things for example. This is still stored as a single item in meta data; it’s a single array with multiple key/value pairs. How it gets rendered is slightly different from above, however.

Here’s a custom field asking the customer what their favorite animal is:

Rendering it in our HTML table would look like this:

ID, 'favorite_animal', true ) as $animal ) {
            $animals .= '
  • ' . $animal . '
  • ' . "n"; } // print out the table row, wrapping the results in unordered list tags, and escaping with wp_kses_post() ?>

    As you can see it’s only slightly more complicated than the first example.

    Wrapping Up

    Putting together the two code samples from above, we end up with something like this:

    ID ), 'are_you_happy_with_this_purchase_process', true ) ) ); ?>
    ID, 'favorite_animal', true ) as $animal ) { $animals .= '
  • ' . $animal . '
  • ' . "n"; } // print out the table row, wrapping the results in unordered list tags, and escaping with wp_kses_post() ?>
    ID ), 'are_you_happy_with_this_purchase_process', true ) ) ); ?>

    Which will look like this:

    Key Points

    • To render Custom Fields answers on your receipts, copy the shortcode-receipt.php file to your theme and put your code in there
    • Getting the data is simply doing a get_post_meta() call on the Meta Key provided in you the admin area
    • All keys from Custom Fields Manager are stored as singles in the post_meta table.

    Note: Easy Digital Downloads does not provide support for custom coding/development. If needed we recommend hiring a developer through Codeable make the custom changes you need.