Easy Digital Downloads – Fields

Documentation

Setting Up Easy Digital Downloads – Fields

Initially configuring Easy Digital Downloads – Fields requires only a few simple steps.

  1. Install and activate the plugin
  2. Navigate to Downloads – > Settings – > Fields and activate your license key (which you can find on your purchase history page)
  3. From here, you can decide to Edit or Remove the existing Fields Templates or to Add your own.
  4. Hit Save Changes and you’re in business!

Creating New Fields Templates

Clicking the “Add Field Template Group” button at the bottom of the list of Templates allows you to create new ones.

You can name your Fields whatever you’d like as well as choose between different Field Types: Plain Text, Select, and Downloads List. If you choose “Select”, the “Edit Options” button appears which allows you to define all the Options for the Select Field. The “Downloads List” Field Type outputs a Select Field with every Download automatically populated into it to choose from.

Here’s an example of a filled out Field Template:

The Field Options panel for the “Required PHP Version” Field has been filled out like so:

All Fields and Field Options can be drag-and-dropped to be rearranged within their Templates to best suit your needs.

Add Fields Data to a Download

If you scroll down the Edit Screen for a Download, you will see a “Download Fields” meta box. This is where you are able to store Fields data in your Download.

You can either choose to use a Custom Template, which allows you to add whatever Field Names and Values to the Download that you want, or you can use a pre-made Template created on the settings page. The “Custom (No Template)” option is specific to that Download, so if you want to have something that is re-usable, you should create your own Template.

Once these are filled out to your liking, you can either check the “Show Fields Table?” checkbox to automatically include a table of your Fields to your Download, or you can add them directly to the Content using Shortcodes.

The Content Editor has a few extra options added to it for EDD Fields to help you add your Fields Data wherever you’d like. You can choose the “Create Fields Table” option to output a complete table for each Field, or you can choose “Get Field Value” to output the value of a specific Field Name wherever you’d like within your Download page.

With the window that appears for each, you can choose to specify a Download different than the one you’re editing and for the “Create Fields Table” window, you can designate a CSS class to add to the table for further customizations.

When using “Get Field Value”, it will only show the Field Names for the currently active Fields Template. If “Custom (No Template)” is in use, it will populate using whatever Field Names have been entered.

Configuring the Fields Widget

Another option for showing Fields Data is by using the included Widget within a Sidebar or Widget Area. You can configure it to show Fields Data for the current Download or for a specific Download, as well as whether to show the full Fields Table or just the value for a Field Name.

When “Current Download” is selected, it will show every available Field Name for each Template when set to show a Single Value. However, with Current Download, it is not possible to use any Download-Specific “Custom (No Template)” Field Names.

If you choose a specific Download, it will allow you to choose Field Names if the “Custom (No Template)” option was selected.

While powerful, the Widget may not work as desired if your Downloads are utilizing many different Fields Templates. This is because if you were to choose “Current Download” as the Download to use Fields Data from and then choose to show only a Single Value, you could choose a Field Name that does not exist for the Download that you’re viewing. If you’re utilizing multiple different Fields Templates throughout your Store, you will most likely want to use the “Full Table” option or otherwise ensure that your Fields Templates that are in use all share that same Field Name.

 

Add Fields Programmatically to a Download

As of EDD Fields v1.0.1, if you need to inject custom Fields into a Download you can use a Filter like the following:

add_filter( 'edd_fields_get_all_saved_fields', function( $fields, $post_id ) {
	
	// This should only matter for Custom Templates, 
	// but in general we don't want to worry about the values that are being Saved to include these added ones
	if ( is_admin() || 
	   ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || 
	   false !== wp_is_post_revision( $post_id ) ) { 
		return $fields;
	}
	
	$template = edd_fields_get_chosen_template( $post_id );
	
	$fields[ $template ][] = array(
		'key' => 'New Field Name',
		'value' => 'New Field Value',
	);
	
	return $fields;
	
}, 10, 2 );

 

This can be utilized to do things like add Custom Meta or Taxonomy Terms to the Fields Table on your Download or to always ensure that the Fields Table includes a certain Field with a pre-defined value or one from elsewhere in the Database.

These additional Fields will not show on the Download Edit Screen, the Shortcode builder in the WYSIWYG Editor, or in the “Singe Value” dropdown in the EDD Fields Widget. But you can use them with the  Shortcode if you want to place an injected Field Value elsewhere in your content. You will just need to enter the Field Name manually as the Shortcode builder cannot see your injected Field.

Changelog

1.1.0

  • Improves updater code
  • Includes WordPress, PHP, and EDD requirements and Tested To values in the readme.txt file
  • Updates Plugin URI in the plugin header to match where it is currently located
  • Updates our licensing and support module to the latest version

1.0.5

  • Fixed an issue where when creating a new Download a PHP Notice could be shown to the user after selecting a Field Template Group.
  • Added a checkbox to the Settings Screen to opt-in to Beta Releases

1.0.4

  • Output the Fields Table on Download Single when using the Themedd Theme properly
  • Fixes potential theme issue where Themes may be overzealous with !important for the EDD Frontend Submissions integration
  • Fixes issue where the integration with the EDD FES Submission Form was not loading
  • Ensures that jQuery UI Sortable and jQuery UI Tooltip is loaded on the Settings Page
  • Fixes issue where when editing a Download via the EDD FES Vendor Dashboard any values entered into EDD Fields would not load properly.

1.0.3

  • Fixes PHP 7.X incompatibility when modifying Field Template Groups on the Admin Screen

1.0.2

  • Adds a link to the Field Template Group management screen on the Download Edit Screen
  • Replaces <strong> with <th> in the Table Shortcode
  • Fixes an incompatibility with EDD Software Licensing

1.0.1

  • Fix: Shortcode Builder in the WYSIWYG Editor did not always load
  • Added edd_fields_get_all_saved_fields() and edd_fields_get_chosen_template() functions to get the saved Fields or chosen Template for a Download.
    • Each function has respective Filters to dynamically inject Fields or alter the chosen Template for Downloads.
  • Updates our Licensing and Support Module to the latest version

1.0.0

  • Initial release