Sending E-product file link in email template

Roman Čapek asked on September 23, 2024 11:07

I would like to include E-product file download link into email template "E-commerce - Order payment notification to customer". According to managing E-products, we should use GetEproductUrl macro. However, its signature requires some input arguments that are dependent on the given order. How can we insert such values into the email template? So far I'm not able to find a way how to get fileToken and fileName using the available macros.

If this is not possible, how can we generate the download link using C# code once the payment is received? I mean, we can insert some middleware triggered by the confimration from payment gate and generate another email with the download link.

Best regards,

Roman Čapek

Correct Answer

Zdeněk Cetkovský answered on September 23, 2024 14:25

In the context of email templates for E-commerce purposes, you can access various entities corresponding to given Order or Shopping cart, Customer, Payment option, Billing and Shipping address, etc. You should be able to see the available entities when entering the macro with the "intellisense", i.e. start typing {% or use the Insert macro dialog. There is also a special entity for e-products: EproductsTable, as you can have more than one e-product per order.

As for E-product links, we have an example in the global email template (you need to switch to "(global)" scope in the selector)
E-commerce - Order payment notification to customer

with the following expression:

{% if (EproductsTable != null && EproductsTable.Any()) { %}
  <p>Your <b>e-products download links were activated</b>, please download the files before their expiration. Once the files expire, you won't be able to download them.</p>
  {% EproductsTable.ApplyTransformation("Ecommerce.Transformations.Order_EproductsTable") %}
{% } #%}

You can see there is another level where the actual e-product link is created, and that's the transformation. You can find it within a special page type serving as a container for transformations. In Page types app, for type "E-commerce - transformations" in the "Order_EproductsTable" transformation, with the default markup as:

 <br />
- {%GetResourceString(OrderItemSKUName)%} (<a href="{%GetEproductUrl(Token, FileName, OrderSiteID)%}" target="_blank" >{%FileName%}</a>) {% String.IsNullOrEmpty(OrderItemValidTo) ? "never expires" : "expires after " + Format(OrderItemValidTo, "{0:G}") #%}

You can see there as now the columns (fields) from the EproductsTable are available for the GetEproductUrl and other methods:
OrderItemSKUName, Token, Filename, OrderSiteID and OrderItemValidTo

Hope this information helps!

Best regards,
Zdenek

1 votesVote for this answer Unmark Correct answer

Recent Answers


Roman Čapek answered on September 24, 2024 08:34

Awesome! Thank you so much for a quick help. It seems to be really well prepared :thumbsup:

Have a nice day, Roman

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.