Skip to content

Instantly share code, notes, and snippets.

@Creativenauts
Created April 2, 2016 05:08
Show Gist options
  • Save Creativenauts/b63042580f321810c6864f63563d258e to your computer and use it in GitHub Desktop.
Save Creativenauts/b63042580f321810c6864f63563d258e to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Change Button Text To "Download Now" When Price = $0.00
function get_download_button() {
$price = edd_get_download_price(get_the_ID());
if ( $price == "0.00" ) {
echo '<a class="your_btn_class" href="/checkout?edd_action=add_to_cart&download_id='.get_the_ID().'">Download Now</a>';
} else {
echo '<a class="your_btn_class" href="/checkout?edd_action=add_to_cart&download_id='.get_the_ID().'">Buy Now</a>';
}
}
@Creativenauts
Copy link
Author

This is a custom function I created to display the button text as "Download now" for downloads that price is equal to $0.00.

You should place this in your themes function.php file.

Calling the function in your theme:

<?php get_download_button() ?>

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