Pages:

How to make price form 10000 - to 10,000 please advice.

gsaroso

No avatar

2007-03-08 06:41

Please advice

» Quick.Cart v2.x

gsaroso

treewood (OpenSolution)

Avatar: treewood

2007-03-08 07:07

gsaroso - use search by words "format", "price" etc.

nikenhn

No avatar

2007-03-14 18:36

Hi treewood, I've have the same problem. Already find that keyword in this forum but no answer. People talk about convert $10390.00 to $10390. Not $10390.00 --> $10,390.00. Could you tell us how to change the format of number in price fields??? (with thousand seperated mark)

nikenhn

treewood (OpenSolution)

Avatar: treewood

2007-03-15 08:21

nikenhn - hmm... check for tPrice() function and change:
sprintf( '%01.2f', $fPrice );
to function number_format() ?
Check PHP manual

nikenhn

No avatar

2007-03-15 16:14

thanks treewood. Here're my change:

sprintf( '%01.2f', $fPrice ); --> sprintf( '%01.0f', $fPrice ); -------- This code will change price format from $1000.00 to $1000.

sprintf( '%01.2f', $fPrice ); --> sprintf( '%01.2f', $fPrice,2, '.', ',' ); -------------- This code doesn't work (it make no change in price format). Did I type it correctly? Is there something wrong in it??

Do I have to change anything else? and where?




nikenhn

treewood (OpenSolution)

Avatar: treewood

2007-03-15 16:16

nikenhn - maybe try number_format() ?

nikenhn

No avatar

2007-03-15 16:38

Hi treewood, It still not very clear. Do you mean this?

sprintf( '%01.2f', $fPrice ); --> sprintf( '%01.2f', number_format($fPrice,2, '.', ',' ));

I have done it in my code but still nothing change. It doesn't change even when I remove '%01.2f' too.

nikenhn

treewood (OpenSolution)

Avatar: treewood

2007-03-15 23:07

nikenhn - then go to core/products.php and to throwProductsData() after change add this:
$aList['fPrice'] = tPrice( $aList['fPrice'] );
before:
$content .= $tpl->tbHtml( $sFile, 'LIST_LIST' );

234233adas

Avatar: 234233adas

2007-03-16 14:04

treewood..thx for ur tutor.., now change /core/other.php, and /core/products.php
here my other.php

<?sprintf'%01.2f'$fPrice ); -->return number_format($fPrice,2'.'',' );?>



and core/products.php i add a function that u described...

<?$aList['fPrice'] = tPrice$aList['fPrice'] );?>



i succesfully change the price to x,xxx.xx but problem with the subtotal in Shopping Cart Menu...
it can't do a right mathematics...

here an example...,
1st product total is 2,399.96
2nd product total is 10,140.00

but the subtotal is wrong, it displays 12, that means it only sum 2+10, equal 12..., so the 3number behind "," is not calculated..., how could it throw that 3 numbers...

234233adas

Avatar: 234233adas

2007-03-16 14:31

:) here an the sample of that problem

www.tokoprotech.com/error.jpg

treewood (OpenSolution)

Avatar: treewood

2007-03-16 17:23

234233adas - problem is that PHP dont understand "2,399.96" as number and dont summary correctly. You must before summary change this value to float

234233adas

Avatar: 234233adas

2007-03-17 06:02

sorry for my nick..., seem i can't change it in this forum... ??????

ok, thx treewood, i understand..., now..how to change that value to float..., can u help me out ? :)

on which file..i should edit...???

i'm very appreciate for ur help...

thanks...

treewood (OpenSolution)

Avatar: treewood

2007-03-17 08:13

234233adas - maybe try to use ereg_replace( ',', '', $fValue ); ?

234233adas

Avatar: 234233adas

2007-03-17 11:26

hm..., on which file i should use ereg_replace( ',', '', $fValue ); ??

thanks

treewood (OpenSolution)

Avatar: treewood

2007-03-17 22:12

234233adas - in core/orders.php in listBasket()

234233adas

Avatar: 234233adas

2007-03-18 07:23

:) i messed up, i don't know php programming well..., can u help me to write that script...

in core/orders.php
here ur quick.cart orders.php script :)


if( !function_exists'listBasket' ) ){
  
/**
  * Generate basket list
  * @return string
  * @param int    $iOrder
  * @param string $sFile
  */
  
function listBasket$iOrder$sFile 'orders_basket.tpl' ){
    global 
$tpl$aList;

    
$aData      dbListBasket$iOrder );

    if( isset( 
$aData ) ){
      
$iCount   count$aData );
      
$fSummary 0;
      
$content  null;

      for( 
$i 0$i $iCount$i++ ){
        list( 
$aList['iElement'], $aList['iOrder'], $aList['iProduct'], $aList['iQuantity'], $aList['fPrice'], $aList['sProduct'] ) = $aData[$i];
        
        
$aList['iStyle'] = ( $i ) ? 01;
        
$aList['sStyle'] = ( $i == ( $iCount ) ) ? 'L'$i 1;

        
$aList['fSummary']  = tPrice$aList['iQuantity'] * $aList['fPrice'] );

        
$fSummary +=  $aList['fSummary'];
     
        
$content  .= $tpl->tbHtml$sFile'LIST_LIST' );
      } 
// end for
     
      
$aList['fSummary'] = tPrice$fSummary );

      return 
$tpl->tbHtml$sFile'LIST_HEAD' ).$content.$tpl->tbHtml$sFile'LIST_FOOT' );
    }
    else
      return 
null;
  } 
// end function listBasket

treewood (OpenSolution)

Avatar: treewood

2007-03-19 08:32

try maybe this. find:
$fSummary += $aList['fSummary'];
replace to:
$fSummary += ereg_replace( ',', '', $aList['fSummary'] );

234233adas

Avatar: 234233adas

2007-03-19 11:53

^o^ THanks so much...treewood.., u r so kind n nice..., now my problem solved...

but just as expected..., The Total in order detail menu got messup... :(

would u mind to help me out again?

here the error sample...

www.tokoprotech.com/error2.jpg

regards,
vincent

treewood (OpenSolution)

Avatar: treewood

2007-03-19 13:02

234233adas - sorry but this is JavaScript ... You must edit js/orders.js and change fix function. I dont know JS well and i cant help You with that now.

234233adas

Avatar: 234233adas

2007-03-20 07:50

ok...thanks treewood..., u already done ur best...

thanks...

:)

btw...what if i change the number format in core.php to this ??

return number_format($fPrice,0'.'',' );



i changed to

return number_format($fPrice,0',''.' );



so i got number format x.xxx

and how to make listbasket do a right mathematic with that format, in core/orders.php

$fSummary += ereg_replace( ',', '', $aList['fSummary'] );

what i should i change..???

Pages:
Back to top
about us | contact