Page 1 of 1
How to display Admin-> Product Price (only 2 decimal places)
Posted: Tue Nov 16, 2010 1:39 am
by Brook
I have OpenCart 1.4.9.2 installed. I am using currency US Dollars.
Simple question I am sure, but currently in the Admin when I look at a Product the Product Price is display with 4 places after the decimal places. This only happens in the Admin. The catalog displays correctly and only displays 2 places after the decimal for the Product Price.
Example: If the Product Price is $1,500 then the price in the Admin would display as 1500.0000
How do I change the Product Price to only display with only 2 places after the decimal? Ex. 1500.00
Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Tue Nov 16, 2010 5:59 pm
by jty
Try this -
Backup admin/view/template/catalog/product_form.tpl
change the line:
Code: Select all
<td><input type="text" name="price" value="<?php echo $price; ?>" /></td>
to
Code: Select all
<td><input type="text" name="price" value="<?php echo number_format($price,2); ?>" /></td>
That will change the display to 2 decimals though it is still stored as 4 decimals
I think I did it by changing the database to 2 decimals or maybe I changed it in the controller file. Changing it in the .tpl is safer and easier if you are unfamilar with coding.
Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Thu Jan 13, 2011 1:11 pm
by xman
I did the database update with ease, here is how:
1. login to your mysqladmin
2. backup database table
3. go to your table and select STRUCTURE
4. click change on the price column
5. under length values enter: 15,2
I had problems with the totals, when paying with paypal, and this change fix my problems, this probably will fix yours.
Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Tue May 20, 2014 9:45 pm
by vinothsmart
No Needs to Change in controller or anything Else Just go db and change in price structure as decimal(15,4) as decimal (15,2) in database .......
Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Thu Jun 12, 2014 5:51 pm
by webgold
Hi
I'm trying to achieve the same thing. In my opencart admin it has prices like:
£4.9900
I want just £4.99
I want just 2 decimal places because I find it a little confusing with everything having 4 decimal places.
No Needs to Change in controller or anything Else Just go db and change in price structure as decimal(15,4) as decimal (15,2) in database
I'm in the db but can't find the "price structure" section, does anyone know whats it called?
Thanks for any help guys!

Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Thu Jun 12, 2014 8:31 pm
by straightlight
This question has been asked so many times in the past on the forum. The problem why the decimal doesn't show by specific ended point is because the prices in the admin products page does not show by currency settings.
The controller
does need to be modified to accomplish your request since the prices are loaded from the database field and not as a converted field. The 15,4 demonstrates already that the decimal won't appear as a 2 ended decimal point.
In admin/controller/catalog/product.php file,
find:
Code: Select all
$special = $product_special['price'];
replace with:
Code: Select all
$special = $this->currency->format($product_special['price'], $this->config->get('config_currency');
Then, find:
replace with:
Code: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency'),
Then, find:
Code: Select all
if (isset($this->request->post['price'])) {
$this->data['price'] = $this->request->post['price'];
} elseif (!empty($product_info)) {
$this->data['price'] = $product_info['price'];
} else {
$this->data['price'] = '';
}
replace with:
Code: Select all
if (isset($this->request->post['price'])) {
$this->data['price'] = $this->currency->format($this->request->post['price'], $this->config->get('config_currency');
} elseif (!empty($product_info)) {
$this->data['price'] = $this->currency->format($product_info['price'], $this->config->get('config_currency');
} else {
$this->data['price'] = '';
}
Then, find:
Code: Select all
'price' => $product_option_value['price'],
replace with:
Code: Select all
'price' => $this->currency->format($product_option_value['price'], $this->config->get('config_currency'),
Then, find:
replace with:
Code: Select all
'price' => $this->currency->format($result['price'], $this->config->get('config_currency'),
This should return the expected results. Also ensure to configurable your decimal values from your admin - > systems - > settings and from your admin - > systems - > localisation tree.
Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Thu Jun 12, 2014 8:44 pm
by webgold
Hey Straightlight
That's very helpful, I did perform numerous searches on google for information about this and started getting some different solutions, so I thought it best to ask here.
Anyway thanks again!

Re: How to display Admin-> Product Price (only 2 decimal pla
Posted: Thu Jun 12, 2014 8:46 pm
by straightlight
No problem.
Re: How to display Admin-> Product Price (only 2 decimal places)
Posted: Wed Aug 08, 2018 2:45 pm
by michael2820
change in the DB worked for me
Re: How to display Admin-> Product Price (only 2 decimal places)
Posted: Fri Jan 18, 2019 11:20 pm
by Mored1984
Go to PHPMyAdmin Then Select Your Database: oc_db »Table: oc_product then select Structure then change price»Length/Values to the number you want.
Re: How to display Admin-> Product Price (only 2 decimal places)
Posted: Sun Nov 22, 2020 8:12 pm
by mariurs
Hello,
I altered the databes tables as instructed and works like a charm! Thanks!