I did this exact thing on my development store that's getting ready to go live to replace our old x-cart store. In x-cart 3.5.6, check out skindir/customer/main/order_message.tpl. This is the main order message that is displayed to your customer after placing an order. In it, you will find references to all the templates you need to modify. I believe it references skindir/mail/order_data.tpl, or skindir/mail/html/order_data.tpl. You will need to modify your customer/cart.php page to grab the download keys for the completed order and reassociate them with the proper product. You might not have noticed this unless you've done extensive modding, but x-cart completely empties the contents of your $cart and $products arrays once your order is completed, then it goes and gets all the order data for whatever orderids are passed to the order message screen and displays the data. So all the data is basically "lost" during order placement and then must be re-gathered to display the order message. You can't just pass it to your template after the order is placed, which causes some problems showing the user a download key that was never associated with an orderid. This means that you'll probably need to modify your xcart_download_keys table in your database as I describe below.
I found that using the mail templates for the order message data was not a good option for me, so I created a set of specific order message templates in the customer skin directory:
skindir/customer/main/order_message_header.tpl
skindir/customer/main/order_message_product_data.tpl
skindir/customer/main/order_message_totals.tpl
skindir/customer/main/order_message_customer_info.tpl
which are all referenced by
skindir/customer/main/order_message.tpl
I then built them all as HTML templates and included not only the download link, but also the product thumbnail and a serial number which I generate on the fly based (sort of) on the order number and the productid.
I then modified my HTML mail templates to do the same, so now my e-mail receipts also include thumbnails of each product and full order data.
In order to do all this, I had to make some database modifications.
I added "number_downloads" and "orderid" fields to the xcart_download_keys table to let me track the number times each key is used as well as associating the key with an order number so it could be retrieved after the order is complete. Otherwise, the key is simply sent during the checkout process, but is never associated with an order, so it can't be retrieved and listed in the order message screen. So once you've modified your xcart_download_keys table, you'll then need to modify the code that inserts the download keys (in the moduels/Egoods/send_keys.php file) so that you insert the orderid with the download key.
These modifications will also help you if you want to allow users to view their order history and retrieve their download keys. To modify the order history you need to modify the skindir/main/history_orders.tpl and the customer/order.php page. There may be some other files too. I've modded most of my order/product/cart/customer files and templates so it's hard to remember what relates to what. Webmaster mode is your friend for figuring out which templates are being called by which php files. Anyway, hopefully I've given you a good idea of what you'll need to do to make that happen. Also, below is a copy of my customer/main/order_message_product_data.tpl file. It displays a "download now" button instead of a download link. Maybe it will give you some ideas.
Code:
{* $Id: order_data.tpl,v 1.4 2003/10/03 10:12:11 svowl Exp $ *}
{config_load file="$skin_config"}
<table width="100">
{if $products}
<tr>
<td>
<font size="+1">
{$lng.lbl_products_ordered}
:</font></td>
</tr>
<tr>
<td>{section name=prod_num loop=$products}<table cellpadding="0" cellspacing="0" border="0"><tr><td></td><td><table border=1 bordercolor="#CCCCCC" cellpadding="5" cellspacing="0"><tr><td>
<table border=0 cellpadding=0 cellspacing=0 width="99%">
<tr>
<td colspan="5">
<font size="2">
{* $lng.lbl_product *}
{$products[prod_num].product}
</font>
</td>
</tr>
<tr>
<td rowspan="12" valign="TOP"><a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>
{include file="product_thumbnail.tpl" productid=$products[prod_num].productid image_x=$products[prod_num].image_x product=$products[prod_num].product tmbn_url=$products[prod_num].tmbn_url}
</a></td>
<td></td>
<td>
{$lng.lbl_quantity}
:</td>
<td></td>
<td>
{$products[prod_num].amount}
</td>
</tr>
{if $products[prod_num].product_options ne ""}
<tr>
<td valign=top></td>
<td valign=top>
{$lng.lbl_selected_options}
:</td>
<td></td>
<td valign=top>
{$products[prod_num].product_options|replace:"\n":"
"}
</td>
</tr>
{/if}
<tr>
<td nowrap></td>
<td nowrap>
{$lng.lbl_item_price}
:</td>
<td></td>
<td>
{include file="currency.tpl" value=$products[prod_num].price}
</td>
</tr>
{* egoods key in order data mod by brett *}
{if $products[prod_num].download_key
!= ""}
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="4">
This product is downloadable:</td>
</tr>
<tr>
<td></td>
<td>
{$lng.lbl_filename}
:</td>
<td></td>
<td>
{$products[prod_num].distribution_filename}
</td>
</tr>
<tr>
<td></td>
<td nowrap valign="TOP" colspan="3">
{* $lng.lbl_download_url *}
[img]{$SkinDir}/images/btn_download_now.gif[/img]</td>
</tr>
{if $products[prod_num].serial_number != ""}
<tr>
<td></td>
<td nowrap>
Serial Number:</td>
<td></td>
<td nowrap>
{$products[prod_num].serial_number}
</td>
</tr>
{/if}
<tr>
<td></td>
<td colspan="3"><font size="1">
Instructions: Simply click the link above to
open the download page, then follow the instructions on
that page. Once you have downloaded your product, we strongly
recommend that you back up your program to a safe location
such as cd-rom so that you have easy access to it if you
need to reinstall in the future. If your product requires
a serial number, it will be listed above. You will need
to enter the serial number the first time you run your
program</font>. </td>
</tr>
{/if}
{* end egoods key in order data mod by brett *}
{* begin digital subscription info in order data mod by brett *}
{if $products[prod_num].subscribed_url}
<tr>
<td colspan="4">
Access to this online course:</td>
</tr>
<tr>
<td></td>
<td nowrap>
Login Address:</td>
<td></td>
<td> <a href="{$products[prod_num].subscribed_url}" target="_blank"><font color=red>
{$products[prod_num].subscribed_url}
</font></a> </td>
</tr>
<tr>
<td></td>
<td colspan="3"><font size="1">
Instructions: Simply click on the link
above to log in to your online course. You will need your
username and password that you created during the checkout
process. If you forget your password, just go to
www.realestate-school.com/online-store
and use our password retrieval utility located near the
bottom-left of the page navigation.</font></td>
</tr>
{/if}
{if
not %prod_num.last%}
{/if}
</table></td></tr></table></td></tr></table>
{/section}</td>
</tr>
{/if} {if $giftcerts}
<tr>
<td>
{$lng.lbl_gift_certificates_ordered}:</td>
</tr>
<tr>
<td> <table border=0 cellpadding=0 cellspacing=0 width="99%">
{section name=giftcert loop=$giftcerts}
<tr>
<td></td>
<td>{$lng.lbl_gc_id}:</td>
<td></td>
<td>{$giftcerts[giftcert].gcid}</td>
</tr>
<tr>
<td></td>
<td>{$lng.lbl_amount}:</td>
<td></td>
<td>{include file="currency.tpl" value=$giftcerts[giftcert].amount}</td>
</tr>
<tr>
<td></td>
<td>{$lng.lbl_recipient}:</td>
<td></td>
<td>{$giftcerts[giftcert].recipient}</td>
</tr>
{if $giftcerts[giftcert].send_via eq "P"}
<tr>
<td></td>
<td colspan=3>{$lng.lbl_gc_send_via_postal_mail}</td>
</tr>
<tr>
<td></td>
<td valign=top>{$lng.lbl_mail_address}:</td>
<td></td>
<td valign=top>{$giftcerts[giftcert].recipient_firstname} {$giftcerts[giftcert].recipient_lastname}
{$giftcerts[giftcert].recipient_address}, {$giftcerts[giftcert].recipient_city},
{$giftcerts[giftcert].recipient_state} {$giftcerts[giftcert].recipient_country},
{$giftcerts[giftcert].recipient_zipcode}</td>
</tr>
<tr>
<td></td>
<td>{$lng.lbl_phone}:</td>
<td></td>
<td>{$giftcerts[giftcert].recipient_phone}</td>
</tr>
{else}
<tr>
<td></td>
<td>{$lng.lbl_recipient_email}:</td>
<td></td>
<td>{$giftcerts[giftcert].recipient_email}</td>
</tr>
{/if} {if not %giftcert.last%}
<tr>
<td>[img]../../mail/html/empty.gif[/img]
</td>
<td colspan=3><hr size=1 noshade width=100% align=left color="#DDDDDD"></td>
</tr>
{/if} {/section} </table></td>
</tr>
{/if}
</table>
Using the above template as a rough example, you will still need to modify your cart.php file to collect the download link data and associate it with the proper products before the $orders/$products array is assigned to the order message template. You would do that near the bottom of the customer/cart.php file where you see the code to collect info about orders already placed.
Good luck!