Post by crusin » Mon Mar 09, 2015 4:10 pm

Hello,

We are using our store here in india, the currency format for amounts which are high is different.

currently oc shows amounts like Rs.255,000 where as in india it is Rs. 2,55,000

How can i edit this. i need it to be in indian format

New member

Posts

Joined
Sat Jan 23, 2010 4:04 pm

Post by chulcha » Mon Mar 09, 2015 6:25 pm

system/library/currency.php

Code: Select all

$string .= number_format(round($value, (int)$decimal_place), (int)$decimal_place, $decimal_point, $thousand_point);

Code: Select all

if ($symbol_right == 'RS.' || $symbol_left == 'RS.' ) {
//indian format
        $num=round($value, (int)$decimal_place)
        $num=explode('.',$num);
        $dec=(count($num)==2)?'.'.$num[1]:'.00';
        $num = (string)$num[0];
        if( strlen($num) < 4) return $num;
        $tail = substr($num,-3);
        $head = substr($num,0,-3);
        $head = preg_replace("/\B(?=(?:\d{2})+(?!\d))/",",",$head);
        $string .= $head.",".$tail.$dec;
} else {
       $string .= number_format(round($value, (int)$decimal_place), (int)$decimal_place, $decimal_point, $thousand_point);
}

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by crusin » Mon Mar 09, 2015 7:22 pm

hello,

thanks for the code. but how do i use it do i need to replace the code or just add the code

New member

Posts

Joined
Sat Jan 23, 2010 4:04 pm

Post by chulcha » Tue Mar 10, 2015 12:22 am

Sorry, of course replace the code.

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by crusin » Wed Mar 11, 2015 6:37 pm

hello,

Thanks it seems to be working for amounts where the price is more than 3 digits. example anything above 1000 is fine. but for 3 digit numbers it isnt working. for example there is product which cost Rs. 575 it appears like this now Rs. ,575

how do we solve this

New member

Posts

Joined
Sat Jan 23, 2010 4:04 pm

Post by chulcha » Wed Mar 11, 2015 8:22 pm

Code: Select all

if ($symbol_right == 'RS.' || $symbol_left == 'RS.' ) {
//indian format
        $num=round($value, (int)$decimal_place);
        $num1=explode('.',$num);
        $dec=(count($num1)==2) ? '.' .$num1[1] : '.00';
        $num_ = (string)$num1[0];
        if( strlen($num_) < 4) {
			$string .= $num;
		} else {
			$tail = substr($num_,-3);
			$head = substr($num_,0,-3);
			$head = preg_replace("/\B(?=(?:\d{2})+(?!\d))/",",",$head);
			$string .= $head.",".$tail.$dec;
		}
} else {
       $string .= number_format(round($value, (int)$decimal_place), (int)$decimal_place, $decimal_point, $thousand_point);
}
Test

Code: Select all

123.56 => 123.56
1123 => 1,123.00
11123.56 => 11,123.56
111123 => 1,11,123.00
1111123.56 => 11,11,123.56
11111123.56 => 1,11,11,123.56
111111123.56 => 11,11,11,123.56
1111111123.56 => 1,11,11,11,123.56

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by crusin » Thu Mar 12, 2015 12:56 pm

hello,

thanks for the update, we used your code but still no luck the Rs. symbol doesnt appear for amounts less than 1000.

New member

Posts

Joined
Sat Jan 23, 2010 4:04 pm

Post by chulcha » Fri Mar 13, 2015 3:33 am

may be

($symbol_right == 'RS. ' || $symbol_left == 'RS. ' )
space after dot?

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by crusin » Fri Mar 13, 2015 2:49 pm

Hello,

Thanks a ton buddy, the revised code worked....:-)

New member

Posts

Joined
Sat Jan 23, 2010 4:04 pm

Post by faizanyasn » Sun May 16, 2021 11:20 am

Good Job, but with OC 3.x code have some bug you have selected currency value rather then amount

Code: Select all

$num=round($value, (int)$decimal_place);
it should be

Code: Select all

$num=round($amount, (int)$decimal_place);
and the piece of code will be

Code: Select all

$num=round($amount, (int)$decimal_place);
        $num1=explode('.',$num);
        $dec=(count($num1)==2) ? '.' .$num1[1] : '.00';
        $num_ = (string)$num1[0];
        if( strlen($num_) < 4) {
			$string .= $num;
		} else {
			$tail = substr($num_,-3);
			$head = substr($num_,0,-3);
			$head = preg_replace("/\B(?=(?:\d{2})+(?!\d))/",",",$head);
			$string .= $head.",".$tail.$dec;
		} 

If you need any further assistance for Opencart development you can reach me out at
http://asktofaizan.com/ocd.php
OR
http://asktofaizan.com
OR
http://alliancedigitals.com

For further assistance with Opencart Development you can reach me at
asktofaizan@gmail.com | https://asktofaizan.com |


Newbie

Posts

Joined
Tue Jan 12, 2021 2:28 pm
Who is online

Users browsing this forum: No registered users and 65 guests