Instantly share code, notes, and snippets.

Embed
What would you like to do?
Modify the standard purchase button on a single download page for each downloads. Simply add new case statements for each download ID
<?php
// remove the standard button that shows after the download's content
remove_action( 'edd_after_download_content', 'edd_append_purchase_link' );
// our own function to output the button
function sumobi_edd_append_purchase_link( $download_id ) {
if ( ! get_post_meta( $download_id, '_edd_hide_purchase_link', true ) ) {
switch ( $download_id ) {
// download with an ID of 11019
case 11019:
$price = 0; // hide price
$class = 'edd-submit my-class-1 my-class-2';// add custom classes
break;
// download with an ID of 11037
case 11037:
$price = 0; // hide price
$class = 'edd-submit some-other-class'; // add custom classes
break;
// defaults that will show for all other downloads
default:
$price = 1;
$class = 'edd-submit';
break;
}
echo edd_get_purchase_link(
array(
'download_id' => $download_id,
'class' => $class,
'price' => $price
)
);
}
}
// rehook/add our function back to the same location as before
add_action( 'edd_after_download_content', 'sumobi_edd_append_purchase_link' );
@ehsankhorasani

This comment has been minimized.

ehsankhorasani commented Aug 1, 2015

Hi
this snippet not work in loop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment