1a. Download code from https://github.com/btcgear/Bitcoin_Exchange_Rate_OpenCart and extract somewhere.
1b. Download code from https://github.com/coinbase/coinbase-php and copy the 'lib' folder to \upload\catalog\controller\common\ in above dir.
2. Edit the file \upload\catalog\controller\common\bitcoin_update.php as follows; Replace everything after public function runUpdate() { (line 60) with;
Code:
require_once(dirname(__FILE__) . '/lib/Coinbase.php');
$default_currency_code = $this->config->get('config_currency');
// API settings
$_API_KEY = "YourCoinbaseApiKey";
$_API_SECRET = "YourCoinbaseApiSecret";
// run the query
$coinbase = Coinbase::withApiKey($_API_KEY, $_API_SECRET);
$currency = "BTC";
$value = $coinbase->getSpot();
if ((float)$value) {
$value = 1/$value;
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
}
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
$this->cache->delete('currency');
}
}
?>
3. Install code as per instructions in instructions.txt
Please let me know if you need any help or something, or can make the code better - or fork it on Git for me!