For Developers

Download Invoice Using the Access Token

If you allow to not logged customers to display their order detail using the order access feature, you can also make them their e-shop documents accessible (downloadable) here.

  1. You need to edit the page with the order detail, where the info about the order is displayed.

  2. Modify its code and check the access token: request.params[ ‘accessToken’ ]. Test if the parameter carries a value:

    {% set token = request.params.accessToken %}
                {% if token %}
                    {% set tokenParam = '&accessToken=' ~ request.params.accessToken %}
                {% else %}
                    {% set tokenParam = '' %}
                {% endif %}
  3. Now use the tokenParam value to make the document download available. The particular download link for the invoice can look like this:

    {% if order.hasInvoice %}
                    <td class="normal">{{ _( 'Download Invoice' ) }}</td>
                            <td><a target="_blank" href="/__api/order/getinvoice?orderId={{ }}{{ tokenParam }}">{{ _( 'Invoice' ) }}</a></td>
    {% endif %}


Remember that the accessToken parameter has to be used only in case you work with the order access feature and want to allow not logged users to download e-shop documents. For logged customers there is no need to make this adaptation.

See also

Order Access