Post by SamNabz » Mon Nov 26, 2018 11:21 am

Hey all,

Since the free Yahoo API no longer works for automatic currency updates in OC, I was wondering if anyone has managed to find a new free provider?

All of the ones I have found that offer a free API are restricted to certain currencies, none of which I can use. And yes, whilst I can use a different default currency as a workaround, it means I will need to change all product pricing in the store to accommodate for this (which is not ideal).

Surely someone has managed to replace it? Any help/info with this is appreciated.
Last edited by SamNabz on Tue Nov 27, 2018 9:56 am, edited 1 time in total.

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by SamNabz » Mon Nov 26, 2018 4:46 pm

Hey ocmta,

I tried both of them, but unfortunately they don't support my currency (AUD) on the free plan. USD and EUR only.

Also tried Fixer.io (same deal).

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by IP_CAM » Tue Nov 27, 2018 2:55 am

Official OC Update Currency Patch
Yahoo currency API not providing service for updated currency anymore.
We had made an update extension for the previous released OpenCart system now.
User can upload the extension with change the API without edit code.
https://www.opencart.com/index.php?rout ... n_id=32694
Image

I am no longer active at this Forum.
Please don't send Personal Messages, contact: jti@jacob.ch
---
Github OC Downloads: https://github.com/IP-CAM
2'000+ FREE OC Extensions from the World's largest Github OC Archive.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by ocmta » Tue Nov 27, 2018 3:03 am

IP_CAM wrote:
Tue Nov 27, 2018 2:55 am
Official OC Update Currency Patch
It uses fixer.io, so probably won't help in this situation.

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by IP_CAM » Tue Nov 27, 2018 6:18 am

Oh well, I should have known ... 8)
But there are others for OC v.3 Versions as well, possibly easy to be made work:
Turkish Currency Update Patch
https://www.opencart.com/index.php?rout ... n_id=33183
Turkish Currency Update Patch v1.5
https://www.opencart.com/index.php?rout ... n_id=33425

I am no longer active at this Forum.
Please don't send Personal Messages, contact: jti@jacob.ch
---
Github OC Downloads: https://github.com/IP-CAM
2'000+ FREE OC Extensions from the World's largest Github OC Archive.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by SamNabz » Tue Nov 27, 2018 6:44 am

Thanks for your the info, fellas. But I wasn't able to get any of them working with my default currency (AUD) and the 5 others I'm using. Looks like I will have to go with a paid solution ::)

Appreciate the help.

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by SamNabz » Tue Nov 27, 2018 8:03 am

Hey ocmta,

I used the free 'Exchange Rate Providers' module (https://www.opencart.com/index.php?rout ... n_id=32355) and attempted to add the free tool you provided to it, but I wasn't able to get it working. Here are the changes I made:

File: admin/model/localisation/currency.php
After:

Code: Select all

} elseif ($provider == 'openexchangerates') {
  $url = "https://openexchangerates.org/api/latest.json?app_id=".$apikey."&base=".$base_currency."&symbols=".$currencies;
Added:

Code: Select all

} elseif ($provider == 'freecurrencyconverter') {
  $url = "https://free.currencyconverterapi.com/api/v6/convert?q=".$base_currency."_".$currencies."&compact=y";
After:

Code: Select all

} elseif (($provider == 'openexchangerates') && !empty($response['error'])) {
  $error = sprintf($this->language->get('error_rates_provider'), $this->language->get('rates_providers_'.$provider), $response['status'], $response['description']);
Added:

Code: Select all

} elseif (($provider == 'freecurrencyconverter')) {
  $error = sprintf($this->language->get('error_rates_provider'), $this->language->get('rates_providers_'.$provider), 0, $response['error']);
File: admin/controller/setting/setting.php
Before:

Code: Select all

array('value' => 'openexchangerates', 'title' => $this->language->get('rates_providers_openexchangerates')));
Added:

Code: Select all

array('value' => 'freecurrencyconverter', 'title' => $this->language->get('rates_providers_freecurrencyconverter')),
File: admin/language/*/*.php
After:

Code: Select all

$_['rates_providers_openexchangerates'] = "OpenExchangeRates";
Added:

Code: Select all

$_['rates_providers_freecurrencyconverter'] = "Free Currency Converter";
Currency Page Result
**Notice that both the default currency (AUD) and the USD currency both have the default value of 1.00000000
Image

Any ideas on how to get this working? I'm sure I'm missing something simple...
Last edited by SamNabz on Tue Nov 27, 2018 8:30 am, edited 1 time in total.

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by ocmta » Tue Nov 27, 2018 8:22 am

$currencies there contain a list of comma separated currencies, e.g. "AUD_GBP,CAD,EUR", and that format is not supported by free.currencyconverterapi.com , it requires currencies like this: "AUD_GBP,AUD_CAD", and also free version only supports 2 pairs max in the same request. So i guess you'll need to split that into multiple requests. Also its output format is different:

Code: Select all

{"AUD_GBP":{"val":0.563793},"AUD_CAD":{"val":0.957239}}

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by SamNabz » Tue Nov 27, 2018 8:37 am

Hey ocmta,

Are you able to give me an example of how this would look split up? I still can't get it to work :-\

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by ocmta » Tue Nov 27, 2018 9:00 am

OK, here is complete replacement for function refresh. I did not test it so can't guarantee it actually works, it's not optimal and it's doesn't have any error checking or reporting, basically just to give you the idea (sorry, i don't have time for more):

Code: Select all

public function refresh($force = false) {
		$currency_data = array();

		if ($force) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
		} else {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" .  $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
		}

		foreach ($query->rows as $result) {
			$curl = curl_init();
			$currency_key = $this->config->get('config_currency') . '_' . $result['code'];
			curl_setopt($curl, CURLOPT_URL, 'https://free.currencyconverterapi.com/api/v6/convert?q=' . $currency_key . '&compact=ultra');
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($curl, CURLOPT_HEADER, false);
			curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
			curl_setopt($curl, CURLOPT_TIMEOUT, 30);
			$content = curl_exec($curl);		
			curl_close($curl);
			$content = json_decode($content, true);
			if(isset($content[$currency_key])) $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$content[$currency_key] . "', date_modified = '" .  $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($result['code']) . "'");
		}
		$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');
	}

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by SamNabz » Tue Nov 27, 2018 9:56 am

Thank you, ocmta. That worked perfectly!!

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia
Who is online

Users browsing this forum: No registered users and 17 guests