Jump to content

Pre tax price in product-listing (category.php)


Recommended Posts

I want to add the pretax price in the product-listing, like it is done in product.php where both price including and excluding taxes are shown. Been playing around in product-list.tpl but as I´m new to Smarty I can´t figure out how to get it done. Could someone point me in the right direction please?

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
  • 1 month later...
  • 1 month later...

Ok, i have managed to do it although it maybe a rather crude way of doing so.

edit your product-list.tpl and after the line

{foreach from=$products item=product name=products}
put in the following code.

          {assign var=productpriceincvat value=$product.price}
           {assign var=producttaxid value=$product.id_tax}
           {php}
               $producttaxid = $this->get_template_vars('producttaxid');
               $sql = 'SELECT * FROM `'._DB_PREFIX_.'tax` WHERE `id_tax` = '.$producttaxid.' ORDER BY `id_tax` DESC';
               $result = Db::getInstance()->getRow($sql);
               $percentage = $result['rate'];
               $percentage = number_format('1.'.$result['rate'], 2);
               $totalPrice = $this->get_template_vars('productpriceincvat');
               $discountPrice = $totalPrice / $percentage;
               $discountPrice = round(($discountPrice),2);;

               $this->assign('productpriceexvat', $discountPrice);
           {/php}
           {$discountPrice}



find the line where the price is displayed

{convertPrice price=$product.price}
and then undernieth or where ever you want the ex tax price to be displayed paste.

{convertPrice price=$productpriceexvat} ex VAT




This code comes with no warranty what so ever so use at your own risk!

Link to comment
Share on other sites

×
×
  • Create New...