Add custom checkout fields to Easy Digital Downloads

If you use Easy Digital Downloads for your e-commerce store, you are probably a fan of his minimal and straightforward checkout like I am. At the same time, I have to say it is not rare I need to implement custom checkout fields to collect additional information from users.

Of course, you can use the official extension (Checkout Fields Manager) to implement them, which is very good and flexible. But sometimes you may prefer to code them yourself if you don’t want to add backend interfaces or to keep more control over your code.

EDD custom checkout fields

EDD is a nicely coded plugin, and you have all the hooks needed to load, validate and process the custom checkout fields. I actually use a functionality plugin, which takes care of:

Displaying the fields on the checkout form – hooking edd_purchase_form_user_info_fields()

Validating the fields – hooking edd_purchase_form_required_fields()

Showing error messages – hooking edd_checkout_error_checks()

Saving the fields in the backend – hooking edd_payment_meta()

Displaying the fields on payment backend page – hooking edd_payment_personal_details_list()

The plugin is open sourced on GitHub, and you’ll find in the code the parts to change to add your own custom fields (documented in a clear way, hopefully).

It also takes care of prefixing the fields automatically, so you just need to input the keys, labels, and descriptions. There is no definition for the priority/order for the fields in checkout, so they are shown just in the same order of the array containing the data.

It is a great and lightweight alternative to Checkout Fields Manager, especially useful if you do not need complex fields like radio buttons or multi-select.

Leave a comment

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