Shortcut to the file in a protected folder

  • Posts: 410
  • Thank you received: 15
5 years 2 weeks ago #305661

-- HikaShop version -- : 4.0.3

Hi, I want to add support to audio player but I come across this problem. My goal after purchasing a product can be to create a playlist from which you can download and listen. The problem is that you need to create a shortcut to the file you should look like this:

"name": "Song Name 1",
"artist": "Artist Name",
"album": "Album Name",
"url": "/song/url.mp3", - problem
"cover_art_url": "/cover/art/url.jpg"

Last edit: 5 years 2 weeks ago by neo191987.

Please Log in or Create an account to join the conversation.

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 2 weeks ago #305664

Hi,

You can't use the direct URL to the file as the folder is protected.
So you have two options:
- you remove the protection on the upload safe folder (which means that as long as someone has the download link, it can get the file)
- you use the link that is given to the customer for the download of the file. In that case, the URL is different for each order. So I'm not sure if you have a way to have such dynamic URL with your audio player ? It might require some custom development in the audio player.

The following user(s) said Thank You: neo191987

Please Log in or Create an account to join the conversation.

  • Posts: 410
  • Thank you received: 15
5 years 2 weeks ago #305707

I managed to get him to start free songs, which is good with this code, now comes the problem that I have to set a link for bought songs. Can some help also want to show if the product is not bought notice (This should show the product page). Also, I want to ask if I create a subscription whether after purchase there may be access to certain product files.

This code automatically generates url addresses:

<?php
foreach($this->element->files as $file) {
$json = array(
  "name" => $file->file_name,
  "artist" => '',
  "album"  => '',
  "url" => hikashop_completeLink('product&task=download&file_id=' . $file->file_id.$url_itemid),
  "cover_art_url" => ''
);
$info = json_encode($json);
echo $info;
echo ',';
}
?>

Last edit: 5 years 2 weeks ago by neo191987.

Please Log in or Create an account to join the conversation.

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 2 weeks ago #305709

Hi,

1. If you want to add a message on the product page when the product has downloadable files available after the purchase, you would have to run a MySQL query on the hikashop_file table with a condition on the column file_free_download equal to 0 and a condition on file_ref_id equal to the product_id and a condition on the file_type equal to "file" to get the files of the product and then display the message if you have some results.

2. If you want to give access to downloadable files after the purchase of a subscription product, you can add these downloadable files in the plan settings.

The following user(s) said Thank You: neo191987

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum