Jump to content

Afficher le prix le plus bas des prix degressifs


Recommended Posts

Bonjour,

Je cherche comment changer le prix qui s'affiche sur mes produits.
Par défaut, c'est le prix le plus élevé de mes tarifs degressifs qui se mets sous le produit, hors, j'aimerai que ce soit le moins cher, afin d'ajouter par la suite "a partir de"....€*

Quelqu'un sait il comment faire ?
A partir de je sais le rajouter, il me manque juste l'affichage du prix le moins elevé !!

Merci de votre aide

Link to comment
Share on other sites

SI ça parle a quelqu'un, est ce que je peux trouver ce que je cherche là : (à mon avis c'est la variable qu'il faut changer de mais je fais ça ou ??)

<?php $_from = $this->_tpl_vars['quantity_discounts']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['quantity_discounts'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['quantity_discounts']['total'] > 0):
   foreach ($_from as $this->_tpl_vars['quantity_discount']):
       $this->_foreach['quantity_discounts']['iteration']++;
?>



<?php if (((is_array($_tmp=$this->_tpl_vars['quantity_discount']['id_discount_type'])) ? $this->_run_mod_handler('intval', true, $_tmp) : intval($_tmp)) == 1): ?>

                   <?php $this->assign('prixProduct', $this->_tpl_vars['product']->getPrice(true,@NULL,2)); ?>

                   <?php echo Product::convertPrice(array('price' => ((is_array($_tmp=$this->_tpl_vars['prixProduct']-$this->_tpl_vars['prixProduct']*$this->_tpl_vars['quantity_discount']['value']/100)) ? $this->_run_mod_handler('floatval', true, $_tmp) : floatval($_tmp))), $this);?>


               <?php else: ?>

<?php echo Product::convertPrice(array('price' => ((is_array($_tmp=$this->_tpl_vars['product']->getPrice(true,@NULL,2)-$this->_tpl_vars['quantity_discount']['value'])) ? $this->_run_mod_handler('floatval', true, $_tmp) : floatval($_tmp))), $this);?>



ou là dans le product tpl.


{l s='Quantity'}
               {assign var='prodNb' value=0}
               {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'}                        
               {if $prodNb==0}
                   {if $quantity_discount.quantity==2}
{l s='for'}
                   {else}
{l s='de'} 1 {l s='a'}
                   {/if}
               {/if}
               {$quantity_discount.quantity-1|intval}
               {assign var='prodNb' value=$prodNb+1}                    

{l s='de'} {$quantity_discount.quantity|intval} {l s='a'}
               {/foreach}
               ∞



{l s='Price'}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}
               {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'}


               {if $quantity_discount.id_discount_type|intval == 1}
                   {assign var='prixProduct' value=$product->getPrice(true, $smarty.const.NULL, 2)}
                   {convertPrice price=$prixProduct-$prixProduct*$quantity_discount.value/100|floatval}
               {else}
                   {convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)-$quantity_discount.value|floatval}
               {/if}

Link to comment
Share on other sites

Exact !! désolée pour le code, kje ne connaissais pas ce détail !

J'ai donc avancé sur mon problème, mais j'ai un petit bloquage.
Sur le product.tpl, je change la ligne 167 çi dessous :

{convertPrice price=$product->getPrice(true, NULL, 2)}



par

{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2, $smarty.const.NULL, false, true, 180)}



180 étant la quantité dégréssive correspondant au prix le moins elevé à afficher sur ma fiche produit.

Résultat : en touchant à cette variable, le prix minimum s'affiche 2 secondes, puis l'ancien (le plus élevé) se remets en place.
Qu'est ce qui fait que l'ancien prix revient ?
Merci de votre aide, je ne m'en sors pas !!

Link to comment
Share on other sites

  • 4 months later...

Bonjour,

est ce que vous avez trouvé la solution?

Je m'interesse aussi à la question et je pense qu'il faudrait juste calculer "le prix du produit"-"la plus grande valeur degressive" ici (product-list.tpl ligne 9-10 pour la version 1.2.4.0 de presta)


{if !$priceDisplay || $priceDisplay == 2}

{l s='from'}{convertPrice price=$product.price_tax_exc}{l s=' Tax exc.'}
{/if}


au lieu d'avoir {convertPrice price=$product.price_tax_exc} on aurait plutot quelque chose du genre {convertPrice price=$product.price_tax_exc-$quantity_discount.value}
seulement ca ne marche pas, peut etre que je n'appelle pas la bonne variable ou que je l'appelle mal, car quand je remplace la variable par une valeur fixe (par exemple 2) le prix est bien diminué de 2€

Si vous avez une idée de l'endroit ou ca ne vas pas, n'hésitez pas!!

merci par avance
Link to comment
Share on other sites

  • 7 months later...

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