Creating Custom Add to Cart Links

A lot of times when building a site or theme with Easy Digital Downloads, you will want to create custom purchase/add-to-cart buttons that allow your users to purchase a digital product. Sometimes the button options that come with EDD are quite suited to your application. Luckily, there is a very simple way to turn any hyperlink into a “purchase button”.

Let’s say that you have a hyperlink displayed on your product details that says “Purchase This”, and you have styled it exactly as you want. The only thing you have left is to turn the link into one that automatically adds the current item to the shopping cart. It’s very simple and the basic format looks like this:

Purchase This



would be replaced with the actual ID number of your download.

If, when clicked, you want the link to automatically take the user to the checkout page, do this:

Purchase This

“” would be replaced with the full URL to your checkout page.

If you are displaying the link on the single page for the “download” post type, then you can do this (it will automatically append the ID):

Purchase This

Sending Customers Straight to PayPal

If you’d like your customers to be sent straight to PayPal, instead of to the checkout page, use a URL like this:

Purchase This


  1. Roman Eirich

    Is there a link to add a specific variation of a product to cart?


    • For variable prices? If so, yes, it’s very similar:

      ?edd_action=add_to_cart&download_id={ID}&edd_options[price_id]={PRICE ID}

      The price ID can be found by counting down from the top of the created price options. The first price option is price_id = 0, the second is price_id = 1. Make sense?


      • Roman Eirich

        Yep, that’s what I mean! THX!


      • Branndon

        Adding this to my WordPress menu removes the square brackets, see example

        Any way around this?


        • Branndon

          I got around it by using special characters

          However any time I save the menu after doing this once, it removes the special characters. I understand why it’s happening, and it would require a big rewrite on your end I believe to fix.


      • Is this currently working?


      • Tom

        This doesn’t seem to work for me. All I get is a redirect to my home page where the url is /?edd_options[price_id]={0}.

        What I’m actually looking to do is have the standard button but just for individual price options: I’m trying to sell music and if I add the download shortcode it displays all the tracks with a button underneath, which is great but is there a way to just post the button for each track?


        • Did you setup each track as a price option or as individual products?


          • Tom

            I’ve tried the simple link both by adding /?edd_action=add_to_cart&download_id={1} and also /?edd_action=add_to_cart&download_id={1}&edd_options[price_id]={0} but both just redirect to home with nothing added to the cart.

            The individual button I can get by putting each track as a separate download: is it not possible to isolate price options for the add to cart button?

          • Can you show me a live URL where you have the links?

  2. Probably best to use something like this: <a href="?edd_action=add_to_cart&download_id=">Add to Cart
    …but a checkout page does (and should anyway) need to be set.


  3. I have raving reviews for your plugin. It’s awesome! Thank you for making it and for sharing your knowledge.

    I know multiple file can be attached to one button. I am looking to have multiple downloads attached to one button. This way, when added to the shopping cart, it lists all the individual downloads as separate items. Is there a way to have multiple downloads attached to one button?

    I guessed at the following shortcode and html script, but they did not work:

    [purchase_link id=”4352,4357,4358,4359,4360,4361,4362,4364,4363,4365,4368,4369,4411″ text=”Add to Cart – $110″ style=”button” color=”orange”]

    Add to Cart – $110

    Your help is greatly appreciated.


    • That’s great to hear!

      There is actually a way to do this, though it works slightly differently. Instead of specifying the product IDs, you can specify a particular category to purchase, and when adding to the cart, every download in the category is added:

      [purchase_collection taxonomy="download_category" terms="#"]

      The # is replaced with the ID you want to purchase. Make sense?


      • It works! Brilliant! You make it too easy! :)

        Just one more question.

        What would the html tag look like? I am attaching it to an image on our site…kind of like a banner ad.

        Thanks so much!


        • Ah, you know what, that’s actually not currently possible. This was a feature I built specifically for one person, so it hasn’t received a lot of attention.

          I’ve just updated it to support using an image to purchase the items, but it won’t be available until the next version. I’m pushing the next version out this weekend probably.


          • Thanks for the quick replies! Much appreciated!

            I found a work around that combines your wizardry with what little I know of coding. Here’s a sample link, if you want to see what I mangled together…

            it works perfect and even sends them directly to their shopping cart for checkout.

            Thanks gain for all your help and hard work. This really is a wonderful plugin. So happy to have found it. Cheers!

          • Whoops. I do not know how to add html in a text box apparently.

            Here is the code without the html < tags:

          • Great!

            To post HTML, first wrap it in PRE tags.

      • abe

        Im having trouble getting it too work when i use the shortcode
        [purchase_collection taxonomy="download_category" terms="20"]
        it downloads everything not just the downloads form the specific category. also is there a way to set a specific discounted price to buy the whole category?


  4. How to make a “Purchase now” button. When user click to this button, website will redirect to the Pay Gate (PayPal or other …). That mean skip Checkout step.


  5. garethmore

    Hi Pippin,
    Is it possible to create a single link that simply goes straight to payment and instant download of one product? Therefore there is no checkout page, you simply click a button that, for example, reads “BUY NOW” and you just go straight through to payment. Is that possible?
    Thanks in advance.


  6. Brad

    Hi Pippin

    Loving this plugin. Is there a way to add a discount code to a URL? I would like to link offsite straight ot the checkout page and include a discount automatically.

    Thanks in advance.


  7. Grady Sibert

    I’m using this code for an add to cart link. Unfortunately if I leave out the /checkout slug (I don’t want to redirect) it refreshes the site to the blog feed… Any tips on having it simply add the item to the cart?

    <a href="?edd_action=add_to_cart&download_id=">Add to Cart


  8. Jan Bosman

    Does this work at all with the Custom Prices extension? I.e.



  9. digital
    I have a form
    Part of it is as follows
    This format is compatible with the plug-in commands whose address is listed at the beginning
    Please update this code for Easy Digital Download

    <input type="hidden" name="product" value="” /><input type="hidden" name="price" value="” /><input type="hidden" name="product_tmp" value="” /><input type="hidden" name="cartLink" value="” />

    update easy digital download
    <a href="?edd_action=add_to_cart&download_id=Add to Cart


    tank you


  10. Branndon

    I read most comments, but didn’t see the exact solution I wanted.

    Is there a shortcode or HTML link I can use as “add to cart” but not redirect them after it’s added? I’d prefer a shortcode that was ajax, so it could say add to cart, then when clicked, it changes to Added, or Checkout.


  11. I’m having a similar issue with the HTML5 “Buy Now” button not accepting EDD add to cart codes. When I put the code in, it changes it when I hit save. The fixes for that mentioned here don’t seem to work for me, either, although I don’t see one specifically for “Add to Cart” but don’t go directly to checkout. I just want to add the track to the cart and have them stay on the page so they can add more. Can you help me with that please? Thanks!


  12. Wart Wamsteker


    I write the text “buy now” on the bottom of my page. I select the text and click “insert/edit link”
    Then I write:
    I save the page and test the link. It will take me to my chechout page but it didn’t add the download withe the id 107. The cart remains empty …

    I tryed to put “” around the download id:“107″
    but that doesn’t seem to be the answer.

    Any ideas?


  13. Rohit Korat

    I have the matrix table of pricing for subscription. i am facing a problem of placing button on price itself. I want my customer to directly add to cart by clicking on that price button. i have placed the short code of button from it shows the code on the price page. i am not getting the price button having price amt.


  14. Awesome plugin! So great! I have to add the buy it now buttons as a description which only accepts html… The little tutorial works perfectly (thankyou!) but is there any way I can have it so the button is the same as if I was using the css code. As in, is there a html code for the grey “add to cart” button?


  15. Okay now if you go to this page :
    and press add to cart it just says that your cart is empty? The code I’m using for the first add to cart on the page is:

    Add To Cart

    what am I doing wrong??


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>