Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.

Currency Update (Automatic)

23 Jun 2011, 7:48 PM
#241
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Post #241 by athens_collectibles

Steve, the confirmation was mine but the add-on wasn't developed by me, I'm just a user like you!

23 Jun 2011, 7:50 PM
#242
spembleton avatar

spembleton

Zen Follower

Join Date:
Jun 2010
Location:
Holland, MI
Posts:
232
Plugin Contributions:
0

Post #242 by spembleton

Then thank you for the confirmation, and thanks to the author for the add-on

17 Aug 2011, 2:01 PM
#243
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Post #243 by gazag

Can anyone help out?

I have installed this mod once and it has worked great. I am setting up a new store with the multistore add on and i now get the error below.

X-Powered-By: PHP/5.2.17
Content-type: text/html

the domain does not exist.

Any ideas???

17 Aug 2011, 2:08 PM
#244
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #244 by kuroi

Have you posted in the wrong thread? Can't see what this has to do with the automatic currency update?

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

17 Aug 2011, 2:13 PM
#245
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Post #245 by gazag

kuroi:

Have you posted in the wrong thread? Can't see what this has to do with the automatic currency update?

No i have installed the automatic currency updater and i am getting an error in the email from the cron job that says

X-Powered-By: PHP/5.2.17
Content-type: text/html

the domain does not exist.

i have the multisite contribution added to my site and when i remove the pce of code that you have to add to the includes/config file

include_once('includes/config_sites/sites_switch.php');

it works fine.
How do i fix this??

17 Aug 2011, 4:20 PM
#246
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Post #246 by gazag

i also got this error a couple of times from the cron email but it has quit now!!??!!??

<br /> <b>Warning</b>: include_once(includes/config_sites/sites_switch.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in <b>/HOME*/USER_NAME/public_html/includes/configure.php</b> on line <b>2</b><br /> <br /> <b>Warning</b>: include_once() [<a href='function.include'>function.include</a>]: Failed opening 'includes/config_sites/sites_switch.php' for inclusion (include_path='.:/usr/share/pear') in <b>/HOME*/USER_NAME/public_html/includes/configure.php</b> on line <b>2</b><br />

Has anyone else got this working as well as multisite??

17 Aug 2011, 4:57 PM
#247
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #247 by kuroi

The problems that you're reporting seem to be linked to the code added for multisite rather than the code being executed for this mod.

It's possible that this is because the multisite code or instructions are using relative rather than absolute paths, so if you run this mod from somewhere other than the root of your site, it can't resolve those paths properly. But that would need to diagnosed and fixed by somebody familiar with multisite.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

14 Sep 2011, 12:33 PM
#248
arovuo avatar

arovuo

New Zenner

Join Date:
Jul 2007
Posts:
13
Plugin Contributions:
0

Post #248 by arovuo

Moi,

Oanda and XE keeps giving me errors, so I have added one more server and updated my code accordingly.

admin/includes/functions/localization.php

  • added new function
  function quote_ecb_currency($code, $base = DEFAULT_CURRENCY) {

    $xml= new SimpleXMLElement(file_get_contents("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"));

    # extract default currency's exchange rate.
    $nzd = $xml->xpath("//*[@currency='".$base."']");
    $base_rate = (float)$nzd[0]['rate'];
    if ($base == 'EUR') {$base_rate=(float)1;}
    
    # extract requested currency's exchange rate.
    $nzd = $xml->xpath("//*[@currency='".$code."']");
    $rate = (float)$nzd[0]['rate'];
    if ($code == 'EUR') {$rate=(float)1;}

    $new_rate = $rate/$base_rate;

    if ($new_rate != 0) return $new_rate;
    else return null;
  }

admin/currencies.php

  • updated the 'update' with completely new code.
      case 'update':
        $currency = $db->Execute("select currencies_id, code, title from " . TABLE_CURRENCIES);
        $servers = array('ecb', 'oanda', 'xe');
        zen_set_time_limit(600);
        while (!$currency->EOF) {
          foreach($servers as $server_used){
            $quote_function = 'quote_' . $server_used . '_currency';
            $rate = $quote_function($currency->fields['code']);
            if (!empty($rate)){
              /* Add currency uplift */
              if ($rate != 1 && defined('CURRENCY_UPLIFT_RATIO')) {$rate = (string)((float)$rate * (float)CURRENCY_UPLIFT_RATIO);}
              $db->Execute("update " . TABLE_CURRENCIES . "
                set value = '" . $rate . "', last_updated = now()
                where currencies_id = '" . (int)$currency->fields['currencies_id'] . "'");
              $messageStack->add_session(sprintf(TEXT_INFO_CURRENCY_UPDATED, $currency->fields['title'], $currency->fields['code'], $server_used), 'success');
              break;
            }
            else $messageStack->add_session(sprintf(WARNING_SERVER_FAILED, $server_used, $currency->fields['title'], $currency->fields['code']), 'warning');
          }
         $currency->MoveNext();
        }
        zen_redirect(zen_href_link(FILENAME_CURRENCIES, 'page=' . $_GET['page'] . '&cID=' . $_GET['cID']));
      break;

admin/includes/languages/english/currencies.php

  • added new definition
define('WARNING_SERVER_FAILED', 'Warning: The exchange rate server (%s) failed for %s (%s)');

I do not have automatic updates, but now I have European Central Bank (ECB) daily rates as a primary exchange rate server :clap:

14 Sep 2011, 12:43 PM
#249
arovuo avatar

arovuo

New Zenner

Join Date:
Jul 2007
Posts:
13
Plugin Contributions:
0

Post #249 by arovuo

BTW. the original zencart code has a bug. If both, the primary(oanda) AND backup(xe) server fails to provide sane rate, the particular currency rate will become corrupt/zero.

14 Sep 2011, 7:51 PM
#250
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #250 by drbyte

As has been stated elsewhere, ECB support is built-in to v1.5.0, as well as resolution of the problem that would set values to 0 if the update failed. I can't speak to how any automated-update scripts work, but the core ZC code is fine.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Sep 2011, 2:45 AM
#251
grantsja avatar

grantsja

New Zenner

Join Date:
Jul 2010
Posts:
9
Plugin Contributions:
0

Post #251 by grantsja

Hi

I set up a new Zen Cart site 1.39h and installed the automatic currency update. The default currency in JMD (jamaican dollars) and I also have US dollars. I am getting a division by zero error message when the currency update runs.

<b>Warning</b>: Division by zero in <b>/<my path>/currency_update.php</b> on line <b>71</b><br />

Do you have any suggestions?
Thanks
b

28 Sep 2011, 3:12 AM
#252
grantsja avatar

grantsja

New Zenner

Join Date:
Jul 2010
Posts:
9
Plugin Contributions:
0

Post #252 by grantsja

OK - I see that the ECB XML file does not include the Jamaican Dollar. I see references to Oanda in this thread. Will read tomorrow when I am not so tired.
Thanks
b

1 Dec 2011, 6:14 PM
#253
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Post #253 by gazag

Hello,

I have several currencies on my zencart installation and all of them update fine using the manual update. The following don't update using the automatic updater although the other 8 do!
Argentinian Peso ARS
Barbadian Dollar BBD
Jamaican Dollar JMD
Trinidadian Dollar TTD

Does anyone have any ideas as to why they don't update automatically???

1 Dec 2011, 6:28 PM
#254
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Post #254 by athens_collectibles

Hi,

The mod gets the rates from the ECB site. ECB does not publish rates for every currency in the world and those mentioned above are obviously not included in the list.

Check the ECB published rates to see currencies included.

19 Dec 2011, 8:30 AM
#255
magwongpc avatar

magwongpc

New Zenner

Join Date:
Nov 2011
Posts:
3
Plugin Contributions:
0

Post #255 by magwongpc

I have a similar problem. I have change the root path to as per suggested post #223

How will I know if the mod works?

20 Dec 2011, 3:13 AM
#256
magwongpc avatar

magwongpc

New Zenner

Join Date:
Nov 2011
Posts:
3
Plugin Contributions:
0

Post #256 by magwongpc

magwongpc:

I have a similar problem. I have change the root path to as per suggested post #223

How will I know if the mod works?

I think it's working now. It's something to do with my web hosting.

They corrected the problem.

I am receiving CRON emails which is empty in the text area so it should be working right?:clap:

20 Dec 2011, 7:26 AM
#257
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Post #257 by athens_collectibles

I am receiving CRON emails which is empty in the text area so it should be working right?Right, well done! :yes:

21 Dec 2011, 3:12 AM
#258
magwongpc avatar

magwongpc

New Zenner

Join Date:
Nov 2011
Posts:
3
Plugin Contributions:
0

Post #258 by magwongpc

I have the mod working but I realised that as the exchange rate comes from ECB site, it publishes the rate default to EURO so it meesed up my exchange rates. Please advice can I do? ECB has most but 1 of the currency that I listed.

I installed mod v2 and it works very well. However, I just read the thread and realised that it is not legal to use?

I am new to php and zencart so please advice how should I go about this?

Many thanks

13 Jan 2012, 3:17 PM
#259
spembleton avatar

spembleton

Zen Follower

Join Date:
Jun 2010
Location:
Holland, MI
Posts:
232
Plugin Contributions:
0

Post #259 by spembleton

Will v4.0 work with Zencart 1.5?

13 Jan 2012, 10:47 PM
#260
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #260 by drbyte

FYI - The ECB support is built-in to v1.5.0

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.