Jump to content

Ajouter prix barré et réduction listing produit


stillen

Recommended Posts

Vous désirez afficher le prix barré et le montant de la réduction dans le le listing produit prestashop 1.5, voilà la solution...

 

Ajouter ligne 54 dans themes/default/product-list.tpl :

<!-- Reduction (percent or amount) -->
{if $product.price_without_reduction neq $product.price}
			{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}

			 {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_percent"><span class="reduction_percent_display">-{$pro_specific_prices.reduction * 100|floatval}%</span></p>
					 {/if}

					 {if $pro_specific_prices.reduction_type eq 'amount' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_amount"><span class="reduction_amount_display">-{$pro_specific_prices.reduction|floatval}€</span></p>
							{/if}
					 {/if}
				{/if}<!-- End Reduction -->
<!-- Old price -->
<p id="old_price"><span class="bold">
 {if $priceDisplay >= 0 && $priceDisplay <= 2}
	  {if $product.price_without_reduction > $product.price}
			<span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
					{if $tax_enabled}
						{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
					{/if}
	 {/if}
  {/if}
</p><!-- End Old price -->

 

Ajouter ligne 164 dans themes/default/css/product_list.css :

.reduction_percent,
.reduction_amount {
  display: block;
  float: right;
   margin-left:10px;
  padding: 0 0 0 10px;
  font-weight: bold;
  font-size: 12px;
  color: #fff;
   background: url(../img/bg_reduction.png) no-repeat 0 0 transparent
}
.reduction_percent span,
.reduction_amount span {
  display: block;
  padding: 1px 5px 1px 0;
  background: url(../img/bg_reduction.png) no-repeat 100% 0 transparent
}

 

Si un développeur confirmé passe par là et peut vérifier le code, ça serait top.

 

Nativement Prestashop devrait gérer cette possibilité d'afficher la réduction dans le listing produit.

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

  • 3 weeks later...

Vous désirez afficher le prix barré et le montant de la réduction dans le le listing produit prestashop 1.5, voilà la solution...

 

Ajouter ligne 54 dans themes/default/product-list.tpl :

<!-- Reduction (percent or amount) -->
{if $product.price_without_reduction neq $product.price}
			{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}

			 {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_percent"><span class="reduction_percent_display">-{$pro_specific_prices.reduction * 100|floatval}%</span></p>
					 {/if}

					 {if $pro_specific_prices.reduction_type eq 'amount' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_amount"><span class="reduction_amount_display">-{$pro_specific_prices.reduction|floatval}€</span></p>
							{/if}
					 {/if}
				{/if}<!-- End Reduction -->
<!-- Old price -->
<p id="old_price"><span class="bold">
 {if $priceDisplay >= 0 && $priceDisplay <= 2}
	  {if $product.price_without_reduction > $product.price}
			<span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
					{if $tax_enabled}
						{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
					{/if}
	 {/if}
  {/if}
</p><!-- End Old price -->

 

Ajouter ligne 164 dans themes/default/css/product_list.css :

.reduction_percent,
.reduction_amount {
  display: block;
  float: right;
margin-left:10px;
  padding: 0 0 0 10px;
  font-weight: bold;
  font-size: 12px;
  color: #fff;
background: url(../img/bg_reduction.png) no-repeat 0 0 transparent
}
.reduction_percent span,
.reduction_amount span {
  display: block;
  padding: 1px 5px 1px 0;
  background: url(../img/bg_reduction.png) no-repeat 100% 0 transparent
}

 

Si un développeur confirmé passe par là et peut vérifier le code, ça serait top.

 

Nativement Prestashop devrait gérer cette possibilité d'afficher la réduction dans le listing produit.

 

Bonjour,

Comment intégrer cela dans le catalogue CSV à importer ?

Je mets une valeur Old Price ??

Link to comment
Share on other sites

  • 2 weeks later...

Bonjour,

J'ai testé cette solution sur mon site www.oriames.fr pour mon produit orialgic, malheureusement, la réduction n'apparait pas dans la catégorie produits phares, je suis en version 1.4.6.2, pouvez-vous m'aider à résoudre ce problème.

Merci par avance

 

Bonjour.

Il y a une solution là http://www.prestashop.com/forums/topic/117826-prix-barre-dans-les-produits-phares-en-page-dacceuil/ mais c'est pour la version 1.4.3 de prestashop, je sais pas si ca marche pour le 1.5.2 j'ai tenté mais je trouve pas la ligne /* display: block /* dans le global.css

 

Demande à l'auteur peut être qu'il pourra t'aider.

 

Bonne chance.

Link to comment
Share on other sites

Merci pour ta réponse, je ne sais pas comment contacter l'auteur ?

 

C'est rien.

Tu clique sur son profil, et y a un onglet 'send a message'.

Apparemment le code est adaptable sur 1.5 il faut juste trouver comment agrandir les dimensions des blocs produits sur le module 'produits phares' normalement via le global.css mais comme c'est pas organisé pareil que le 1.4 je peux pas te dire ou regarder...

 

Parcque ca marche, mais c'est pas visible vu que ca ajoute une ligne pour l'ancien prix (barré) qui dépasse du cadre de l'objet.

Link to comment
Share on other sites

merci infiniment pour ton aide, je viens de poster ma demande à l'auteur.

 

dans themes/theme288/css, je ne trouve pas product_list.css, la capture d'écran ne passe pas !!!

 

Y a pas de soucis, j'y connais pas grand chose en code alors quand je peux aider. Parcque si on m'aider pas je sais pas où en serait mon site :D

Link to comment
Share on other sites

  • 5 weeks later...

Bonjour,

 

J'ai utilisé votre code et bizarrement, le prix barré apparaît de temps en temps sur des prix ou il n'y a pas de réduction. Le prix apparaît barré et pas barré, j'ai ajouté "&& $product.price_without_reduction != $product.price" dans le code mais rien ne change, si je modifie le prix sans changer les autres paramètres le prix barré disparait... Avez vous une idée du problème ?

 

Voir ici : http://www.cycles-mari.com/index.php

 

Merci

 

 

PS : J'ai dupliqué la fiche "CADRE BH ULTRALIGHT 2012" avec le prix à 1 890,00 le prix apparait 2 fois (barré et pas barré) et avec le prix 1889,00 il n'y est qu'une fois ???

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

  • 4 months later...

Vous désirez afficher le prix barré et le montant de la réduction dans le le listing produit prestashop 1.5, voilà la solution...

 

Ajouter ligne 54 dans themes/default/product-list.tpl :

<!-- Reduction (percent or amount) -->
{if $product.price_without_reduction neq $product.price}
			{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}

			 {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_percent"><span class="reduction_percent_display">-{$pro_specific_prices.reduction * 100|floatval}%</span></p>
					 {/if}

					 {if $pro_specific_prices.reduction_type eq 'amount' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_amount"><span class="reduction_amount_display">-{$pro_specific_prices.reduction|floatval}€</span></p>
							{/if}
					 {/if}
				{/if}<!-- End Reduction -->
<!-- Old price -->
<p id="old_price"><span class="bold">
 {if $priceDisplay >= 0 && $priceDisplay <= 2}
	  {if $product.price_without_reduction > $product.price}
			<span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
					{if $tax_enabled}
						{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
					{/if}
	 {/if}
  {/if}
</p><!-- End Old price -->

 

Ajouter ligne 164 dans themes/default/css/product_list.css :

.reduction_percent,
.reduction_amount {
  display: block;
  float: right;
margin-left:10px;
  padding: 0 0 0 10px;
  font-weight: bold;
  font-size: 12px;
  color: #fff;
background: url(../img/bg_reduction.png) no-repeat 0 0 transparent
}
.reduction_percent span,
.reduction_amount span {
  display: block;
  padding: 1px 5px 1px 0;
  background: url(../img/bg_reduction.png) no-repeat 100% 0 transparent
}

 

Si un développeur confirmé passe par là et peut vérifier le code, ça serait top.

 

Nativement Prestashop devrait gérer cette possibilité d'afficher la réduction dans le listing produit.

 

Je recherchais une solution au problème d'affichage des réductions sur le listing des produits et votre solution fonctionne à merveilles :D :D :D :D .

 

Merci pour l'aide que vous apportez aux personnes étant novice, cela fait plaisir un peu d'entraide.

 

Vous pourrez constater sur cette page que les réductions et le prix barré sont bien appliqués sur la liste des produits et produits phares.

 

Pour ceux qui souhaite avoir les fichiers modifiés selon le tuto de "STILLEN" et qui pour ma part qui suis en 1.5.3 fonctionne très bien, contactez moi en MP.

 

[Modéré]

Edited by Muche
pubicité (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Bonjour,

 

je suis en v1.5.4, je vous remrecie pour votre code ça fonctionne parfaitement mais j'ai toujours un problème avec ces prix barrés: ils ne s'affichent pas sur la fiche produit lorsque je fais des règles de prix catalogue! Ils s'affichent seulement lorsque je crée des règles spécifiques et que je coche la case "afficher une icône en solde" dans chaque fiche produit!

J'ai du rater quelque chose dans mon code, je ne comprends pas!!

Le voici:

       	 <div class="price">
               {if !$priceDisplay || $priceDisplay == 2}
                   {assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
                   {assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
               {elseif $priceDisplay == 1}
                   {assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)}
                   {assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(true, $smarty.const.NULL)}
               {/if}

               <p class="our_price_display">
               {if $priceDisplay >= 0 && $priceDisplay <= 2}
                   <span id="our_price_display">{convertPrice price=$productPrice}</span>
                   <!--{if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))}
                       {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
                   {/if}-->
               {/if}
               </p>

               {if $product->on_sale}
                   <img src="{$img_dir}onsale_{$lang_iso}.gif" alt="{l s='On sale'}" class="on_sale_img"/>
                   <span class="on_sale">{l s='On sale!'}</span>
               {elseif $product->specificPrice AND $product->specificPrice.reduction AND $productPriceWithoutRedution > $productPrice}
                   <span class="discount">{l s='Reduced price!'}</span>
               {/if}
               {if $priceDisplay == 2}
                   <br />
                   <span id="pretaxe_price"><span id="pretaxe_price_display">{convertPrice price=$product->getPrice(false, $smarty.const.NULL)}</span> {l s='tax excl.'}</span>
               {/if}
           </div>
<!--            <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> -->
           <p id="reduction_amount" {if !$product->specificPrice OR $product->specificPrice.reduction_type != 'amount' && $product->specificPrice.reduction|intval ==0} style="display:none"{/if}><span id="reduction_amount_display">{if $product->specificPrice AND $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|intval !=0}-{convertPrice price=$product->specificPrice.reduction|floatval}{/if}</span></p>
           {if $product->specificPrice AND $product->specificPrice.reduction}
               <p id="old_price">
               <span class="bold">
               {if $priceDisplay >= 0 && $priceDisplay <= 2}
                   {if $productPriceWithoutRedution > $productPrice}
                       <span id="old_price_display">{convertPrice price=$productPriceWithoutRedution}</span>
                       <!-- {if $tax_enabled && $display_tax_label == 1}
                           {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
                       {/if} -->
                   {/if}
               {/if}
               </span>
               </p>
           {/if}

Link to comment
Share on other sites

  • 2 months later...

Vous désirez afficher le prix barré et le montant de la réduction dans le le listing produit prestashop 1.5, voilà la solution...

 

Ajouter ligne 54 dans themes/default/product-list.tpl :

<!-- Reduction (percent or amount) -->
{if $product.price_without_reduction neq $product.price}
				{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}
						  
				 {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_percent"><span class="reduction_percent_display">-{$pro_specific_prices.reduction * 100|floatval}%</span></p>
						 {/if}
								
						 {if $pro_specific_prices.reduction_type eq 'amount' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_amount"><span class="reduction_amount_display">-{$pro_specific_prices.reduction|floatval}€</span></p>
								{/if}
						 {/if}
					{/if}<!-- End Reduction -->
<!-- Old price -->
<p id="old_price"><span class="bold">
	 {if $priceDisplay >= 0 && $priceDisplay <= 2}
		  {if $product.price_without_reduction > $product.price}
				<span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
						{if $tax_enabled}
							{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
						{/if}
		 {/if}
	  {/if}
</p><!-- End Old price -->
Ajouter ligne 164 dans themes/default/css/product_list.css :

.reduction_percent,
.reduction_amount {
   display: block;
   float: right;
    margin-left:10px;
   padding: 0 0 0 10px;
   font-weight: bold;
   font-size: 12px;
   color: #fff;
    background: url(../img/bg_reduction.png) no-repeat 0 0 transparent
}
.reduction_percent span,
.reduction_amount span {
   display: block;
   padding: 1px 5px 1px 0;
   background: url(../img/bg_reduction.png) no-repeat 100% 0 transparent
}
Si un développeur confirmé passe par là et peut vérifier le code, ça serait top.

 

Nativement Prestashop devrait gérer cette possibilité d'afficher la réduction dans le listing produit.

 

Merci beaucoup pour ce code.

Link to comment
Share on other sites

  • 2 months later...

Bonjour, j'ai peut être rien compris, mais moi pour faire des prix barré je fais :

 

1 je clique sur afficher en solde pour avoir le logo en solde

2 je créer un prix spécifique en cochant " laisser afficher ancien prix"

3 mon produit est sur ma boutique avec un prix barré et le nouveau prix

Link to comment
Share on other sites

Bonjour,

 

Il existe aussi ce plugin qui vous permet d'afficher la promotion du produit directement sur l'image du produit sous la forme d'un label de couleur : http://addons.prestashop.com/fr/prix-promo-modules-prestashop/7244-nps-labels-de-promotions.html

 

Je pense que cela peux répondre à vos besoins sans toucher au code. Si vous avez des questions, je reste à votre disposition.

 

Bonne journée.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

Bonjour,

 

j'ai rencontré le même problème. Pour barrer le texte tu peux ajouter la balise <strike>, elle est déconseillée (car pas toujours reconnue) mais fonctionne. Ca donne :

 

<!-- Reduction (percent or amount) -->
{if $product.price_without_reduction neq $product.price}
    {if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}
       
     {if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_percent"><span class="reduction_percent_display">-{$pro_specific_prices.reduction * 100|floatval}%</span></p>
       {/if}
        
       {if $pro_specific_prices.reduction_type eq 'amount' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}<p class="reduction_amount"><span class="reduction_amount_display">-{$pro_specific_prices.reduction|floatval}€</span></p>
        {/if}
       {/if}
     {/if}<!-- End Reduction -->
<!-- Old price -->
<p id="old_price"><span class="bold">
  {if $priceDisplay >= 0 && $priceDisplay <= 2}
    {if $product.price_without_reduction > $product.price}
    <span id="old_price_display"><strike><b>{convertPrice price=$product.price_without_reduction}</b></strike></span>
      {if $tax_enabled}
       {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
      {/if}
   {/if}
   {/if}
</p><!-- End Old price --> 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...