You are here:  » Price Display

Support Forum



Price Display

Submitted by MikeV on Mon, 2007-04-02 18:03 in

Is there a way to make my prices display like this:

$12,999,99

instead of:

$12299.99?

Basically I want to add a comma.

Mike

Submitted by support on Tue, 2007-04-03 07:08

Hi Mike,

Yes - you can do this using PHP's number_format() function. You'll need to make modifications in a few files where the price is displayed.

In html/searchresults.php find this code on line 28:

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

...and change to:
<strong><?php print $config_currencyHTML.number_format($product["price"],2); ?></strong><br />

In html/prices.php find this code on line 13:

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

...and change to:
<td><strong><?php print $config_currencyHTML.number_format($product["price"],2); ?></strong></td>

Finally, in html/product.php

<?php print $config_currencyHTML.$mainProduct["price"]; ?>&nbsp;<?php print translate("from"); ?>&nbsp;

...and change to:
<?php print $config_currencyHTML.number_format($mainProduct["price"],2); ?>&nbsp;<?php print translate("from"); ?>&nbsp;

Hope this helps!
Cheers,
David.

Submitted by MikeV on Tue, 2007-04-03 23:30

Hi David,

Thank you always for your immediate response. You have an awesome product and I love it.

I did the modification you suggested, but now it rounds the number up.

For instance $999.99 is now listed as $1,000.

How do I fix this?

Submitted by support on Wed, 2007-04-04 07:09

Ah, sorry - the default for number_format is zero decimal places. To use 2 decimal places another parameter is needed. In the case of the first modification, it should actually be this:

<strong><?php print $config_currencyHTML.number_format($product["price"],2); ?></strong><br />

(just add the ,2 after $product["price"]).

I've just updated my original post to include this correction (see above)...

Cheers,
David.

Submitted by MikeV on Thu, 2007-04-05 16:36

Hi David,

Everything has been working out well. Just one problem, when I go to import my feeds, I get this error:

Warning: Wrong parameter count for str_replace() in /home/funkymus/public_html/includes/tapestry.php on line 36

How do I fix this so I can successfully import my feeds?

Mike

Submitted by support on Fri, 2007-04-06 08:27

Hi Mike,

The line referred to is this line in includes/tapestry.php:

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

Can you confirm that this code appears identical in your current version? Either way, I would suggest extracting this file from the distribution and re-uploading it to your site to make sure that the entire file is in its original condition.

This line won't affect the above modifications as they insert the commas at run time. The purpose of the tapestry_decimalise() function (and this line in particular) is to remove any commas from a previously formatted price value - as some feeds contain these - in order that they can be inserted into the database as type DECIMAL.

Cheers,
David.