Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:6631495
Last active December 23, 2015 11:49
Creates 2 additional fields (company and title) on Easy Digital Download's register account form, and saves them to the newly registered user's profile
<?php
/**
* Add company field to EDD's registration form
*/
function my_child_theme_register_account_fields() { ?>
<p id="edd-user-company-wrap">
<label for="edd-company">
<?php _e( 'Company', 'my-child-theme' ); ?>
@amdrew
amdrew / gist:6644774
Created September 20, 2013 22:28
Make Easy Digital Downloads' discount field show by default
<?php
/**
* Unhook default EDD discount field
*/
remove_action( 'edd_checkout_form_top', 'edd_discount_field', -1 );
/**
* Custom EDD discount field function
*/
@amdrew
amdrew / gist:6645804
Last active December 23, 2015 13:59
Exclude downloads from search in Easy Digital Downloads
<?php
/**
* Exclude downloads from search
*/
function my_child_theme_download_post_type_args( $download_args ) {
$download_args['exclude_from_search'] = true;
return $download_args;
}
@amdrew
amdrew / gist:6943311
Created October 11, 2013 22:59
Format the amount in Easy Digital Downloads to remove the decimal points
<?php
function my_child_theme_edd_format_amount_decimals( $decimals, $amount ) {
$decimals = 0;
return $decimals;
}
add_filter( 'edd_format_amount_decimals', 'my_child_theme_edd_format_amount_decimals', 10, 2 );
@amdrew
amdrew / gist:6956842
Last active December 25, 2015 09:49
Format the amount in Easy Digital Downloads to remove the decimal points, but only if the number is a whole number.
<?php
function my_child_theme_edd_format_amount_decimals( $decimals, $amount ) {
if( floor( $amount ) == $amount )
$decimals = 0;
return $decimals;
}
add_filter( 'edd_format_amount_decimals', 'my_child_theme_edd_format_amount_decimals', 10, 2 );
@amdrew
amdrew / gist:6985653
Last active December 25, 2015 13:39
Get an array containing of all the log IDs for a particular download using the EDD Logging Class in Easy Digital Downloads.
<?php
/**
* Get an array of all the log IDs using the EDD Logging Class
*
* @return array if logs, null otherwise
* @param $download_id Download's ID
*/
function get_log_ids( $download_id = '' ) {
@amdrew
amdrew / gist:7034827
Created October 18, 2013 00:49
Add some text just before the purchase button on the checkout page in Easy Digital Downloads
<?php
function my_child_theme_edd_purchase_form_after_cc_form() { ?>
<p>Enter your text here</p>
<?php }
add_action( 'edd_purchase_form_after_cc_form', 'my_child_theme_edd_purchase_form_after_cc_form' );
@amdrew
amdrew / gist:7065236
Last active December 26, 2015 00:38
Changing the /category/ label in the URL. Eg http://mywebsite.com/downloads/category/ebooks/ to http://mywebsite.com/downloads/cat/ebooks/. Replace "the-new-category-label" with what you'd like.
<?php
function my_child_theme_edd_download_category_args( $category_labels ) {
$slug = defined( 'EDD_SLUG' ) ? EDD_SLUG : 'downloads';
// modify the "the-new-category-label" below to your liking
$category_labels['rewrite'] = array('slug' => $slug . '/the-new-category-label', 'with_front' => false, 'hierarchical' => true );
return $category_labels;
}
@amdrew
amdrew / gist:7077390
Created October 21, 2013 01:20
Add support for genesis cpt archive settings to Easy Digital Download's download post type http://www.carriedils.com/genesis-2-0-archive-settings-custom-post-types/
<?php
function my_child_theme_edd_download_supports( $supports ) {
$supports[] = 'genesis-cpt-archives-settings';
return $supports;
}
add_filter( 'edd_download_supports', 'my_child_theme_edd_download_supports' );
@amdrew
amdrew / gist:7150371
Created October 25, 2013 06:48
Add more required fields
<?php
function my_child_theme_validate_fields( $required_fields ) {
$new_required_fields = array(
'billing_country' => array(
'error_id' => 'invalid_billing_country',
'error_message' => __( 'Please enter your Billing Country', 'edd' )
)