When you create a new download with Easy Digital Downloads, a purchase button is automatically appended to the bottom of your single download pages. What if you’d like to modify this button to add new CSS classes, or remove the price?

There’s an option on each download’s edit/publish screen to “Disable the automatic output of the purchase button”, which would allow you to use the [[purchase_link]] shortcode instead (giving you access to all the parameters), but there’s another way if you don’t mind doing it through code.

First we need to unhook/remove the default function that outputs the button, make a copy of the function, and then re-hook/add our function into the same location. The default location this button as mentioned above is at the bottom of the download pages, which uses the edd_after_download_content hook.

Copy and paste the code below (mind the opening PHP tag) into your child theme’s functions.php or custom plugin and adjust as necessary.

This example show you how to add a new CSS class called my-new-class, and turns the purchase button’s price off:

The edd_get_purchase_link function you see above accepts all of the same arguments as the [[purchase_link]] shortcode. This is because the shortcode actually uses the exact same function.

You can also go one step further and modify the button on a per download level. The example below uses a simple PHP switch statement, checking for each download ID:

14 comments

      1. hi…
        humm…
        where edit this “text” fonction?
        file for edit?

        easy-digital-downloads/includes/template-functions.php ?
        does i modify an existing fonction or add this fonction ?
        can you make a screenshoot of this edit ?
        i need a button text : “achetter” and no “purchase”
        sorry , im new…
        thanks in advance
        PS: maybee the texts buttons can be traduct when we change the language in settings…
        (next update)

  1. Hi, is there a way to remove the title from the single-page template using the ‘remove_action’?
    Thanks

    1. Depends if your theme has a hook for it. Otherwise, create a child theme and remove the the_title from your single-download.php template

  2. Hi,

    Is this code for this? http://screencast.com/t/W6PAjdNVYPbg
    The ADD TO CART button for each service we are featuring? If so, can you please help me remove it? I’m not really familiar with codes that’s why I’m not sure what to do. We just want to have the DETAILS button showed and no price also. We want to info to be seen once they click on the DETAILS button.

    Thanks!

      1. Greetings,

        I had a similar question to one you responded to. I would also like change the text to “Added to Cart” instead of “checkout” but I tried doing that in “Complete Purchase Text” but was not succesful. Would I need to add it as a function to EDD? or somewhere where I can edit text only?

        Thanks

  3. When I create a new page and paste the document purchase shortcode there, the page and the button are in the correct layout. However, the buttons aren’t appearing how I would like/how they appear in the download page. (The font color and hover font color). Basically would you be able to provide me the css so both the font and font hover color of the button can be changed?

    I’m not very familiar with css and I’ve been trying to read articles and watch tutorials, but I can’t seem to find this answer anywhere. 🙁
    I would really appreciate it if you could help!

    I would also like to be able to change the actual button colors to a custom #, but I don’t know the css to do so either. If you could provide that too, it would be great.
    If not, I would at least really appreciate if you could for the font color and font hover color.

    Thank you!
    Brooke

Comments are closed.