I don't want to modify how the prices are stored, just how they are displayed.
For example I want to display the prices with three decimals in the admin side, but only two in the front end.
In admin it is displayed in 4 decimal places and in the front end in 2
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
I have website in oc 3.0.3.2 in php 8.2.
It has several extensions and modifications and a very peculiar owner.
The product prices have indeed 4 decimals in the price, but that's shown when you actually edit or create the product.
In the product list and the order list - and when you click to see order details - the prices use the same amount of decimals as defined in the currency. In my case 2. Is there a way to see 3 (or more) decimals in the product/order lists? But still display 2 decimals in the front end?
Both admin and the catalog use the same currency data which includes the decimals which is stored in the database and used by the common currency class.vourlismenos wrote: ↑Tue Feb 04, 2025 3:30 pmSorry you are right, my question was too vague.
I have website in oc 3.0.3.2 in php 8.2.
It has several extensions and modifications and a very peculiar owner.
The product prices have indeed 4 decimals in the price, but that's shown when you actually edit or create the product.
In the product list and the order list - and when you click to see order details - the prices use the same amount of decimals as defined in the currency. In my case 2. Is there a way to see 3 (or more) decimals in the product/order lists? But still display 2 decimals in the front end?
When inputting a price that field is just a number and is not controlled by the currency class.
To have different currency representation for admin and the catalog you would need an extension/modification.
The simplest way would be to remove currency in admin for the listvourlismenos wrote: ↑Tue Feb 04, 2025 3:30 pmSorry you are right, my question was too vague.
I have website in oc 3.0.3.2 in php 8.2.
It has several extensions and modifications and a very peculiar owner.
The product prices have indeed 4 decimals in the price, but that's shown when you actually edit or create the product.
In the product list and the order list - and when you click to see order details - the prices use the same amount of decimals as defined in the currency. In my case 2. Is there a way to see 3 (or more) decimals in the product/order lists? But still display 2 decimals in the front end?
In admin catalog controller under getList find all the prices (inc specials etc) and change them from
Code: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency')),
Code: Select all
'price' => $result['price'],
Code: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency2')),
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
I'll have a go and see if it works out !
by mona wrote: ↑Tue Feb 04, 2025 10:44 pmThe simplest way would be to remove currency in admin for the listvourlismenos wrote: ↑Tue Feb 04, 2025 3:30 pmSorry you are right, my question was too vague.
I have website in oc 3.0.3.2 in php 8.2.
It has several extensions and modifications and a very peculiar owner.
The product prices have indeed 4 decimals in the price, but that's shown when you actually edit or create the product.
In the product list and the order list - and when you click to see order details - the prices use the same amount of decimals as defined in the currency. In my case 2. Is there a way to see 3 (or more) decimals in the product/order lists? But still display 2 decimals in the front end?
In admin catalog controller under getList find all the prices (inc specials etc) and change them fromand change toCode: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency')),
Alternatively you could set up a second currency for the back end and add it directly to the database to have something likeCode: Select all
'price' => $result['price'],
If you dont understand / not following / not know how to do this you will have to get an extension built.Code: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency2')),
in system/library/cart/currency.php
add variable:
Code: Select all
private $decimal_place_override = false;
Code: Select all
public function decimal_place_override_set ($value) {
$this->decimal_place_override = (int)$value;
}
Code: Select all
$decimal_place = $this->currencies[$currency]['decimal_place'];
Code: Select all
$decimal_place = ($this->decimal_place_override !== false ? $this->decimal_place_override : $this->currencies[$currency]['decimal_place']);
add this:
Code: Select all
$this->currency->decimal_place_override_set (4);
Code: Select all
// Currency
$this->registry->set('currency', new Cart\Currency($this->registry));
nonnedelectari wrote: ↑Wed Feb 05, 2025 1:07 pmYou can also do this:
in system/library/cart/currency.php
add variable:add function:Code: Select all
private $decimal_place_override = false;
in function format, replace this:Code: Select all
public function decimal_place_override_set ($value) { $this->decimal_place_override = (int)$value; }
with:Code: Select all
$decimal_place = $this->currencies[$currency]['decimal_place'];
in admin/controller/startup/startup.phpCode: Select all
$decimal_place = ($this->decimal_place_override !== false ? $this->decimal_place_override : $this->currencies[$currency]['decimal_place']);
add this:after this:Code: Select all
$this->currency->decimal_place_override_set (4);
That will make sure that while using the same currency class as the front-end, in admin only the decimal places are overridden with 4.Code: Select all
// Currency $this->registry->set('currency', new Cart\Currency($this->registry));
Thank you
I made a small xml and uploaded it in vqmod and works great.
nonnedelectari wrote: ↑Wed Feb 05, 2025 1:07 pmYou can also do this:
in system/library/cart/currency.php
add variable:add function:Code: Select all
private $decimal_place_override = false;
in function format, replace this:Code: Select all
public function decimal_place_override_set ($value) { $this->decimal_place_override = (int)$value; }
with:Code: Select all
$decimal_place = $this->currencies[$currency]['decimal_place'];
in admin/controller/startup/startup.phpCode: Select all
$decimal_place = ($this->decimal_place_override !== false ? $this->decimal_place_override : $this->currencies[$currency]['decimal_place']);
add this:after this:Code: Select all
$this->currency->decimal_place_override_set (4);
That will make sure that while using the same currency class as the front-end, in admin only the decimal places are overridden with 4.Code: Select all
// Currency $this->registry->set('currency', new Cart\Currency($this->registry));
So could you add [SOLVED] to the start of this topic title?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
paulfeakins wrote: ↑Wed Feb 05, 2025 7:30 pmSo could you add [SOLVED] to the start of this topic title?
Users browsing this forum: Amazon [Bot], khnaz35 and 11 guests