Page 29 of 30 FirstFirst ... 1927282930 LastLast
Results 281 to 290 of 298
  1. #281
    Join Date
    May 2014
    Location
    United States
    Posts
    14
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Hello, I have a question about this module.

    To start, I used the info that GizmoTronic provided in post #270.
    My store is based in the United States, so I changed the info in the php file that is uploaded to the server on lines 53 and 82 to USD.

    I have it all setup correctly and it seems to be functioning to update the currencies. The problem I am running into is it is updating them to an incorrect dollar amount. If I push the button in Zen Cart for "Updating Currencies" it updates them to the correct and current amounts at that particular time of day. So the zen cart built in feature is working correctly.

    But, when I have the Cron Job setup to process the auto currency updater, It is setting the currency values to a completely incorrect number. Here are the before and after rates.

    Before:
    AUD = 1.05778
    CAD = 1.06567
    EUR = .73056692
    GBP = .583065
    USD = 1.00000

    After the Cron Job executes the Currency Updater the currencies come back as this:
    AUD = 1.4479006
    CAD = 1.4586994
    EUR = .73056692
    GBP = .79809999
    USD = 1.0000000

    The first thing I noticed was the Euro wasn't changed at all, and it remains the correct currency rate. All the other ones except the Euro and the USD were affected and gave back a completely incorrect currency rate.

    Does anyone have any suggestions on what the issue could be with this?

    I really appreciate anyone who has an input on solving this issue.
    Thanks in advance!
    Chris

  2. #282
    Join Date
    May 2014
    Location
    United States
    Posts
    14
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Well, To respond to my above question. I think I figured out a solution that will work. I don't know if it is correct, but it works.

    So, Above I mentioned that I changed the .php file that you upload to your server. I put in USD in place of EUR. I figured it would be worth changing this around and see what happened. I put it back to EUR and still left my Zen Cart Default currency to USD and sure enough it is updating correctly now.

    I manually changed all the currencies that I have in Zen Cart to very incorrect figures. (changed AUD from 1.05 to 1.55, ETC) I setup the Cron Jobs to perform the currency update a few minutes later and sure enough it updated all the currencies back to their correct amounts. I tried it two times and worked correctly both times. So I am going to setup the cron job to run every day at 7am and see what happens.

    If anyone has any input though, I would be more than happy to hear what others have to say about this.

    Thanks,
    Chris

  3. #283
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Currency Update (Automatic)

    This is listed as the official support thread for the Automatic Currency Updater.

    I'm noticing TWD isn't being updated. I also notice that ECB doesn't have TWD, is that why? It is a PayPal currency and those, at the very least, should all be supported, no? Or am I just missing something? Thanks.

  4. #284
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Currency Update (Automatic)

    s_mack,
    You can add a new currency in your admin
    Zen-Venom Get Bitten

  5. #285
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Currency Update (Automatic)

    not my point... I *DO* have the currency in admin... it doesn't get updated. I've looked into it further and yes, it is because this mod and, in fact, the core files themselves, are reliant on a very limited set of data. They chose to use ECB which only provides data for about 30 currencies... there are over 160 in use in the world.
    Last edited by s_mack; 25 Oct 2015 at 07:19 AM.

  6. #286
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Currency Update (Automatic)

    For those interested in a more expanded set of currencies, here is my version. Note that you have to sign up (free) for an API key at openexchangerates.org and enter that in.

    Code:
    <?php
    /*
     * Automatic Currency Update v6.0
     * Originally by Richard Fink (masterblaster)  based on Zen Cart manual currency update
     * updated by Kuroi to include Zen Cart's currency uplift ratio
     * further updated by Kuroi to use European Central Bank reference rates  (adapted from ECB-supplied code)
     * updated by Zen4All (design75) use Zen Cart standard coding
     *
     * Rework for PHP 5.3 compatibility (ereg and mysql_db_query functions deprecated in PHP 5.3.0)
     * switched to using SimpleXML and mysqli instead.
     * JeRo www.jero.co.nz 18/06/2010
     *
     * modified by s_mack to use openexchangerates instead of very limited ECB. Simplified some logic.
     * license: GNU Public License V2.0
     *
     */
    
    require_once('includes/application_top.php');
    //  Sign up for openechangerates.org API and enter your ID below
    $openexhangeratesapi = "";
    /*
     *  Get default currency.
     */
    $defaultCurrency = $db->Execute("SELECT configuration_value
                                    FROM " . TABLE_CONFIGURATION . "
                                    WHERE configuration_key = 'DEFAULT_CURRENCY' LIMIT 1 ");
    
    $defaultCurrency = $defaultCurrency->fields['configuration_value'];
    
    /* 
     * Get currency conversion ratio.
     */
    $currencyUpliftRatio = $db->Execute("SELECT configuration_value
                                         FROM " . TABLE_CONFIGURATION . "
                                         WHERE configuration_key = 'CURRENCY_UPLIFT_RATIO' LIMIT 1 ");
    
    //grab the full dataset from openechangerates.org
    
    $currency_data = file_get_contents('http://openexchangerates.org/api/latest.json?app_id=' . $openexhangeratesapi);
    $currency_data = json_decode($currency_data, true);
    
    //since USD is not represented in the dataset, lets push it in
    $currency_data['USD'] = 1;
    
    
    // extract your default currency's exchange rate.
    
    $defaultRate = (float)$currency_data['rates'][$defaultCurrency];
    
    // put each currency into the DB, adjusted with the currency uplift ratio
    
    foreach ($currency_data['rates'] as $code => $rate) {
      $rate = ( $code == $defaultCurrency ? 1 : (float)$rate * $currencyUpliftRatio->fields['configuration_value'] / $defaultRate );
      $sql_data_array = array('value' => $rate,
                              'last_updated' => 'now()',
                              'code' => $code);
      zen_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "code = '" . $code . "'");
    }
    You'll notice in the comments I took the liberty of calling this V6 and adding my name... I did rewrite a bit of the logic to clean it up, in my opinion, as it was sort of making redundant-ish calls. Not important. I'm not uploading it to the downloads section so use or don't.

  7. #287
    Join Date
    Apr 2010
    Posts
    269
    Plugin Contributions
    1

    Default Re: Currency Update (Automatic)

    I just updated to 6.0 a couple of days ago, and the email I receive back from my host has errors in it:
    /home2/redsauto/public_html/currency_update.php: line 1: ?php: No such file or directory
    /home2/redsauto/public_html/currency_update.php: line 2: /0: Permission denied
    /home2/redsauto/public_html/currency_update.php: line 3: access-logs: command not found
    /home2/redsauto/public_html/currency_update.php: line 4: syntax error near unexpected token `('
    /home2/redsauto/public_html/currency_update.php: line 4: ` * Originally by Richard Fink (masterblaster) based on Zen Cart manual currency update'
    This makes no sense whatsoever.

    V6.0:
    Code:
    <?php
    /*
     * Automatic Currency Update v5.0
     * Originally by Richard Fink (masterblaster)  based on Zen Cart manual currency update
     * updated by Kuroi to include Zen Cart's currency uplift ratio
     * further updated by Kuroi to use European Central Bank reference rates  (adapted from ECB-supplied code)
     * updated by Zen4All (design75) use Zen Cart standard coding
     *
     * Rework for PHP 5.3 compatibility (ereg and mysql_db_query functions deprecated in PHP 5.3.0)
     * switched to using SimpleXML and mysqli instead.
     * JeRo www.jero.co.nz 18/06/2010
     *
     * license: GNU Public License V2.0
     *
     */
    
    require_once('includes/application_top.php');
    V5.0:
    Code:
    #!/usr/bin/php
    <?php
    
    /**
     * Automatic Currency Update v4.0
     * Originally by Richard Fink (masterblaster)  based on Zen Cart manual currency update
     * updated by Kuroi to include Zen Cart's currency uplift ratio
     * further updated by Kuroi to use European Central Bank reference rates  (adapted from ECB-supplied code)
     *
     * Rework for PHP 5.3 compatibility (ereg and mysql_db_query functions deprecated in PHP 5.3.0)
     * switched to using SimpleXML and mysqli instead.
     * JeRo www.jero.co.nz 18/06/2010
     *
     * license: GNU Public License V2.0
     *
     **/
    
    # Set this to the physical path of your installation.
    # Make sure to include the trailing "/"
    define('PATH_TO_STORE_ROOT','');
    It looks like it is trying to execute the commented out section, and is not recognizing the <?php

  8. #288
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Currency Update (Automatic)

    Looks to me like you simply didn't copy the very first character of the code

  9. #289
    Join Date
    Apr 2010
    Posts
    269
    Plugin Contributions
    1

    Default Re: Currency Update (Automatic)

    Quote Originally Posted by s_mack View Post
    Looks to me like you simply didn't copy the very first character of the code
    Do you mean this:
    Code:
    #!/usr/bin/php
    That's not in the newest version. How I posted it, is exactly like I downloaded it.
    Also, I got the version numbers wrong in my previous post. The correct versions are in the code.

  10. #290
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Currency Update (Automatic)

    PHP Code:
    #!/usr/bin/php 
    Was used in version 4 and presumably earlier. As of version 5 it is no longer in the currency_update.php file.

 

 
Page 29 of 30 FirstFirst ... 1927282930 LastLast

Similar Threads

  1. Automatic Currency Updates - curl version problem
    By mtimber in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 10 Dec 2008, 07:53 PM
  2. Automatic Currency Selection for a domain
    By [email protected] in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 3
    Last Post: 5 Jun 2007, 09:38 AM
  3. Automatic Currency Updates
    By dustyservers in forum Customization from the Admin
    Replies: 6
    Last Post: 28 Jun 2006, 12:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR