Jump to content

Afficher un %pourcentage sans decimale dans product.tpl


Recommended Posts

Bonjour,

 

Je n'arrive pas à afficher mon pourcentage sans décimale du genre -20% au lieu de 20.1234%

 

Voici la ligne dans mon product.tpl version prestahop 1.5.2.0 :

 

<p id="reduction_percent" {if !$product->specificPrice OR $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}><span id="reduction_percent_display">{if $product->specificPrice AND $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}</span></p>

 

 

j'ai tout essayer en vidant à chaque fois mon cache et compil :

 

-{round($product->specificPrice.reduction*100)}%

***

{$product->specificPrice.reduction*100|round}%

***

{$product->specificPrice.reduction*100|round:2}%

***

{$product->specificPrice.reduction*100|intval}%

***

{$product->specificPrice.reduction*100|floatval}%

***

{$product->specificPrice.reduction*100truncat:2''}%

 

 

Connaitriez-vous une solution ?

 

Merci d'avance !

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 years later...

Bonjour,

J'ai un module bloc nouveauté en page accueil et celui-ci affiche un petit encart avec la réduction en %

Le soucis est que parfois mes produits affiche 30%001 et je ne peux pas modifier manuellement les produits en 30% (car il s'agit de produits importés) je voudrais juste rendre l'affichage de réduction en 30%sur le bloc nouveauté

 

J'ai trouvé sur internet qu'on peut le modifier en CSS avec "width: 40%;"

Malheureusement je ne trouve l'endroit ou le mettre (les test que j'ai effectué a augmenté le fond (le 30% du responsive) :/

Il s'agit seulement sur le bloc nouveauté en page d'accueil car sur la fiche produit il n'affiche déjà pas les .00%

 

Merci d'avance pour votre aide :)

Link to comment
Share on other sites

Voici mon blocnewproducts.css

 

/* Block new products */

#new-products_block_right ul {list-style-type:none;}

#new-products_block_right li {

float:left;

margin-right:20px;

padding:10px 0;

}

#new-products_block_right li.first {margin-left:30px;}

 

#new-products_block_right dl {

list-style-type:none;

}

#new-products_block_right dt {

padding:10px 0 0 0;

font-weight:bold;

font-size:12px;

color:#333;

}

#new-products_block_right dd,

#new-products_block_right dd a {

color:#666;

}

#new-products_block_right dd {

padding:0 0 10px 0;

border-bottom:1px dotted #ccc;

 

}

#new-products_block_right dd.last_item {border:none;}

#new-products_block_right dd a.lnk_more {

padding-right: 10px;

font-weight:bold;

color:#0088cc;

background:url(../img/arrow_right_1.png) no-repeat 100% 4px;

}

 

#new-products_block_right p {

padding:0;

text-align:right;

}

 

#new-products_block_right p.title_block, #new-products_block_right h4  {

padding:6px 11px;

text-align:left;

}

#new-products_block_right .button_large {

padding:0;

border:none;

background:none;

color:#333;

}

#new-products_block_right .button_large:hover {text-decoration:underline}

 

 

 

 

Je dois surement créer une ligne pour lui dire d'afficher sans les .00% mais sur quoi ?

 

#new-products_price-percent-reduction {width: 40%} ??

Link to comment
Share on other sites

Bonjour KevinMD,

 

C'est du coté de smarty qu'il faut aller voir et non pas au niveau des CSS.

 

Ouvre le fichier TPL du module bloc nouveauté et travail la dessus. recherche la ligne ou il y a le code pour la réduction, il faudrait ajouter un {round} au code.

 
Link to comment
Share on other sites

Merci admin974 mais je n'ai pas de ligne de réduction dans le blocnewproducts.tpl :

 

<!-- MODULE Block new products -->

<div id="new-products_block_right" class="block products_block">

<h4 class="title_block"><a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='New products' mod='blocknewproducts'}">{l s='New products' mod='blocknewproducts'}</a></h4>

<div class="block_content">

{if $new_products !== false}

<ul class="product_images clearfix">

{foreach from=$new_products item='product' name='newProducts'}

{if $smarty.foreach.newProducts.index < 2}

<li{if $smarty.foreach.newProducts.first} class="first"{/if}><a href="{$product.link|escape:'html'}" title="{$product.legend|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'medium_default')|escape:'html'}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$product.legend|escape:html:'UTF-8'}" /></a></li>

{/if}

{/foreach}

</ul>

<dl class="products">

{foreach from=$new_products item=newproduct name=myLoop}

<dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link|escape:'html'}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags|escape:html:'UTF-8'}</a></dt>

{if $newproduct.description_short}<dd class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link|escape:'html'}">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:75:'...'}</a><br /><a href="{$newproduct.link}" class="lnk_more">{l s='Read more' mod='blocknewproducts'}</a></dd>{/if}

{/foreach}

</dl>

<p><a href="{$link->getPageLink('new-products')|escape:'html'}" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">» {l s='All new products' mod='blocknewproducts'}</a></p>

{else}

<p>» {l s='Do not allow new products at this time.' mod='blocknewproducts'}</p>

{/if}

</div>

</div>

<!-- /MODULE Block new products -->

 

j'ai que ça :/

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