Guillaume Posted April 6, 2021 Share Posted April 6, 2021 Hello, I am developping a payment gateway to connect my Cubecart-powered website with French PSP Systempay. Not that I specifically need that myself, but for the sake of public interest, I would like the gateway to support multi-currencies (provided, of course that the website owner has the correct set-up but in Cubecart and in Systempay). Where I am struggling is on how to retrieve the exchange rates, which we have in Cubecart's admin panel. I have tried the following, all of them staying empty: $currency_records = $GLOBALS['db']->select('CubeCart_currency','exchange_rate',array('code' => $currencyCode)); if ($currency_records !== false) $exchange_rate = $currency_records[0]['exchange_rate']; //here I was mimicking the way I retrieve the numerical currency code $exchange_rate = $GLOBALS['smarty']->getTemplateVars($currencyCode); $exchange_rate2 = tpl_vars[$currencyCode]->value['exchange_rate']; Apologies if this is a dumb question, I am fairly new here, and haven't seen much documentation as of how to interact with Cubecart's databases and reference data tables. Thanks in advance for any hint! Best regards, Guillaume Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2021 Share Posted April 6, 2021 The column to retrieve is 'value' from CubeCart_currency. We assume $currencyCode is acquired from some other source that relates to the customer's choice in how they are viewing the site. The value retrieved from the table is a multiplier against that distinct currency whose 'value' is "1.0000". Which is to say, the store's default currency. Link to comment Share on other sites More sharing options...
Guillaume Posted April 6, 2021 Author Share Posted April 6, 2021 Thanks a million, I've used the below code and can now get the exchange rate indeed: $currency_records = $GLOBALS['db']->select('CubeCart_currency','value',array('code' => $currencyCode)); if ($currency_records !== false) $exchange_rate = $currency_records[0]['value']; By any chance would you know the equivalent query to retrieve the amount of decimals (which is "2" for nearly all currencies)? I have tried replacing "value" by "decimals_place". Sounded a fair guess from what I saw both in the Cubecart code and in the logs when updating the admin panel (enclosed), but no leads... Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2021 Share Posted April 6, 2021 'decimal_places' Link to comment Share on other sites More sharing options...
Guillaume Posted April 6, 2021 Author Share Posted April 6, 2021 Shame on me... Apologies! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.