Jump to content

Creating free virtual products with direct download


Recommended Posts

Hey there,

i'm assuming the prestashop addons store is using prestashop itselft (why not to believe in their own software?) and for that reason my question is this:

- you can download free products directly from the addons store. No registration, no checkout process. Just direct dowload. It is possible in prestashop? I tried adding free digital products (setting price to 0), but i still have to go through the checkout process.

 

I just want to substitute the "add to cart" with "download for free" in product page, and allow customers to directly download from there.

 

So, again, is this possible?

 

Fabio

Link to comment
Share on other sites

Hi

 

One of workarounds is to use attachment feature like rocky used on his website

http://www.nethercottconstructions.com/en/prestashop-modules/4-product-links.html

 

Code is already in product.tpl (section with tabs) it only need some styling.

Something like this :

  {if $attachments}
  {foreach from=$attachments item=attachment}
   <p><a href="{$link->getPageLink('attachment.php', true)}?id_attachment={$attachment.id_attachment}"><img src="{$img_dir}download.png" alt="{$attachment.name|escape:'htmlall':'UTF-8'}" title="{$attachment.description|escape:'htmlall':'UTF-8'}"></img></a></p>
  {/foreach}
  {else}
	 <form id="buy_block" ...
.... {/if}

And you can use some additional if/else conditions like if $virtual depending how you set product.

  • Like 1
Link to comment
Share on other sites

Here is maybe better solution, that works for downloadable products.

 

In attachment there are files download-file.php and ProductController.php.

 

File download-file.php should be copied in root directory of prestashop installation.

ProductController.php goes to override/controllers/ folder. If there is already one there

code should be megred.

 

Finialy product.tpl in theme folder should be edited. I choose to hide whole buy_block.

Changed

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->

to

 

{if $virtual AND $product->getPrice(true, $smarty.const.NULL) == 0}
<a href="{$link->getPageLink('download-file.php', true)}?file={$product_filename|escape:'htmlall':'UTF-8'}" title="{l s='download this product'}" class="button">{l s='Free Download!'}</a>
{elseif ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->

 

Note only that this doesn't take in consideration downloadable product options like number of downloads, expiration date and number of days.

 

@girlsgirl12 I didn't quite understand your question, but did you mean something like this ?

directdownload.zip

Edited by razaro (see edit history)
  • Like 3
Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 1 month later...

Here is maybe better solution, that works for downloadable products.

 

In attachment there are files download-file.php and ProductController.php.

 

File download-file.php should be copied in root directory of prestashop installation.

ProductController.php goes to override/controllers/ folder. If there is already one there

code should be megred.

 

Finialy product.tpl in theme folder should be edited. I choose to hide whole buy_block.

Changed

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->

to

 

{if $virtual AND $product->getPrice(true, $smarty.const.NULL) == 0}
<a href="{$link->getPageLink('download-file.php', true)}?file={$product_filename|escape:'htmlall':'UTF-8'}" title="{l s='download this product'}" class="button">{l s='Free Download!'}</a>
{elseif ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->

 

Note only that this doesn't take in consideration downloadable product options like number of downloads, expiration date and number of days.

 

@girlsgirl12 I didn't quite understand your question, but did you mean something like this ?

 

Hi,

 

I did this as you explain, and I get a "Download this product!" button in my free downloads, but when I click this button it gets me to an error page.

 

What is wrong? Do I have to change anything else?

I'm using PS v. 1.5.2

You can see it in http://www.partty.es/es/48-lista-de-invitados-gratis.html

 

Thanks!!

Link to comment
Share on other sites

This was working in 1.4 version but in 1.5 there were some changes, so my previous solution is not working.

When I find solution for 1.5 will post here.

 

Thanks for your reply.

 

This is a very useful module, I hope you can make it work, I can't find any other way to make free downloads easy to my shop customers.

 

Anyway, thanks for the good job made with the module.

Link to comment
Share on other sites

Here is modification for Prestashop version 1.5.

 

Files should be copied with same file structure like in zip file.

So download-file.php should go to root of websites where are rest of main php files.

DownloadFileController.php should be copied to controllers/front folder and

file ProductController.php to override/controllers/front if it not exists there.

If file exists code should be compared and copied apropriate lines.

 

Last step is to change code in product.tpl in current theme folder.

This could be done in different way but here is one. In default theme,

for example, find code arround line 259

 

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}

<!-- add to cart form-->

and replace it with

 

{assign var='virtualproductPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
{if $product->is_virtual AND $virtualproductPrice == 0 }
<a href="{$link->getPageLink('download-file', true,NULL,"file={$product_download->filename}")}" title="{l s='download this product'}" class="button">{l s='Free Download!'}</a>
{elseif ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->

 

And now you have direct download of free virtual products.

free download.zip

Edited by razaro (see edit history)
  • Like 2
Link to comment
Share on other sites

Hi Razaro,

 

thank you very much for your help. It works great.

I have been searching for this function for a long time...and finally you got it!!

 

The only thing I miss is that this don't changes the 'Add to cart' buttons in products categories page, and it will be a little confusing for the users...but I'm not a programmer so I don't know if this is difficult or easy to do (or maybe not possible)

You can see it here http://www.partty.es...escargas-gratis

 

Anyway, thanks again for your great and fast job!!

 

If you don't mind I will share it in the spanish forum, I know that some people where searching for this function too.

Edited by parttyshop (see edit history)
Link to comment
Share on other sites

  • 6 months later...

razaro

 

Nice!! Congratulations!

 

But if I show my product category (ie. 'Free products') where I have all my free products, then every product still show "add cart" button.

 

Only when you enter the specific product the button is "Free Download!".

 

Is possible to put "Free Download!" button in every free product when are showed in the category level ?

I guess I have to go to category.tpl (or similar) and find the code referenced and changed...but how I do this?

 

Thanks!

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...

Here is maybe better solution, that works for downloadable products.

 

In attachment there are files download-file.php and ProductController.php.

 

File download-file.php should be copied in root directory of prestashop installation.

ProductController.php goes to override/controllers/ folder. If there is already one there

code should be megred.

 

Finialy product.tpl in theme folder should be edited. I choose to hide whole buy_block.

Changed

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->
to

 

{if $virtual AND $product->getPrice(true, $smarty.const.NULL) == 0}
<a href="{$link->getPageLink('download-file.php', true)}?file={$product_filename|escape:'htmlall':'UTF-8'}" title="{l s='download this product'}" class="button">{l s='Free Download!'}</a>
{elseif ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->
Note only that this doesn't take in consideration downloadable product options like number of downloads, expiration date and number of days.

 

@girlsgirl12 I didn't quite understand your question, but did you mean something like this ?

 

 

how to edit product-list.tpl. so it looks like product.tpl

i using presta 1.4

 

help me please

 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 3 weeks later...
  • 3 weeks later...
  • 4 months later...
  • 2 months later...
  • 1 year later...

Unless i miss the gist of the thread, there seems to be a logic path missing here: say i offer one free ebook. Store the big file up on AWS for example, create a thank you file with details of the download link. Price it at 0$ as a virtual product. Run through the check out to increase your customer base. They should not receive 3 emails for the cart process (payment accepted) and i would argue, as well, the Order Confirmation. It seems heavy.

 

Thoughts?

Link to comment
Share on other sites

  • 3 years later...
On 1/28/2013 at 9:08 PM, razaro said:

Here is modification for Prestashop version 1.5.

 

Files should be copied with same file structure like in zip file.

So download-file.php should go to root of websites where are rest of main php files.

DownloadFileController.php should be copied to controllers/front folder and

file ProductController.php to override/controllers/front if it not exists there.

If file exists code should be compared and copied apropriate lines.

 

Last step is to change code in product.tpl in current theme folder.

This could be done in different way but here is one. In default theme,

for example, find code arround line 259

 

 


{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}

<!-- add to cart form-->
 

 

and replace it with

 

 


{assign var='virtualproductPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
{if $product->is_virtual AND $virtualproductPrice == 0 }
<a href="{$link->getPageLink('download-file', true,NULL,"file={$product_download->filename}")}" title="{l s='download this product'}" class="button">{l s='Free Download!'}</a>
{elseif ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}
<!-- add to cart form-->
 

hi . can u please help me?

my store is on PS 1.6.1.24

i did all these things. but i faced with fatal error 

:

in address bar :

http://newspower.ir/index.php?controller=download-file&file=

in white page with these words : FATAL ERROR

 

And now you have direct download of free virtual products.

free download.zip 5.49 kB · 248 downloads

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...