Markus Michalski FAQ

Sylius Digital Download: Storefront

Sylius Digital Download in the shop: release by payment, email with links, download link and response codes, refunds, list in the customer account, Twig functions, shipping step.

Sylius Digital Download: Storefront

This documentation always describes the latest published version.

The plugin listens to the payment workflow, not to the order:

  1. A payment changes to completed (workflow.sylius_payment.completed.complete).
  2. The plugin checks whether the completed payments of the order cover its total. A partial payment is not enough.
  3. If so, one link per order item and file is created. Links that already exist are never created again.
  4. If there were new links, the email is sent.

PayPal completes the payment automatically. With bank transfer or direct debit, you mark the payment as completed in the order in the admin, which triggers the release. Placing the order creates nothing.

There is one link per file for each order item, regardless of the item's quantity.

The email

The email with the code mmd_digital_download_ready goes to the email address of the order's customer. For each link, it states the product name, the variant, the file name and the download link. If the link has an expiry date or a download limit, that is included as well. The order confirmation never mentions the links.

How to customize the text and appearance of the email is described under Extending.

A link looks like this:

https://shop.example.com/downloads/3f9c…64 characters…a1b2

The token is the access credential, customers do not need an account. That is why the links also work for guest orders. On every request, the plugin checks the link:

State Response
Link valid The file is delivered as a download, the counter increases by one
Link blocked, expired or used up 410 Gone with the text "This download link is no longer valid. Please contact the shop."
Token unknown 404 Not Found
File no longer readable in the storage 404 Not Found, the counter does not increase

A link is blocked if a refund has withdrawn it. It is expired as soon as the expiry date is reached, and used up as soon as the number of downloads has reached the limit.

The file response comes with Cache-Control: private, no-store, X-Robots-Tag: noindex and X-Content-Type-Options: nosniff, the 410 response with Cache-Control: private, no-store and X-Robots-Tag: noindex. The file name in the download is the original name of the uploaded file.

Refunds

If a payment is refunded and the order is no longer fully paid afterwards, the plugin blocks all links of the order. The customer then gets 410 Gone, even if they still have the email. If the order is still fully paid despite the refund, nothing happens. The block also applies when the plugin is switched off.

List in the customer account

Logged-in customers see the Your downloads block on the order page in their account, with one row per link: product, variant and file name, next to it either the Download button or the reason why the link no longer works ("Access was withdrawn", "Link expired", "Download limit reached"). Guests receive their links by email only.

Order page in the customer account with the Your downloads block

The block is attached to the Twig hook sylius_shop.account.order.show.content.main (priority 100). If your theme replaces the template of the order page and no longer renders the hook, the block is missing. The email and the links keep working then.

Custom templates

Two Twig functions are available for a template of your own:

Function Return value
mmd_download_grants(order) All links of the order
mmd_download_blocked_reason(grant) null if the link is usable, otherwise revoked, expired or limit_reached
{% for grant in mmd_download_grants(order) %}
    {% set reason = mmd_download_blocked_reason(grant) %}
    {% if reason is null %}
        <a href="{{ path('mmd_digital_download_shop_download', {token: grant.token}) }}">
            {{ grant.downloadFile.originalFilename }}
        </a>
    {% else %}
        {{ ('mmd_sylius_digital_download.shop.blocked.' ~ reason)|trans }}
    {% endif %}
{% endfor %}

A variant with a file is saved without shipping required. If a cart contains only such items, Sylius skips the shipping step in the checkout.

You can use the same attribute in your checkout to recognize digital items: !ProductVariant::isShippingRequired().

The checkbox for consent to early performance of the contract (§ 356 para. 5 BGB) is not part of the plugin. Your checkout has to provide it itself.