Jump to content

[Résolu] Vignette en fonction de la réduction


Recommended Posts

Bonjour à tous,

 

Actuellement sur ma version de prestashop, j'ai le prix d'origine qui s'affiche, le brix barré, la mention soldes au dessus en texte.

 

Je voudrais affiché une vignette dans un coin de l'image de mon produit, en fonction du pourcentage de réduction..

 

Donc par exemple si :

 

réduction supp à 41% => vignette 50%

si entre 31 et 40 = vignette 40%

si inférieur à 31 = vignette 30%

 

Mon but étant toujours de faires des soldes avec -30 -40 et -50 jamais autre chose.

 

Sachant que actuellement donc mon code, j'ai une fonction qui affiche déjà une vignette différente en fonction du taux de remise mais je ne vois pas comment l'adapté pour moi, je vous mets le code, en espérant que vous pourriez m'aider.

 

{foreach from=$products item=product name=homeFeaturedProducts}
  {assign var='productLink' value=$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)}
  {if $product.price_without_reduction != $product.price}
{math equation='1-(x/y)' x=$product.price y=$product.price_without_reduction assign='txreduc'}
  {else}
{assign var='txreduc' value=0}
  {/if}
  <li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}first_item_of_line{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}">
<a href="{$productLink}" title="{$product.legend|escape:htmlall:'UTF-8'}" class="product_image"><img src="{$img_prod_dir}{$product.id_image}-home.jpg" alt="{$product.legend|escape:htmlall:'UTF-8'}" height="129" width="129" />
{if $txreduc>0.01}
 {if $txreduc>=$percent_asaisir}
<div class="imgasaisir"><img src="{$img_dir}asaisir.png" alt="{l s='A saisir'}" /></div>
 {else}
<div class="imgpromo"><img src="{$img_dir}promo.png" alt="{l s='Promotion'}" /></div>
 {/if}
{/if}

 

Merci pour votre aide :)

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

Solution trouvée, voici mon code, pour ceux que sa pourrait aider, à modifier bien entendu en fonction de votre prestashop, sa vous donne l'idée globale....

 

{if $product.price_without_reduction != $product.price}
 {math equation='1-(x/y)' x=$product.price y=$product.price_without_reduction assign='txreduc'}
   {else}
 {assign var='txreduc' value=0}
   {/if}
   <li class="ajax_block_product {if $smarty.foreach.specialsFeaturedProducts.first}first_item{elseif $smarty.foreach.specialsFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.specialsFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.specialsFeaturedProducts.iteration%$nbItemsPerLine == 1}first_item_of_line{/if} {if $smarty.foreach.specialsFeaturedProducts.iteration > ($smarty.foreach.specialsFeaturedProducts.total - ($smarty.foreach.specialsFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}">
 <a href="{$productLink}" title="{$product.legend|escape:htmlall:'UTF-8'}" class="product_image"><img src="{$img_prod_dir}{$product.id_image}-home.jpg" alt="{$product.legend|escape:htmlall:'UTF-8'}" height="129" width="129" />
 {if $txreduc>0.01}
   {if $txreduc>0.42}
  <div class="imgasaisir"><img src="{$img_dir}50.png" alt="{l s='A saisir'}" /></div>
   {elseif $txreduc > 0.32 AND $txreduc < 0.42}
  <div class="imgpromo"><img src="{$img_dir}42.png" alt="{l s='Promotion'}" /></div>
   {elseif $txreduc < 0.32}
  <div class="imgpromo"><img src="{$img_dir}68.png" alt="{l s='Promotion'}" /></div>
   {/if}
 {/if}

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