You are here:  » Need to change some numbers

Support Forum



Need to change some numbers

Submitted by Blastaway on Thu, 2011-12-29 20:48 in

On my site it shows price like this

211.00:-

I want it to only show

211:-

how do i do?

Submitted by support on Fri, 2011-12-30 09:27

Hi,

As the price field is stored as DECIMAL in the database; they are coming out of the database with 2 zero-padded decimals. What you would need to do is create a display function to convert this to the format require. I would suggest adding this to includes/tapestry.php by adding the following code to the end of the script; just before the closing PHP tag:

  function tapestry_price($price)
  {
    return sprintf("%d",$price);
  }

Finally, wherever a price value is displayed within the /html/ files, enclose, within the above function. The easiest way to do this would be to do a Search and Replace with your text editor of:

$product["price"]

...REPLACE with:

tapestry_price($product["price"])

In the following files:

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

And of

$mainProduct["price"]

...REPLACE with:

tapestry_price($mainProduct["price"])

in html/product.php

Cheers,
David.
--
PriceTapestry.com

Submitted by Blastaway on Mon, 2012-01-02 07:52

Hi David

it did work very well, got problem with the currency symbol in the product.php page i want it on the right side.

<?php print tapestry_price($mainProduct["price"]); ?>&nbsp;<?php print translate("from"); ?>&nbsp;
how do i ad it to this row?

Submitted by support on Mon, 2012-01-02 10:10

Hi,

In each of the html/ files where price is displayed, the original code would display $config_currencyHTML prior to the price; e.g.

$config_currencyHTML.$product["price"]

...so swapping them around would be just:

$product["price"].$config_currencyHTML

In your line of code (which I think won't be displaying the currency at all at the moment) use:

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

Cheers,
David.
--
PriceTapestry.com

Submitted by Blastaway on Mon, 2012-01-02 13:17

Thx it did work very well.
i did get ride of all the .00 but not on the compare line in the serchresults.php

on this line:

 <em><?php print translate("from"); ?></em>&nbsp;<strong><?php print $product["minPrice"].$config_currencyHTML?></strong><br />

how can i change this line of code so the price don´t show .00?

Submitted by support on Mon, 2012-01-02 13:54

Hi,

Using your new tapestry_price function that line would be:

 <em><?php print translate("from"); ?></em>&nbsp;<strong><?php print tapestry_price($product["minPrice"]).$config_currencyHTML?></strong><br />

Cheers,
David.
--
PriceTapestry.com