You are here:  » Currency Converters

Support Forum



Currency Converters

Submitted by bat on Fri, 2011-04-15 14:32 in

On my PT I have all products in GBP as I only deal with UK affiliates. However, if I wanted to add a dollar or other currency affiliate, is there some code I could use to do the equation to show the GBP equivalent for that particular affiliate? Or would this be impossible due to the ever changing currency strengths?

Same goes for a site wide conversion, i.e. is there a way users could select what currency they view the site in?

No problems if none of this can be done, I'm just interested if any of this is possible.

Thanks

Submitted by support on Thu, 2011-04-21 12:59

Hello bat,

It's straight forward to override the configured currency HTML for selected merchants. Start by adding the following code to your top of your includes/tapestry.php, immediately after the opening PHP tag:

  // array of non configured currency merchants
  $tapestry_currency["Merchant Name 1"] = "USD";
  $tapestry_currency["Merchant Name 2"] = "USD";
  function tapestry_curencyHTML($product)
  {
    global $config_currencyHTML;
    global $tapestry_currency;
    if ($tapestry_currency[$product["merchant"]])
    {
      return $tapestry_currency[$product["merchant"]];
    }
    else
    {
      return $config_currencyHTML;
    }
  }

Next, it's a case of replacing each instance of $config_currencyHTML with all files in the /html/ folder with a call to the above function. The function needs to know the merchant name, so it must be passed the product array that is used to display the price which in most cases is $product, so you would SEARCH:

$config_currencyHTML

REPLACE:

tapestry_currencyHTML($product)

The only instance where it is not $product is in html/product.php at line 23 where the REPLACEment would be:

tapestry_currencyHTML($mainProduct)

Bear in mind that this would only be suitable where all merchants for a particular product are in the same currency otherwise the strongest currency is going to have a distinct advantage..! In general I wouldn't recommend trying to mix currencies in the same installation.

Cheers,
David.
--
PriceTapestry.com