Creating Custom Add to Cart Links

Many 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 not quite suited to your application. Luckily, there is a very simple way to turn any hyperlink into a “purchase button”.

Creating the Link

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:

<a href="http://example.com/?edd_action=add_to_cart&download_id=ID_OF_THE_DOWNLOAD">Purchase This</a>

This

ID_OF_THE_DOWNLOAD

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

You can find the ID of your download by going to Downloads → All Downloads and then clicking on the product you’re looking for. Then in the URL you’ll find the ID you’re looking for

Leave a Reply

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