Page 1 of 4 123 ... LastLast
Results 1 to 10 of 298

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    663
    Plugin Contributions
    0

    Default Currency Update (Automatic)

    This contribution was already posted by myself on the forums a long time ago, but it seems to be lost for the newer zenners not knowing about it.
    Here is a link to this mod: Automatic Currency Update.

    This script is designed to run via cronjob within certain interval you may/must set. Once done, the script will check oanda.com or xe.com server with the current conversion rate and update your store.

    This is extremely useful, if you don't click on the update button every hour

    Installation is very easy - just drop in the file and set the directory path to your Zen-Cart setup, if this script is not running in your Zen-Cart's folder. After that, set up the cronjob.

    This is one of the wonderful set it & forget it options that are quite useful to have!
    Last edited by kuroi; 28 Feb 2010 at 11:14 AM. Reason: Edit link to point to mod's downloads page, not out-of-date version on original author's site

  2. #2
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Hello! Can you tell me what I should put in when I'm doing the cron job and it asks for the Command to run? Also, should I be choosing the Standard or Advanced (Unix) mode when doing the cron job?

    Thanks!
    Danielle

  3. #3
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    663
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Standard or Advanced one is self explaining. If you were in expert in this (cronjob) area, then ofcourse you would be choosing the advancded one, but I guess you wouldn't be asking.

    The command to run is just the complete file path to this update script. A real "advancded" command is like this
    30 * * * * /full/path/to/cron/script/file.php
    which runs every 30 mins. In the normal view, you are given the option to let the xpanle generator set up the complete command to run (additional to the file path).

  4. #4
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Thank you! So I can use the Standard mode and just put http://www.mysite.com/currency_update.php or wherever my script is located?
    Danielle

  5. #5
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Hmmm it's not working. It sends an e-mail each times it runs and says this: /bin/sh: line 1: http://www.babyplanet.ca/currency_update.php: No such file or directory

    But the file is there...
    Danielle

  6. #6
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    663
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    You will have to use the exact system file path to this file. You shouldn't be using the web location in your cron.

    It should be something like this
    /var/www/~user123/html/file.php

  7. #7
    Join Date
    Feb 2007
    Posts
    4
    Plugin Contributions
    0

    Default Re: Currency Update (Automatic)

    Hello,

    The problem might not always be with cron. Generally, if you run php from console, you should define where php resides on your system. Locate your php binary and add this to the first line of the currency_update.php:

    #!/usr/bin/php

    When the file (with +x rights) is run, it will tell the system to use the /usr/bin/php to interpret its contents.

    The plugin works extremely well, big thanks to the author :-)

  8. #8
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Re: Currency Update (Automatic)

    Hello Kuroi
    I am trying to get this mod working on my site but I keep getting errors when I run the cron job.

    I have a few websites on the same hosting package. Is it possible to get this to work with all the different website Knowing that they are all using Zen cart 1.38a?
    At the moment I am trying to test the cron job on one website. but I keep getting an error in the cron job
    Warning: require_once(/ohiospeedshop/includes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home/coolcarp/public_html/currency_update_curled.php on line 20

    Fatal error: require_once() [function.require]: Failed opening required '/ohiospeedshop/includes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/coolcarp/public_html/currency_update_curled.php on line 20
    I have the file in the root of the public html ( /public_html/currency_update_curled.php/) The website I am trying to install this mod on is an addon domain so the link to the site is /public_html/ohiospeedshop/
    This is the code I am using on my site
    Code:
    <?php
    /**
     *  Automatic Currency Update v3.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)
     *
     * @package currencies
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: currency_update.php 1 2008-12-16 12:47:23Z kuroi $
      */
    
    // This describes the path from the location where you install this file to the root directory of your Zen Cart
    // It is normally the only line that you will need to edit.  See readme for guidance.
    DEFINE('PATH_TO_STORE_ROOT','/ohiospeedshop/');
    
    // Get Zen Cart configuration data
    require_once(PATH_TO_STORE_ROOT . 'includes/configure.php');
    require_once(PATH_TO_STORE_ROOT . 'includes/database_tables.php');
    
    //connet to database
    $link = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Could not connect");
    
    //get default currency
    $currency_default = mysql_db_query(DB_DATABASE, "select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key='DEFAULT_CURRENCY' LIMIT 1 ", $link);
    $currency_default= mysql_fetch_array($currency_default);
    define('DEFAULT_CURRENCY', $currency_default[0]);
     
    //get currency conversion ratio
    $currency_uplift_ratio =  mysql_db_query(DB_DATABASE, "select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key='CURRENCY_UPLIFT_RATIO' LIMIT 1 ", $link);
    $currency_uplift_ratio= mysql_fetch_array($currency_uplift_ratio);
    define('CURRENCY_UPLIFT_RATIO', $currency_uplift_ratio[0]); 
    
    // Define currency file
    $ECBFile = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
    $XMLContent = @file($ECBFile);
    if (!is_array($XMLContent) && function_exists('curl_init')) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $ECBFile);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $XMLContent = explode("\n", curl_exec ($ch));
      curl_close($ch);
    }
    
    $currencyArray['EUR'] = 1;
    foreach ($XMLContent as $line) {
      if (ereg("currency='([[:alpha:]]+)'",$line,$currencyCode)) {
        if (ereg("rate='([[:graph:]]+)'",$line,$rate)) {
          $currencyArray[$currencyCode[1]] = (float)$rate[1];
        }
      }
    }
    
    if (sizeof($currencyArray) > 1)
    {
      $currencyQuery = mysql_db_query(DB_DATABASE, "select currencies_id, code from " . TABLE_CURRENCIES . "", $link);
      while ($currency = mysql_fetch_array($currencyQuery)) {
        if ($currency['code'] == DEFAULT_CURRENCY)
        {
          $rate = 1;
        }
        else
        { 
          $rate = ($currencyArray[$currency['code']] / $currencyArray[DEFAULT_CURRENCY]) * CURRENCY_UPLIFT_RATIO;
        }
        $updateSql = "UPDATE " . TABLE_CURRENCIES . "
                      SET value = '" . $rate . "',
                          last_updated = now()
                      WHERE currencies_id = '" . $currency['currencies_id']. "'";
        mysql_db_query(DB_DATABASE, $updateSql, $link);
      }
    }
    
    mysql_close($link);
    ?>
    I am sure I have something wrong somewhere maybe you can help?

  9. #9
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Currency Update (Automatic)

    Quote Originally Posted by Glamorousshoe View Post
    Code:
    DEFINE('PATH_TO_STORE_ROOT','/ohiospeedshop/');
    wouldn't the PATH_TO_STORE_ROOT need to be '/home/coolcarp/public_html/ohiospeedshop/'?

    EDIT: I just checked mine and I have'./' for my root directory so you would need './ohiospeedshop/' but maybe I've always had it wrong and never noticed! :-)
    Last edited by lankeeyankee; 28 Jan 2009 at 08:15 AM.

    Zen Cart and it's community are the best!!

  10. #10
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    55
    Plugin Contributions
    0

    red flag Re: Currency Update (Automatic)


    Hi everyone Awesome scripts, i am with Bravenet and they wont run cron jobs service but they said something about triggering the script to make it work? I found http://www.cronjobs.org but i cant really make sense of it all.
    If anyone could help me with my major delema it would be heaps appreciated

 

 
Page 1 of 4 123 ... 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

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