Jump to content

[Solved] Want to provide a download link for signed up customers only


tronetix

Recommended Posts

My file size is 39MB. Attachment upload is maxxed at 24MB, so, it wont work as attachment. I have this and other files in ftp server. What I need is a download link to appear in product page for only customers, not guests or visitors. I can put product in a customer only category but I still want visitors to review the product, just not download.

 

I can not find anything readily available in Prestashop 1.5.4 that would allow this.

 

Any suggestions?

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

I did add Link Block module and set Group Visitors to unauthorized for Link Block. That works but is kind of clubby. Would be best to either have a download link appear in top pull down bar or better yet, inside the product listing short description area. Something similar to how the Favorite module works.

Link to comment
Share on other sites

Not exactly sure wehre you want to put this link, in the product itself, or in the categories (product list)?

if you want it in the product just add the code i posted above below

{if $product->description_short OR $packItems|@count > 0}
 <div id="short_description_block">
  {if $product->description_short}
<div id="short_description_content" class="rte align_justify">{$product->description_short}</div>
  {/if}
  {if $product->description}
  <p class="buttons_bottom_block"><a href="javascript:{ldelim}{rdelim}" class="button">{l s='More details'}</a></p>
  {/if}
  {if $packItems|@count > 0}
  <div class="short_description_pack">
<h3>{l s='Pack content'}</h3>
{foreach from=$packItems item=packItem}
<div class="pack_content">
 {$packItem.pack_quantity} x <a href="{$link->getProductLink($packItem.id_product, $packItem.link_rewrite, $packItem.category)}">{$packItem.name|escape:'htmlall':'UTF-8'}</a>
 <p>{$packItem.description_short}</p>
</div>
{/foreach}
  </div>
  {/if}
 </div>
 {/if}

(line 230 in themes/default/product.tpl)

 

and for product list it is basically the same except you would put that piece of code from my earlier post at the end of the center_block div

<div class="center_block">
<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
 <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
 {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}
</a>
<h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3>
<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>
[iNSERT CODE HERE]
  </div>

(line 39 of themes/default/product-list.tpl)

 

 

the {if $logged} is a prestashop global smarty variable to check if the user is logged in or not, which is what you are looking for if i'm not misstaken

Link to comment
Share on other sites

Thanks but to hard code the links in the products.tpl would make it visible in all products I think.

To make it clean, a download link specific to a certain product in the product itself for non-visitors would be the best. I see at line 504 of products.tpl is the beginning of logic used for attachments and features. Perhaps if something similar was setup for a Download option? If there was a module that would embed download links specific to products like how attachment works but also have the group check, that could solve alot of problems.

However, a pull down menu on the top bar would suffice if setup to disallow visitors. Currently, only categories and modules have visitor/guest/customer group rules. And currently, CMS can not be put in the Top Horiz menu using the backend tools..atleast that I can find.

I'm still checking around and learning more of this tool but thanks for your suggestions.

Link to comment
Share on other sites

what you could do is give the products for which you want this download link a feature called "has-download" for example then you could do this:

{if isset($features)}
  {foreach from=$features item=feature}
   {if $feature.name == "has-download"}
		 {if $logged}
			  download link
		 {/if}
   {/if}
 {/foreach}
{/if}

 

good luck!

 

edit: If the products that need a download link each have a specific downloadable file then you could probably use the attachment option in the products and enclose the {if isset($attachments) && $attachments} part of the product.tpl in {if $logged}

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

I setup a feature called download and since I have 2 files that need to be picked for some of my products (ie for 32bit and 64bit), I setup attributes which would be the file names.

 

I attempted unsuccessfully to create a new tab called Downloads using:

 

{if $feature.name == "has-download"}

{if $logged}

<li><a id="download_links" href="#idTab9">{l s='Downloads'}</a></li>

{/if}

{/if}

 

 

Also, I added this:

 

{if isset($features)}

{foreach from=$features item=feature}

{if $feature.name == "has-download"}

{if $logged}

<a href={$feature.value|escape:'htmlall':'UTF-8'}>{$feature.value|escape:'htmlall':'UTF-8'}{l s=' Download'}</a>

{/if}

{/if}

{/foreach}

{/if}

 

which works fine. Just what I needed.

Now, if a Tab called Downloads could be made for the links instead of Datasheet, that would be perfect.

Link to comment
Share on other sites

You need to call the "foreach features" loop for the tab part also, so:

 

{if $features && $logged}

{foreach from $features item=$feature}

{if $feature.name == "has-download"}

<li><a id="download_links" href="#idTab9">{l s='Downloads'}</a></li>

{/if}

{/foreach}

{/if}

 

you might want to move the "if logged" part somewhere else depending on what you want to do. Hope this helps

Link to comment
Share on other sites

This is the Product Tab area:

<ul id="more_info_tabs" class="idTabs idTabsShort clearfix">

{if $product->description}<li><a id="more_info_tab_more_info" href="#idTab1">{l s='More info'}</a></li>{/if}

{if $attachments}<li><a id="more_info_tab_attachments" href="#idTab9">{l s='Download'}</a></li>{/if}

{if isset($accessories) AND $accessories}<li><a href="#idTab4">{l s='Accessories'}</a></li>{/if}

{if isset($product) && $product->customizable}<li><a href="#idTab10">{l s='Product customization'}</a></li>{/if}

{if $features && $logged}

{foreach from $features item=$feature}

{if $feature.name == "has-download"}

<li><a id="download_links" href="#idTab9">{l s='Downloads'}</a></li>

{/if}

{/foreach}

{/if}

{if $features}<li><a id="more_info_tab_data_sheet" href="#idTab2">{l s='Data sheet'}</a></li>{/if}

 

{$HOOK_PRODUCT_TAB}

</ul>

....

and the features area:

{if isset($features)}

<!-- product's features downloads-->

<ul id="idTab9" class="bullet">

{foreach from=$features item=feature}

{if $feature.name == "has-download"}

 

{if $logged}

<a href={$feature.value|escape:'htmlall':'UTF-8'}>{$feature.value|escape:'htmlall':'UTF-8'}{l s=' Download'}</a>

{/if}

{/if}

{/foreach}

</ul>

{/if}

 

I'm still not getting a tab9 bullet that would be called Downloads. I guess I don't really understand the tabs. Perhaps the download_links id has to be defined elsewhere to be usable or the tab id has to be mapped to the id's?

 

if you want, you could login and check product 21 (IDF modeler). It is the product in question to provide 2 different download options for logged in users. attached is products tpl file for reference. Thanks for the guidance!

product_tpl.txt

Link to comment
Share on other sites

I looked at your product.tpl, the problem is you have the "idTab9" ul twice, so my guess is the attachment "idTab9" is overwriting the features one. Either remove the attachments tab (you are not using atatchments right?) or give your special "features" tab it's own id. Hope that does the trick :)

Link to comment
Share on other sites

Yes, I still want to use attachments on many products. Attachments that are small pdf's etc that would be visible to everyone. I changed the has-download codes to idTab3 but still not showing in a tab. idTab3 wasn't being used for anything else that I could find.

 

attached is product tpl

Thanks

products_tpl.txt

Link to comment
Share on other sites

Defuzed. Well it works now. Don't really know why but I snipped your section of code (which looked the same to me) and it works. I did rename feature from has-downloads to just FIles thinking maybe something is stuck in server cache. Anyways, thanks a bunch! Now I can have attachments both super large and small to satisfy my ISP php upload/download limitations of 24MB.

 

Attached is the final products.tpl for anyone else needing a solution to this problem. Line 504 is where the customization begins. Feature named Files is needed for product. Feature value is the filename which by default is located in root of Prestashop.

product_tpl.txt

  • Like 1
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...