You are here:  » Remove comma in Price Field

Support Forum



Remove comma in Price Field

Submitted by anhmocboc on Wed, 2010-10-20 21:17 in

I got item price $2,000.00 and it displays $2.00.

If the price in the feed is 2000.00, it will display correct.
But if the price in the feed is 2,000.00, then it will display $2.00
How to remove the comma in Price field when import?
Thanks

Submitted by support on Thu, 2010-10-21 09:09

Hi,

This is happening because of code built into handle comma as a decimal point - but it's easy to remove. In includes/tapestry.php look for the following code at line 36:

    $price = str_replace(",",".",$price);

...and simply delete or comment out that line and then re-import any affected feeds.

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Sat, 2010-11-20 20:51

Hi David

I got a similar problem, but it doesn't help outcomment this linie 36

I got item price $2.000,00 and it displays $2.00.
- notice that ',' and '.' is different from the first post.

If I change to $2,000.00 and outcomment linie 36, then it is displayed correctly.

thx
//Brian

Submitted by support on Sun, 2010-11-21 20:47

Hi Brian,

In that scenario, instead of deleting that line, REPLACE with the following:

    $price = str_replace(".","",$price);
    $price = str_replace(",",".",$price);

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Mon, 2010-11-22 15:29

Hi David

Thx for your feedback...

your reply results this: $2000.00

If possible i like to have $2000,00 as a result - this is the normal way in Denmark, using comma as seperator :o)

thx
Brian

Submitted by support on Mon, 2010-11-22 15:38

Hi Brian,

As price values are stored in the database in DECIMAL(10,2) format this would need to be handled at the display level - but is easy to do.

In each of the following files:

html/featured.php
html/searchresults.php
html/prices.php

Search and replace:

  $product["price"]

...with:

  str_replace(".",".",$product["price"])

And in

html/product.php

Search and replace:

  $mainProduct["price"]

...with:

  str_replace(".",".",$mainProduct["price"])

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Mon, 2010-11-22 15:57

Hi David

that almost did the trick - but this ".","." should be replaced with ".",","

then it display 2000,00

thx again

//Brian

Submitted by support on Tue, 2010-11-23 09:47

Well spotted, Brian!

Cheers,
David.
--
PriceTapestry.com

Submitted by Misalf on Fri, 2011-08-26 19:10

Hi David,

Tried this mod, all right in html/featured.php, html/searchresults.php and html/product.php, I just cannot display prices in html/price.php.

In html/prices.php,I have replaced:

<?php
 
print $config_currencyHTML.$product["price"]; 
?>

with

<?php
 
print $config_currencyHTML.str_replace(".",",",$product["price"]); 
?>

Prices are not displayed just here, I have been doing something wrong, cannot find out what exactly.
The strange thing is that featured, searchresults and product are OK !

Thanks in advance

Submitted by support on Sat, 2011-08-27 08:20

Hello Misalf,

That looks absolutely fine, I assume it works OK if you revert back to the original? If you're still not sure, could you post the contents of your modified html/prices.php and I'll check it all in context...

Cheers,
David.
--
PriceTapestry.com

Submitted by Misalf on Wed, 2011-08-31 11:19

Many thanks David !

I post here the whole fix in order to remove comma in price field product.php, in case someone else need it:

Line 23 of product.php:

Change:

<?php print $config_currencyHTML.$mainProduct["price"]; ?>

with

<?php print $config_currencyHTML.str_replace(".",",",$mainProduct["price"]); ?>

Line 27 of product.php:

Change:

<?php if ($priceProduct["price"] == $mainProduct["price"]): ?>

with

<?php if ($priceProduct["price"] == str_replace(".",",",$priceProduct["price"])): ?>

Thanks for helping!
By the way, new Distribution 12/10B is GREAT !

Greetings

Submitted by support on Wed, 2011-08-31 11:28

Thanks for your comments!

Cheers,
David.
--
PriceTapestry.com