How to Get Digital Products Download Link through Velo

I’m developing a custom members area in wich I need to show member’s past orders download link (for digital products). The problems are:

  • On “Orders” or “Products” CMS there is no download link to none of the products;
  • The function getOrder() doesn’t return any download link for the digital product, although the createOrder() function does mention:

If an item is digital - lineItems[i].itemType.preset: DIGITAL - then lineItems[i].digitalFile must be provided.

Which makes me believe that the download link to the digitalFile is correlated to the getOrder(), but I can’t figure out where to find it.

  • On the original members area, on “My orders” there is a list of historical orders with a download button, but the link expires in 30 days. On my custom members area I do not want the link to expire. Is that possible?

The main point is to find out how do Wix Stores understand that a file is attatched to a product since this information isn’t on any CMS and the documentation has not much about digital products. Where does the download link comes from when an user completes a purchase? How do I compare user’s orders to the products on my website to provide the downloadable link?

The actual flow is:

  • Retrieve member’s ID;
  • Search for member’s ID on "Orders"CMS and retrieve every order;
  • Define which product the user has access;
  • ?? Get product URL

My understanding of digital item downloads is that they do not currently expire and a user can always continue to download the item (although a given link may eventually expire). There’s even a feature request right now to add expiring downloads: Wix Stores Request: Limiting Time Digital Products are Available for Download | Help Center | Wix.com

As for the question it seems the “Orders” table contains this which has mediaItem.src that looks like a Wix URL: https://www.wix.com/velo/reference/wix-stores-backend/“orders”-collection-fields#wix-stores-backend_“orders”-collection-fields_line-items-lineitems

I haven’t tested this but you might try taking that wix:type:// prefixed url and passing it to downloadFiles - Velo API Reference - Wix.com to get back a download URL for the file.

Thanks for your response, @anthony , but I do not think that this works as well as it should due to some problems:

  • I can’t read Orders table even when running the code on backend, as the image shows, it returns no value.

As the reference states, the Orders collection can only be read with Admin permissions, so I don’t see how the user, when reaching the member’s area, could “access” this data (actually even I couldn’t access the data). Any ideas?

  • As I couldn’t read the Orders table as mentioned before, I couldn’t test it, but i believe that the mediaItem.src is the URL for one of the media available on the product page as the reference example show it on a Physical product. However, maybe the DIGITAL itemType does have a lineItems.digitalFile there, which is just unavailable on this example (and there is no example with an itemType : DIGITAL).

About the products, that’s what I meant, the product is available forever, but the link is not. So I need that every time an user tries to download his product a new link is generated.

This would be done by passing the suppressAuth: true option to your query. The function itself could be exposed to users with a Velo Web Method BUT you’ll want to make sure to not accidentally expose the wrong information to the wrong user.

Will check on this.

This would be done by passing the suppressAuth: true option to your query.

Couldn’t make it work, @anthony . Even when running the query on backend I get no results; the suppressAuth: trueoption does work, but I could find no way to access the CMS. Have you ever tried it yourself? Would you be able to run it and send me a screenshot, if that’s not too big of a request? I really don’t see why it’s not working :frowning:

Also, if you’ve got any news about the lineItems.digitalFile type, it would be wonderful to know.

Thanks for all the help!

Can you share the code that isn’t working? I don’t run a Wix Store so I don’t have an easy way to test but can maybe provide some pointers to help.

Please share your code using this format:

```js
const myCode = ‘here’;
```

This will then display it like:

const myCode = ‘here’;