4webs

Mostrar precios Rebajados y sin rebajar en los listados de Prestashop

Muchas veces por tema de diseño web nos hemos encontrado con la dificultad que necesitamos ver en los listados de los productos los precios sin rebajar,  normalmente aparece tachado, y los precios actuales que están rebajados sin tachar , ya que es el precio final, realizar esto en Prestashop es un poco complejo.

Os dejo como conseguí solucionar este problema, tenemos que abrir el archivo del tema donde se muestran los productos, en nuestro caso product_list.tpl, retirar los precios antiguos para que no se mezcle con el núevo código.

Con este código consiguiréis mostrar en Prestashop, el precio antiguo, el precio actual (el rebajado) y el porcentaje de descuento que se le aplica.

        {if ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product.reduction_from))}{assign var='special' value='1'}{else}{assign var='special' value='0'}{/if}                       

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

{l s='Precio:'} {if $special}{if $product.reduction_price != 0}{convertPrice price=$product.price+$product.reduction_price}{elseif $product.reduction_percent != 0}{math assign='product_price' equation='p / (1 - (r / 100))' p=$product.price r=$product.reduction_percent}{convertPrice price=$product_price}{/if}{/if}{convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if} {if $special}({if $product.reduction_price != 0}{math equation='round((r / (p + r)) * 100)' p=$product.price r=$product.reduction_price}%{elseif $product.reduction_percent != 0}{$product.reduction_percent|floatval}%{/if}){/if}
{/if} {if $priceDisplay}
{l s='Precio:'} {if $special}{if $product.reduction_price != 0}{convertPrice price=$product.price_tax_exc+$product.reduction_price}{elseif $product.reduction_percent != 0}{convertPrice price=$product.price_tax_exc+$product.reduction_price}{elseif $product.reduction_percent != 0}{math assign='product_price' equation='p / (1 - (r / 100))' p=$product.price_tax_exc r=$product.reduction_percent}{convertPrice price=$product_price}{/if}{/if}{convertPrice price=$product.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx'}{/if}{if $special}
{if $product.reduction_price != 0}{math equation='round((r / (p + r)) * 100)' p=$product.price r=$product.reduction_price}%{elseif $product.reduction_percent != 0}{$product.reduction_percent|floatval}%{/if}
{/if}
{/if}