old 1.4 price decimals problem

zoltanp

Avatar: zoltanp

2012-11-08 12:16

Hello!

I have a really old quickcart 1.4 installation, works like a charm with more than 10.000 items!!
But I always have price problems because the two decimals after the price.
I mean users calls me why am I so expensive:))

How can I rid off the decimals?
Now the price looks like this: 1600.00
I want this: 1600

thank you

site: filaportal.net

Zoltan

» Quick.Cart v1.x

Zoltan

interkob

Avatar: interkob

2012-11-08 13:32

1. core/other.php

return sprintf'%01.2f'$fPrice );



change to:

return sprintf'%01.0f'$fPrice );



2. core/products.php before line:

$content .= $tpl->tbHtml$sFile'LIST_LIST' );



paste:

$aList['fPrice'] = ereg_replace'.00'''$aList['fPrice'] );



3. actions_client/products.php before line:

$content .= $tpl->tbHtml$sFile'SHOW' );



paste:

$aData['fPrice'] = ereg_replace'.00'''$aData['fPrice'] );



4. core/orders.php before line:

$content  .= $tpl->tbHtml$sFile'LIST_LIST' );



paste:

$aList['fPrice'] = ereg_replace'.00'''$aList['fPrice'] );



This solution should work;) Just try it.

http://qcskins.eu

zoltanp

Avatar: zoltanp

2012-11-09 14:07

oh, great, thanks!

If I add this: $aList['fPrice'] = ereg_replace( '.00', '', $aList['fPrice'] );
to core/products.php than it rid off all zeros and mess up the prices:

original price: 2700.00
price with your code: 2

Zoltan

interkob

Avatar: interkob

2012-11-09 17:01

Are you sure you made all ok? This code should remove ".00" only. I will test it later if you still get mistakes.

zoltanp

Avatar: zoltanp

2012-11-09 17:31

double checked...
inserted your code, wrong
restored from backup
inserted step by step, the error come up when I add this
$aList['fPrice'] = ereg_replace( '.00', '', $aList['fPrice'] );
If I remove this line than I have again 2 decimals. If I insert this the line removes the last 3 character from price. Any price shoren or equal to 3 decimals is shows "nothing"

Zoltan

interkob

Avatar: interkob

2012-11-09 17:46

I've tried again and works properly. Maybe your files have some changes made before and in case of that there are some differents.

zoltanp

Avatar: zoltanp

2012-11-09 17:47

original files i think

thank you for your help!!!

Zoltan

zoltanp

Avatar: zoltanp

2012-11-09 17:48

I'll try again step by step and let you know.
If I have problems again can I send you my php files?

Zoltan

Zoltan

interkob

Avatar: interkob

2012-11-09 18:16

Ok

zoltanp

Avatar: zoltanp

2012-11-10 17:28

If I insert a new item, than the price is good, there is no decimals.
(only added your first line to the code.)
return sprintf( '%01.0f', $fPrice );

If I added your second line, than the following

original price: 150.00
new price: 150 --- goood!!!!

original price: 100.00
new price: 1 --- wrong

If there is two zeros in the price, than your code rid it off.

Zoltan

zoltanp

Avatar: zoltanp

2012-11-10 17:36

One more test:
(your first and second line added to the code)

Adding new item with price: 150
Displayed price in the shop: 150

adding new item with price: 100
displayed price in the shop: 1

Zoltan

interkob

Avatar: interkob

2012-11-11 09:10

Then open core/products.php and instead my old code paste new one:

$string '/([\d,]+)\.(\d+)(.*)$/';
      
$condition preg_replace($string'$2'$aList['fPrice']);
      if (
$condition == 00) {
      
$aList['fPrice'] = preg_replace($string'$1$3'$aList['fPrice']);

      } else {

      
$aList['fPrice'] = preg_replace($string'$1.$2$3'$aList['fPrice']);

      }

qcskins.eu

interkob

Avatar: interkob

2012-11-11 13:21

!!! But don't forget to make changes in other files too, as I wrote in my first message. They are related with price displaying on details page and basket page.

interkob

Avatar: interkob

2012-11-11 13:31

This will be better to write it again.

1. core/other.php

return sprintf'%01.2f'$fPrice );




change to:

return sprintf'%01.0f'$fPrice );




2. core/products.php before line:

$content .= $tpl->tbHtml$sFile'LIST_LIST' );




paste:

$string '/([\d,]+)\.(\d+)(.*)$/';
      
$condition preg_replace($string'$2'$aList['fPrice']);
      if (
$condition == 00) {
      
$aList['fPrice'] = preg_replace($string'$1$3'$aList['fPrice']);

      } else {

      
$aList['fPrice'] = preg_replace($string'$1.$2$3'$aList['fPrice']);

      }




3. actions_client/products.php before line:

$content .= $tpl->tbHtml$sFile'SHOW' );




paste:

$string '/([\d,]+)\.(\d+)(.*)$/';
      
$condition preg_replace($string'$2'$aData['fPrice']);
      if (
$condition == 00) {
      
$aData['fPrice'] = preg_replace($string'$1$3'$aData['fPrice']);

      } else {

      
$aData['fPrice'] = preg_replace($string'$1.$2$3'$aData['fPrice']);

      }




4. core/orders.php before line:

$content  .= $tpl->tbHtml$sFile'LIST_LIST' );




paste:

$string '/([\d,]+)\.(\d+)(.*)$/';
      
$condition preg_replace($string'$2'$aList['fPrice']);
      if (
$condition == 00) {
      
$aList['fPrice'] = preg_replace($string'$1$3'$aList['fPrice']);

      } else {

      
$aList['fPrice'] = preg_replace($string'$1.$2$3'$aList['fPrice']);

      }



I hope this will work ok.

zoltanp

Avatar: zoltanp

2012-11-11 15:08

Yes!!!! It's working!
Thank you very much!!!

Only one place where the 2 decimals left, that is the email order invoice, where is the total includes two decimals.
But never mind, this is fantastic!

thanks again

Zoltan

Zoltan

Back to top
about us | contact