Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:7181379
Last active February 27, 2016 18:24
Modify the "return to website" text on the PayPal confirmation page, when customer is sent from Easy Digital Downloads. The default text is your site title
<?php
function my_child_theme_edd_paypal_redirect_args( $paypal_args ) {
$paypal_args['cbt'] = 'Return to our site to complete your purchase';
return $paypal_args;
}
add_filter( 'edd_paypal_redirect_args', 'my_child_theme_edd_paypal_redirect_args' );
@amdrew
amdrew / gist:7225903
Last active March 22, 2016 02:35
Add to cart links in EDD
<!-- As indicated by the docs https://easydigitaldownloads.com/docs/creating-custom-add-to-cart-links/ -->
<a href="http://yoururl.com/checkout?edd_action=add_to_cart&download_id=ID_OF_THE_DOWNLOAD">Purchase This</a>
<!-- Following the docs, this doesn't work and adds the download twice -->
<!-- URL looks like this http://eddsupport.sumobithemes.dev/checkout?edd_action=add_to_cart&download_id=10 -->
<a href="http://eddsupport.sumobithemes.dev/checkout?edd_action=add_to_cart&amp;download_id=10">Buy Now</a>
<!--This does work - note the / after checkout -->
<!-- URL looks like this http://eddsupport.sumobithemes.dev/checkout/?edd_action=add_to_cart&download_id=10 -->
@amdrew
amdrew / gist:7241455
Created October 30, 2013 22:28
To block the .mp3 file type in Easy Digital Downloads, we modify the edd_protected_directory_htaccess_rules filter and remove mp3 from the FilesMatch line
<?php
function edd_custom_modify_htaccess_rules( $rules, $method ) {
switch( $method ) :
case 'redirect' :
// Prevent directory browsing
$rules = "Options -Indexes";
break;
@amdrew
amdrew / gist:7259097
Last active December 27, 2015 03:28
Add payment meta information to the admin sales notification in Easy Digital Downloads
<?php
function my_child_theme_edd_sale_notification( $email_body, $payment_id, $payment_data ) {
// retrieve payment meta array and unserialize it
$payment_meta = maybe_unserialize( get_post_meta( $payment_id, '_edd_payment_meta', true ) );
// add your fields here
$company = $payment_meta['company'];
$phone = $payment_meta['phone'];
@amdrew
amdrew / gist:7260341
Last active December 27, 2015 03:38
Gets an array containing of all the payment IDs for a particular download using the get_log_ids() function
<?php
/**
* Get array of payment IDs
*
* @param int $download_id Download ID
* @return array $payment_ids
*/
function get_payment_ids( $download_id = '' ) {
// these functions are used within a class, so you may need to update the function call
$log_ids = $this->get_log_ids( $download_id );
@amdrew
amdrew / gist:7260787
Created November 1, 2013 03:59
Remove page title on homepage
function my_child_theme_static_home_page() {
if ( is_front_page() )
remove_action( 'shopfront_the_title', 'shopfront_render_the_title' );
}
add_action( 'template_redirect', 'my_child_theme_static_home_page' );
@amdrew
amdrew / gist:7422708
Last active December 28, 2015 01:48
Add download categories from Easy Digital Downloads to the post_class
<?php
function my_child_theme_post_classes( $classes ) {
// get the terms from our 'download_category' taxonomy
$terms = get_the_terms( get_the_ID(), 'download_category' );
if ( $terms && ! is_wp_error( $terms ) ) {
// add each term slug to our classes array
foreach ( $terms as $term ) {
$classes[] = $term->slug;
}
@amdrew
amdrew / gist:7422861
Last active September 5, 2024 01:44
Add download categories to the class list of the EDD shortcode
<?php
function my_child_theme_edd_post_classes() {
// get the terms from our 'download_category' taxonomy
$terms = get_the_terms( get_the_ID(), 'download_category' );
// keep our original edd_download class
$classes = array( 'edd_download' );
if ( $terms && ! is_wp_error( $terms ) ) {
@amdrew
amdrew / gist:7424283
Last active November 2, 2018 19:50
Filter the download title in the email to include the price, and quantity. EDD 1.9+ only
<?php
function sumobi_custom_email_receipt_download_title( $title, $item, $price_id ) {
$price = $item['price'];
$quantity = $item['quantity'];
// only show quantity if quantities are enabled
$quantity = edd_item_quantities_enabled() ? ' (quantity: ' . $quantity . ')' : '';
// append price and quantity to title
// Download Title – $50.00 (quantity: 5)
$title .= edd_currency_filter( edd_format_amount( $price ) ) . $quantity;
@amdrew
amdrew / gist:7442983
Created November 13, 2013 03:02
Modify the order and orderby parameters of the downloads shortcode in Easy Digital Downloads to get it working with the simple page ordering plugin
<?php
function my_child_theme_edd_downloads_query( $query, $atts ) {
// modify order and orderby to suit simple page ordering plugin
$query['orderby'] = 'menu_order';
$query['order'] = 'ASC';
return $query;
}
add_filter( 'edd_downloads_query', 'my_child_theme_edd_downloads_query', 10, 2 );