Jump to content

[Solved] How do I add image overlay to products on sale.


Recommended Posts

Hi gofer_p
I got the code from the free temporary template which i used for a while (cheers smenster)

Go to your product.tpl page and find

<!-- product img-->



Just under neath it add the code below

{if $product->on_sale}<!--[if IE 6]><!--[if IE 6]>{/if}
{if $have_image}

Make sure you upload an image to use to your images directory.

But make sure you backup your product.tpl file first.
Link to comment
Share on other sites

Fixed the problem with the blank page.
I copied and pasted a statement twice.

I am not seeing an image just text of the image location. The image name is correct and in the image directory but it is not showing.

Thank you for the assistance so far.

Link to comment
Share on other sites

Fixed the problem with the blank page.
I copied and pasted a statement twice.

I am not seeing an image just text of the image location. The image name is correct and in the image directory but it is not showing.

Thank you for the assistance so far.


hi, I am looking for exactly the same feature but face the very same problems, I added the code above and had a blank product page, then deleted the double {if $have_image} and now I see the product page but only the link to the sale overlaz image which IS in the themes/prestashop/img directoty.

see http://www.lilac-lane.de/baby-eating/157-olive-and-moss-maximilian-the-moose-bib.html

any idea how to fix this?

phil

EDIT: copied the exact code from the template and it basically works, except that it spoils my design so I deactivated it for the time being. but glad there is a way to solve my initial request.
Link to comment
Share on other sites

Ok, I do apologize. you should place the overlay image in you'r theme img file.
I'll start again

Find the below code in product.tpl
<!-- product img-->



Directly underneath it add the following code

{if $product->on_sale}<!--[if IE 6]><!--[if IE 6]>{/if}
{if $have_image}

that's it.

If you want the image file I used, iv'e attached, if you want french or spanish, pm me and ill send them over

All images are thanks to smenster.

36483_wBvZ8Tx0pyXdg8pNsrWq_t

Link to comment
Share on other sites

@CameraTek

I had the image in the correct directory but for some reason it would not work. Maybe it was my theme.

I used this code and it's now working.

{if $product->on_sale}{l s='On sale'}{/if}


Thank you again. I would not have been able to get this done without your assistance.
Thank you for the image. I have not totally decided what image to use yet.

Your on sale image in your new products directory is over the product short description. you might want to put in on the image so the product description is not covered.

check here http://www.uk-cameras.cameratek.co.uk/new-products.php
Link to comment
Share on other sites

  • 2 weeks later...
Ok, I do apologize. you should place the overlay image in you'r theme img file.
I'll start again

Find the below code in product.tpl
<!-- product img-->


Directly underneath it add the following code

{if $product->on_sale}<!--[if IE 6]><!--[if IE 6]>{/if}
{if $have_image}

that's it.

If you want the image file I used, iv'e attached, if you want french or spanish, pm me and ill send them over

All images are thanks to smenster.


hi cameraktek, still fiddling around with the code. which not works. could you please post your code snippet above formatted as, well, code. I believe that line breaks are wrong if I copy paste your code. plus, I already have the part {if $have_image}. shall I really add it twice in a row? here's my code:

    <!-- right infos-->

       <!-- product img-->

       {if $have_image}
getImageLink($product->link_rewrite, $cover.id_image, 'large')}" {if $jqZoomEnabled}class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox')}"{else} title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" {/if} id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
       {else}
Link to comment
Share on other sites

  • 2 weeks later...

Ok I came back to this thread ...

I got it to work on my WAMP ... anyway .. here's what you do

add this code in products.tpl under

For overlay image on new products.

{if $product->new}<!--[if IE 6]><!--[if IE 6]>{/if}



and add this at the very end of your global.css

.new_image {
position:absolute;
z-index:2;
}



CameraTek has forgotten to tell you the second bit in global.css .. that's why some of us who are using different theme are having the picture either with just a text link or a picture on top of the product picture....

The same goes for onsale products .... just change to onsale accordingly


Link to comment
Share on other sites

Hi,
Here's the template I used http://www.prestashop.com/forums/viewthread/66386/themes/free_theme_temporary
Have you uploaded an image to your image directory?


Well that's because you are using this template above .. I downloaded the template and cross check with mine and found the global.css has the above statement ... so I added it in .. and viola ....... since you were using the above template .. you had it already in the global.css .... did you check your global.css.... ?
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 2 weeks later...

Its impposible to make overlay picture on Featured products ? And why my picture doesnt show up on the front page its only show up in product page ? Can someone help me with this code ? I think this code would be useful for other prestashop users not only for me. So please help me to solve this problem. PS 1.4

Thank You !

Link to comment
Share on other sites

  • 2 months later...

Hi costed
i have been looking into this and how to get it on the featured block and i have done it follow below

open product-list.tpl

Find

{if isset($product.online_only) && $product.online_only}{l s='Online only!'}{/if}



Replace from

{if isset($product.online_only) && $product.online_only}



add this

{l s='online only'}<!--[if IE 6]>{/if}


so should look like this
{if isset($product.online_only) && $product.online_only}<!--[if IE 6]>{/if}



You can use this method with each one ie on sale and new and it will show images in home featured hope this helps

i have done this on my site www.imbuyingthat.com and it works great

Link to comment
Share on other sites

  • 1 month later...

Hi.

 

I don´t get it. I want to put an onsale overlay image over my product image. I added the code like said before. My product.tpl now looks like this:

 

  <!-- product img-->
               {if $product->on_sale}<!--[if IE 6]>{/if}
               <div id="image-block">
               {if $have_image}

That one doesn´t work for me, because of the close tag '>' after '[if IE 6]'. A lot of code is greyed out after that. Isn´t the right tag '-->'?

Then CameraTek said the code is:

 

{if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if}

So I edited my product.tpl and now I only have a text with the link to the onsale image (which is correct) above my product-image (not laying over it). I´m stuck here. Any suggestions?

 

I´m using Presta 1.4.3 and a slightly modified standard-theme.

 

Thank you in advance!

Link to comment
Share on other sites

I have also tried:

{if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if}

 

And haven't gotten it to work. My image name is sale_img_en.png and is located in the image directory of my theme. In my product.tpl I have written it as both:

 

{if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if}

 

and:

 

{if $product->on_sale}{$img_dir}sale_img_en.png{/if}

 

These are the only lines I have added/changed in my product.tpl and I have not added anything to my global.css or any other files.

I am currently running version 1.4.4. Am I missing something?

 

EDIT: I was actually able to figure it out. Since my product.tpl was already heavily modded, there was a very necessary portion of code that I needed to uncomment out. All fixed and works perfectly!

Link to comment
Share on other sites

I have also tried:

{if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if}

 

And haven't gotten it to work. My image name is sale_img_en.png and is located in the image directory of my theme. In my product.tpl I have written it as both:

 

{if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if}

 

and:

 

{if $product->on_sale}{$img_dir}sale_img_en.png{/if}

 

These are the only lines I have added/changed in my product.tpl and I have not added anything to my global.css or any other files.

I am currently running version 1.4.4. Am I missing something?

 

EDIT: I was actually able to figure it out. Since my product.tpl was already heavily modded, there was a very necessary portion of code that I needed to uncomment out. All fixed and works perfectly!

 

Could you please upload your product.tpl or paste your 'product img' code, because I tried it with the out-of-the-box product.tpl but it doesn´t work. Thank you.

Link to comment
Share on other sites

Hi There,

 

since the solutions showed above didn´t work for me, I´ve found an easy solution that did. I edited my product.tpl:

 

 <!-- product img-->
               {if $product->on_sale}<img src="{$img_dir}sale_img_{$lang_iso}.png" id="overlay"  /> {/if}

 

and I added a line in my product.css:

 

img#overlay
{
z-index:999;
position:absolute;
       margin-top:0px; /*If you wish to move your Image*/
margin-left:0px;/*If you wish to move your Image*/
width:120px; /*your image width*/
height:107px; /*your image height*/
}

 

 

For the product-list.tpl, this one works for me:

 

<div class="center_block">

           {if isset($product.on_sale) && $product.on_sale}<img src="{$img_dir}sale_img_{$lang_iso}.png" id="overlay" />{/if}

 

and in product_list.css:

 

img#overlay
{
z-index:999;
position:absolute;
       margin-top:0px; /*If you wish to move your Image*/
margin-left:0px;/*If you wish to move your Image*/
width:120px; /*your image width*/
height:107px; /*your image height*/
       display:block
}

 

I hope that helps others with the same problem I had.

 

Cheers.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Hey Guys.

Hope that someone can help me out.

 

Implementet this code:

 

 <!-- product img-->
 <div id="image-block">
 {if $have_image}
 {if $product->on_sale}
 <div  style="position: absolute; margin-top:193px; margin-left:194px; float: left; width: 106px; height: 107px; z-index:101; background: url(/themes/prestashop/img/tilbud_sticker.png)">
  <div style="text-align:center; padding-top: 45px; font-size: 16px;">Tilbud</div>
 </div>
   {elseif ($product->reduction_price != 0 || $product->reduction_percent != 0) && ($product->reduction_from == $product->reduction_to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $product->reduction_from))}
 <div  style="position: absolute; margin-top:193px; margin-left:194px; float: left; width: 106px; height: 107px; z-index:101; background: url(/themes/prestashop/img/tilbud_sticker.png)">
  <div style="text-align:center; padding-top: 35px; font-size: 16px;">
   {if $product->reduction_percent != 0}
    SPAR<br />{$product->reduction_percent}%
   {elseif $product->reduction_price != 0}
    SPAR<br />{convertPrice price=$product->reduction_price}
   {else}
    <div style="padding-top:10px;">Tilbud</div>
   {/if}
  </div>
 </div>
   {/if} 

  {if $have_image && !$jqZoomEnabled}
  <span id="view_full_size">
   <img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large')}" {if $jqZoomEnabled}class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox')}"{else} title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" {/if} id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
   <span class="span_link">{l s='View full size'}</span>
  </span>
  {/if}


 {else}
  {if $have_image && !$jqZoomEnabled}
  <span id="view_full_size">
   <img src="{$img_prod_dir}{$lang_iso}-default-large.jpg" id="bigpic" alt="" title="{$product->name|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />
   <span class="span_link">{l s='View full size'}</span>
  </span>
  {/if}
 {/if}
 </div>
 {if isset($images) && count($images) > 0}

 

Like here:

http://www.homeshop.dk/97-weber-q-320.html

 

But it just don't show up one the new page:

http://homeshop.rushnetworks.dk/product.php?id_product=409

 

Can anyone see why?

 

Thanks

Link to comment
Share on other sites

I gave up couldn't get it work at all after trying every single combination :(

 

The only way I can get it to display the image is if I write the code like this:

<!-- product img-->

{if $product=on_sale}<img src="{$img_dir}sale_img_{$lang_iso}.png" id="overlay" /> {/if}

When adding "=" it displays the image name on top of the product but everything else disappears, anyone with a clue about it?

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

hello

 

I Whant to add new products and on sale overlay image in the homfeatured.tpl...

 

in the PS 1.4.7 I now how i can do, but in the 1.5.3 it´s a litle problem.

 

I have make this:

 

{if $product->on_sale}
<div class="rea">
</div>
{/if}

 

in the global.css

#featured-products_block_center_li .rea {
float: right;
   display: inline;
	background: transparent url('../img/rea.png') no-repeat top left;
color: white;
  width: 65px;
height: 65px;
margin: 0;
  position: absolute;
  margin: -15px 0 0 100px;
}

 

but i dont make it to work...

 

Please help me.

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

  • 9 months later...

Thank you for the quick reply.

I added {if $product->on_sale}{$img_dir}sale_img_{$lang_iso}.png{/if} right under <!-- product img--> and above {if $have_image} in product.tpl. 

I'm not HTML savvy and am learning as I go. Once I added the code and it gave me a blank page I went back in to just delete the code but not it's still giving me the blank page however now in the URL on the page it has -.html# at the end. 

Our store is not open yet and we're using PrestaShop 5.1. Here is the link to the store http://buddhajewelryorganics.com/BuddhaShop/en/

 

I hope this is the right information you need.

As far as turning on terror reporting, where do I do that?

Link to comment
Share on other sites

Turned errors page on and this is what it says.

 

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/home/buddhaje/public_html/BuddhaShop/themes/theme724/product.tpl" on line 710 "{/if}" unclosed {if} tag' in /home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(118): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unclosed {if} t...') #1 /home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(206): Smarty_Internal_SmartyTemplateCompiler->doCompile('{*??* 2007-2013...') #2 /home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_template.php(187): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template)) #3 /home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_templatebase.php(155): Smarty_Internal_ in/home/buddhaje/public_html/BuddhaShop/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 667

 

 

I have no idea what any of it means as I don't read HTML. 
Can you help me?

 

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...