You are here:  » A merchant's decided to put a comma in their prices


A merchant's decided to put a comma in their prices

Submitted by Harvey on Mon, 2006-08-21 21:33 in

Hello again!

One of my merchant's used a comma when using prices over $999.99... resulting in a $24k (imagine the commission on that!) ring being displayed at $2.4!

I've tried using the script's wonderful find+replace feature to replace commas in the price field with, well, nothing, but that hasn't done the job.

Anybody got a fresh idea on this?

Submitted by support on Mon, 2006-08-21 21:42

Hi Harvey,

I can see what the problem is - so you have a price that is something like 34,567.89, and PT is turning that into $34.57.

The script is setup to handle feeds that use a comma instead of the decimal point; but in this case it seems that you have both!

To fix this, you'll need to make a change to the decimalise function in includes/tapestry.php, and this assumes that you are not using any other feeds that use a comma instead of a decimal point. Look for the following code:

<?php
  
function tapestry_decimalise($price)
  {
    
$price str_replace(",",".",$price);
    
$price preg_replace('/[^0-9\.]/e','',$price);
    
$price sprintf("%.2f",$price);
    return 
$price;
  }
?>

You will notice that the first line of this function converts commas into decimal places. In your scenario, you want to change this to simply remove commas, so change the function as follows:

<?php
  
function tapestry_decimalise($price)
  {
    
$price str_replace(",","",$price);
    
$price preg_replace('/[^0-9\.]/e','',$price);
    
$price sprintf("%.2f",$price);
    return 
$price;
  }
?>

It should then import with the correct price!

Hope this help!
David.

Submitted by Harvey on Mon, 2006-08-21 21:51

That makes a lot of sense!

Guess who'll get a cut of the commission if I ever sell anything over $999 ;-)

Submitted by Simon on Tue, 2006-08-22 21:29

Had the same problem - just made the tweak and it works fine now

Thanks

Simon

PriceWatchUK.com

Submitted by Harvey on Tue, 2006-08-22 21:37

Glad to hear it. Having said the above, I contacted them and they've changed it which was rather nice of them.