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.

For example, to create a secure download URL for a file stored in a custom field named cf_download, you would use the following parameter:

url="{cf_download}"

Note that if you are displaying a download link inside the Orders tag, custom fields are not automatically available to use. You will need to embed the download tag inside a Channel Entries tag to access the product custom fields. See the example at the bottom of this page for more information.

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="minutes"

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="value"

Adds an id attribute to the resulting anchor element.

class="value"

Adds a class attribute to the resulting anchor element.

style="value"

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:orders order_id="1"}
    <p>Downloads:</p>
    <ul>
        {items}
            <li>
                {exp:channel:entries entry_id="{entry_id}"}
                    {exp:store:download order_id="{order_id}" url="{download_custom_field}"}
                      Download
                    {/exp:store:download}
                {/exp:channel:entries}
            </li>
        {/items}
    </ul>
{/exp:store:orders}

Output:

<p>Downloads:</p>
<ul>
    <li>
        <a href="http://store.example.com/?ACT=123&amp;o=1&amp;f=2&amp;k=c791ae3a745c1af05bd9f60b8c791bc95f46b313">
            Download
        </a>
    </li>
</ul>
Store 2 and 3 Documentation  ·  Store 1.6 Documentation