PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

Free download function help...

5 replies to this topic
#1
jonah

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
I know that topic title isn't clear but I didn't know how to word it... really.

What I need is a way to allow free products that are downloaded without a checkout.

If I need to make a module some pointers would be great.
Also I would like it if it didn't reduce stock levels as the free downloads are unlimited.

Thanks.

Jonah

#2
razaro

    PrestaShop Addict

  • Members
  • PipPipPip
  • 954 posts
I don't know if this is right way or if it has some security flows,
but here is code you can put in your theme folder , file product.tpl

http://paste2.org/p/725004

It checks if there is zip file, with same name as product, in your download folder.
You can change type and folder

#3
jonah

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
When I look in my download folder I see a file that has a long file name like: 6959bbae9c89914e59fec6039a522fa7bd65b1c7 . no file extension. How do i decrypt this for that code?

#4
jonah

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
I tried the code but I am not sure where download files go on the server. When I left the code by itself nothing showed up on my store. Can I get more help.

#5
razaro

    PrestaShop Addict

  • Members
  • PipPipPip
  • 954 posts
Sorry i totally misunderstood your question, my bad :red:

Will let you know if i think of something.

#6
razaro

    PrestaShop Addict

  • Members
  • PipPipPip
  • 954 posts
It can be done but with a changes of core files and that is not recommended.

Problem is in getfile.php and format of key.
/* Key format: - */
http://***/get-file....afaf59f32b438d6

And hashOrder is generated after checkout.

Following code is for test purpose only, it skips all validation, so use it on localhost/test server.
In getfile.php (see atachment) i commented out most of code and added
    $file = _PS_DOWNLOAD_DIR_.$key;
$filename = ProductDownload::getFilenameFromFilename($key);

Then in product.php after line 116
        $smarty->assign('virtual', ProductDownload::getIdFromIdProduct(intval($product->id)));

add
        $smarty->assign('dp', ProductDownload::getFilenameFromIdProduct(intval($product->id)));


Then in product.tpl in your theme folder add following code where you want

http://paste2.org/p/726236
ex. after
 


I will try to test with validation options, but anyone who knows better solution, please let us know.
Edit: it is better to rename attach to getfreefile.php and also in added code in product.tpl.

Attached Files