How to display product price with and without tax at the same time in the list of products for Prestashop?

In the list of products I need to display the price of the product at the same time and without tax.

I am using Prestashop version 1.6.

Currently, the price, including tax, is displayed in the product list. I also want to show the price without tax.

How can i do this? I was looking for a solution and could not find a working solution for me.

+6
source share
5 answers

Locate the following block in product-list.tpl :

 {foreach from=$products item=product name=products} 

Add this to show the price without tax:

 {convertPrice price=$product.price_tax_exc} 

Make sure that during development of Template compilation set to Force compilation and Cache set to No in the back office of PrestaShop β†’ Advanced Parameters β†’ Performance .

+9
source

In my case, it works with default tax:

 {convertPrice price=$product->getPrice(false, $smarty.const.NULL)} ({ls='tax excl.'}) 
+2
source

I have a similar problem in the list of orders before checking. The error message displays the total amount and the amount of the product without tax. So I changed the file in the controllers> front> OrderController.php (PS 1.6) On line 63

 // Check minimal amount $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) { $_GET['step'] = $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase_2, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ); } 

with the following code

 // Check minimal amount $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); # modified (total amount included tax - only for screen error) $minimal_purchase_2 = round(Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency)*1.22,1); $productTotal = round($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS)*1.22,1); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) { $_GET['step'] = $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of %1s (tax incl.) is required to validate your order, current purchase total is %2s (tax incl.).'), Tools::displayPrice($minimal_purchase_2, $currency), Tools::displayPrice($productTotal, $currency) ); } 

I have to decide in order to get the actual tax value (at the moment I inserted 1.22 for the value of the tax on Italy).

In the end, you need to translate a new sentence into localization. Hope someone can finish or better resolve this issue.

0
source

I know that there is already one accepted answer, but I need more information on how to get the price of the product.

The Prestashop built-in product class has a getPrice method.

 /** * Get product price * Same as static function getPriceStatic, no need to specify product id * * @param bool $tax With taxes or not (optional) * @param int $id_product_attribute Product attribute id (optional) * @param int $decimals Number of decimals (optional) * @param int $divisor Util when paying many time without fees (optional) * @return float Product price in euros */ public function getPrice($tax = true, $id_product_attribute = null, $decimals = 6, $divisor = null, $only_reduc = false, $usereduc = true, $quantity = 1) { return Product::getPriceStatic((int)$this->id, $tax, $id_product_attribute, $decimals, $divisor, $only_reduc, $usereduc, $quantity); } 

As you can see, you can indicate whether you want it with taxes, the number of decimal places given as a result, and the numeric divider.

So, if you want to get the price of a product by ID with and without taxes, you can achieve this like this

 $product = new Product($id_product, $id_language) // Fill with your info $price_with_taxes = $product->getPrice(true); $price_wout_taxes = $product->getPrice(false); 

Like other comments, if you are inside a template, you can get the product identifier depending on the type that you are changing.

In product.tpl (single product view) there is a $ product variable. In product-list.tpl, you have the $ products variable, an array containing all the products displayed in the list.

Hope this helps.

0
source

A simple solution

Go to the "Clients β†’ Groups" section and click "Change" in the group you want to change:

Find the price display method and select Price is included or excluded as you want, then Save changes:

check by pressing ctrl + f5. Done

-1
source

All Articles