You are here:  » Add US in front of price


Add US in front of price

Submitted by Pep on Thu, 2016-05-19 22:36 in

Hi
Nearly all my feeds are in AU dollars but I now have a few that are in US. I was hoping to put US in front of the price field but have not been successful. I put %US% in the text before filter for the price field then imported but cannot get it to work. Any ideas.
Cheers

Submitted by support on Fri, 2016-05-20 08:27

Hello Pep,

The easiest thing to do that would not require any database changes would be to add an array of US dollar merchants to config.php, and then wherever a price is if the merchant is in this list then add the US prefix. To do this, add the following to config.php:

  $config_usMerchants = array("Merchant 1","Merchant 2","Merchant 3");

And then for display within the price comparison table, edit html/prices.php and look for the following code at line 59:

<td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>

...and REPLACE with:

<td class='pt_pr_price'>
<?php print (in_array($product["merchant"],$config_usMerchants)?"US ":""); ?>
<?php print tapestry_price($product["price"]); ?>
</td>

For the main product price, edit html/product.php and look for the following code at line 52:

<?php print tapestry_price($product_main["price"]); ?> <?php print translate("from"); ?>

...and REPLACE with:

<?php print (in_array($product_main["merchant"],$config_usMerchants)?"US ":""); ?>
<?php print tapestry_price($product_main["price"]); ?>
<?php print translate("from"); ?>

For search results, first edit search.php and look for the following code at line 476:

$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

...and REPLACE with:

$sql2 = "SELECT id,merchant,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

Next, edit html/searchresults.php and look for the following code at line 59:

<span class='pt_sr_price'><?php print tapestry_price($product["minPrice"]); ?></span>

...and REPLACE with:

<span class='pt_sr_price'>
<?php print (in_array($product["merchant"],$config_usMerchants)?"US ":""); ?>
<?php print tapestry_price($product["minPrice"]); ?>
</span>

And finally for Featured Products, edit html/featured.php and look for the following code at line 25:

<span class='pt_fp_price'><?php print tapestry_price($product["minPrice"]); ?></span>

...and REPLACE with:

<span class='pt_fp_price'>
<?php print (in_array($product["merchant"],$config_usMerchants)?"US ":""); ?>
<?php print tapestry_price($product["minPrice"]); ?>
</span>

Bear in mind that things could become more complex if you need to deal with comparison between merchants with products in different currencies (the above really assumes that search results / features products and product pages will only be for a single merchant's products) however in case you had not come across it there is code for a currency conversion filter here...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Pep on Fri, 2016-05-20 22:35

Hi David
I will try setting up the currency converter. So will post from there.
Cheers