Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Please help with a bit of code


Recommended Posts

What I want to do is simple: grab the text from a field in the database. My canadian shipping module returns costs in CDN funds and I want to get the conversion rate (called "value") from the database which I have stored in my Canadian currency, that way the price would show in USD.


I already know exactly where to put it:

'cost' => (SHIPPING_HANDLING + $cost * 0.91) * $shipping_num_boxes);


I want to replace the 0.91 with the info from the db. Can anyone show me how? I don't need the exact code to make it work, even just the code I could use to grab any field of text would help. Thanks.

Link to comment
Share on other sites

This is my idea (that doesnt work):

$usdconvert = tep_db_query("select value from " . TABLE_CURRENCIES . " where currencies_id = '3'");


Then I replace the 0.91 with $usdconvert, but that doesnt work.

Link to comment
Share on other sites

I have code that returns the exact information I want, however when I replace it with the 0.91 the cost result is always 0. When I enter in an actual number, it always works.



'cost' => (SHIPPING_HANDLING + $cost * 0.91) * $shipping_num_boxes);

Doesnt work:

'cost' => (SHIPPING_HANDLING + $cost * $exchange_amount_row["value"]) * $shipping_num_boxes);

The code I'm using to get the exchange amount (works when I echo the exchange amount anywhere else but where I showed above):

$exchange_amount = mysql_query("SELECT value FROM " . TABLE_CURRENCIES . " WHERE currencies_id=3");
// change 6 to whatever your currency is - check mysql table currencies
$exchange_amount_row = mysql_fetch_array($exchange_amount);
$dollar_amount = $exchange_amount_row["value"];
$dollar_amount = number_format($dollar_amount, 2);
$exchange_amount_row["value"] = number_format($exchange_amount_row["value"], 2);

Any ideas? :blink:

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...