Download Tag

{exp:store:download}
    <!-- link text -->
{/exp:store:download}

Creating downloadable products is easy and flexible! Using the power of ExpressionEngine channel custom fields, you simply need to add a custom “File” field to store your downloads.

Once you have files associated with your products, use the download tag to allow only users with paid orders to access the download. First ensure the real files are stored in a directory which is hard to guess, or even locked down using .htaccess (because if people can access the real file URL, they can access your downloads without paying!). Next, simply pass the URL to the download tag, along with the order ID. The download tag will ensure the order is paid, and output an A element securely linking to your file.

Download Tag Parameters

url

The real URL to the file the user needs to download. You will usually retrieve this from a custom field in your products channel. The download tag will securely provide access to this file for paid orders. Note that internally this is looked up and traced back to a file ID. Therefore, if the file isn’t visible in the EE File Manager, the download tag won’t work.

order_id

The order this download relates to. Usually you would template the download tag inside an order tag, so just pass this through. If the order has not been paid, the download tag will not return anything.

expire

The number of minutes a user has access to the file for. This is counted from when the order was marked as paid. For example, to allow access to the file download for 24 hours after payment is made, set this to 1440.

id

Adds an id attribute to the resulting anchor element.

class

Adds a class attribute to the resulting anchor element.

style

Adds a style attribute to the resulting anchor element.

Download Tag Variables

The Download tag has no variables. The content between your download tag simply becomes the content inside the outputted A element.

Download Tag Example

ExpressionEngine Tag:

{exp:store:download order_id="{order_id}" url="{download_custom_field}"}
  Download
{/exp:store:download}

Output:

<a href="http://demo.exp-resso.com/?ACT=123&amp;o=1&amp;f=2&amp;k=c791ae3a745c1af05bd9f60b8c791bc95f46b313">
  Download
</a>