Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 592 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to display product price with and without tax at a time in product list for Prestashop?

#1
In the product list I need to display the product price with and without tax at a time.

I am using the version 1.6 of Prestashop.

Right now the price including tax is displayed in the product list. I want to display the price excluding tax as well.

How can I do that? I have searched for solution and was not able to find a working solution for me.

Reply

#2
Find the following block in `product-list.tpl`:

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

Add this to display price without tax:

{convertPrice price=$product.price_tax_exc}

Make sure that during development `Template compilation` is set to `Force compilation` and `Cache` is set to `No` in PrestaShop back-office -> `Advanced Parameters` -> `Performance`.
Reply

#3
In my case it works for default tax excl.:

{convertPrice price=$product->getPrice(false, $smarty.const.NULL)} ({l s='tax excl.'})
Reply

#4
I have a similar problem in order list before checkout.
The error message displays the total amount and product amount without tax.
So i modified the file in controllers > front > OrderController.php (PS 1.6)
At 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 solve to get the actual tax value (at the moment i inserted 1.22 for italy tax value).

At the end you have to translate in localization the new sentence.
Hope someone can complete or better solve this question.
Reply

#5
Simple solution

Go to Customers -> Groups and click Edit on the group you want to modify:

Find Price display method option and select Price included or excluded as you want then Save changes:


check with pressing ctrl + f5. Done
Reply

#6
I know there is already one accepted answer but I needed more information about how to get a product price.

The Prestashop built-in product class has the 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 specify if you want it with taxes, the number of decimals given as result, and the number divisor.

So, if you want to get the product price by ID with and without taxes you can achieve it 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);

As other comments say, if you are inside a template, you can get the product id depending on the view you are modifying.

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


Hope this helps.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through