Post by Brook » Tue Nov 16, 2010 1:39 am

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

Active Member

Posts

Joined
Wed Feb 24, 2010 12:15 am

Post by jty » Tue Nov 16, 2010 5:59 pm

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.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by xman » Thu Jan 13, 2011 1:11 pm

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.

Newbie

Posts

Joined
Mon Aug 30, 2010 8:35 am

Post by vinothsmart » Tue May 20, 2014 9:45 pm

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 .......

Newbie

Posts

Joined
Wed Mar 26, 2014 3:17 pm
Location - Kumbakonam

Post by webgold » Thu Jun 12, 2014 5:51 pm

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! ;D

New member

Posts

Joined
Tue Jul 30, 2013 10:37 pm

Post by straightlight » Thu Jun 12, 2014 8:31 pm

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:

Code: Select all

'price'      => $result['price'],
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:

Code: Select all

'price'      => $result['price']
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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by webgold » Thu Jun 12, 2014 8:44 pm

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! ;)

New member

Posts

Joined
Tue Jul 30, 2013 10:37 pm

Post by straightlight » Thu Jun 12, 2014 8:46 pm

No problem.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by michael2820 » Wed Aug 08, 2018 2:45 pm

change in the DB worked for me

--- please reply only with verified data, that is: no 'I think', 'maybe' etc. ---


User avatar
Active Member

Posts

Joined
Sun May 15, 2011 8:16 pm
Location - Denmark OC 2102

Post by Mored1984 » Fri Jan 18, 2019 11:20 pm

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.

Attachments

try.jpg

Decimal Point In Product Prices On Admin Side - try.jpg (378.03 KiB) Viewed 4668 times


=======
Regards
M.Taleb
=======


User avatar
Newbie

Posts

Joined
Tue Jan 23, 2018 10:58 pm

Post by mariurs » Sun Nov 22, 2020 8:12 pm

Hello,
I altered the databes tables as instructed and works like a charm! Thanks!

Newbie

Posts

Joined
Tue Dec 03, 2013 5:17 am
Who is online

Users browsing this forum: No registered users and 73 guests