Customer Account Order Page Download Links
Prerequisite: Customer accounts must be enabled on your Shopify store for this feature to work. If you have not enabled customer accounts, go to Shopify Admin > Settings > Customer accounts and enable them before proceeding.
Note - This requires some theme liquid customization: if you need any help, please let us know.
If you have customer accounts enabled on your store, you can now give your customers the ability to view their available downloads from their customer account order page.
We have added stored data on the order metafields. It's saved as a metafield on the order under the namespace kablewith the key digital_products and it looks like:
{
"line_items": [
"<line_item_id>": {
"product_id": <product_id>,
"variant_id": <variant_id>,
"files": [
{
"attachment_type": "file",
"label": <label_of_attachment>,
"filename": <filename>,
"download_url": <url to download file>,
......
}
]
]
}How to access the customer/order.liquid file: In your Shopify admin, go to Online Store > Themes, click Actions > Edit code, then in the left sidebar, locate and select customer/order.liquid under the Templates or Sections folder (depending on your theme). If this file does not exist, you may need to create it or consult your theme documentation.
We've made this new data available to allow you to directly add the download links to the customer's orders directly inside their customer account.
To include this data on a customer's account, you can include a block of code as shown below. This code should be added to your customer/order.liquid file in the theme editor. This code currently displays as a table (as shown below) with the product info and a direct link to their download page. This table can still be styled by editing your Shopify theme code for this page to suit your personal needs, and if you require any assistance, please reach out to us and let us know.
{% for kable_line_item in order.metafields.kable.digital_products.line_items %}
{% assign kable_line_item_id = kable_line_item[0] | plus: 0 %}
<td>
{% if kable_line_item_id == line_item.id %}
{% for file in kable_line_item[1].files %}
<a href="{{ file.download_url }}" target='_blank'>{{ file.label }}</a>{% if forloop.last == false %}, {% endif %}
{% endfor %}
{% endif %}
</td>
{% endfor %}