Forums / All Other Contributions/Addons / Currency Update (Automatic)

Currency Update (Automatic)

Views: 82,431

Results 201 to 220 of 298
18 May 2010, 12:24 PM
#201
ningyotan avatar

ningyotan

New Zenner

Join Date:
Nov 2009
Posts:
56
Plugin Contributions:
0

Currency Update (Automatic)

I've dumped the file up on my server, altered the root path and it works!

However, if I don't set up the cron job at all, I wont be able to get automatic updates will I?

In which case, I can just run it say once a day myself by typing in the URL?

18 May 2010, 12:28 PM
#202
kuroi avatar

kuroi

Totally Zenned

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

Re: Currency Update (Automatic)

Well yes, you could do that. But you could also just click the update button on the currencies page in the Admin.

Kuroi Web Design and Development | Twitter

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

26 May 2010, 10:16 AM
#203
jezspain avatar

jezspain

New Zenner

Join Date:
Dec 2008
Posts:
8
Plugin Contributions:
0

Re: Currency Update (Automatic)

I have currency update script working ok.

But on my zen cart site I want Euros as the default currency rather than customers having to select euros, so I have euros set as the default currency.

But with us purchasing in US dollars I want to update the other currencies based on the US dollar and the script uses the default currency to update the others.

Any ideas if there is a way I can achieve this please?

26 May 2010, 10:31 AM
#204
kuroi avatar

kuroi

Totally Zenned

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

Re: Currency Update (Automatic)

@jezspain

You're probably attacking this from the wrong end.

Basically of your goods are priced in dollars then your currency conversions need to default to the same currency.

If you want to present a different currency as the default for customers, you need to go to the place that this default is set. This is in the includes/init_includes/init_currencies.php which you can copy to the overrides folder and then replace the reference to DEFAULT_CURRENCY with that which you would like to present first to customers.

Give it a good test though, as I haven't actually tried this in practise.

Kuroi Web Design and Development | Twitter

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

26 May 2010, 11:36 AM
#205
jezspain avatar

jezspain

New Zenner

Join Date:
Dec 2008
Posts:
8
Plugin Contributions:
0

Re: Currency Update (Automatic)

Thanks for the reply Kurio, I think you are right.

I will give it a try from that angle. I have a test site I will try it on first.

28 May 2010, 7:52 AM
#206
jezspain avatar

jezspain

New Zenner

Join Date:
Dec 2008
Posts:
8
Plugin Contributions:
0

Re: Currency Update (Automatic)

@ Kurio,

Not sure if you can help further.

I understood the principle of what you said in your post but I am not sure how to implement it. I copied init_currencies.php into the overides folder, but I don't know enough to know what/where to change the code to get the customer to always see the price in euros first while the default currency is set to US dollars.

I am not sure how hard or easy it is to achieve this but it would be much appreciated if you/someone could help me..

Posting the code below: -

<?php
/**
 * initialise currencies
 * see {@link  [url]http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem[/url] wikitutorials} for more details.
 *
 * @package initSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license [url]http://www.zen-cart.com/license/2_0.txt[/url] GNU Public License V2.0
 * @version $Id: init_currencies.php 6300 2007-05-11 15:49:41Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}

// If no currency is set, use appropriate default
if (!isset($_SESSION['currency']) && !isset($_GET['currency']) ) $_SESSION['currency'] = DEFAULT_CURRENCY;

// Validate selected new currency, if any. Is false if valid not found.
$new_currency = (isset($_GET['currency'])) ? zen_currency_exists($_GET['currency']) : zen_currency_exists($_SESSION['currency']);

// Validate language-currency and default-currency if relevant. Is false if valid not found.
if ($new_currency == false || isset($_GET['language'])) $new_currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? zen_currency_exists(LANGUAGE_CURRENCY) : $new_currency;

// Final check -- if selected currency is bad and the "default" is bad, default to the first-found currency in order of exch rate.
if ($new_currency == false) $new_currency = zen_currency_exists(DEFAULT_CURRENCY, true);
//echo '<br />NEW = ' . $new_currency . '<br />';

// Now apply currency update
if (
   // Has new currency been selected?
  (isset($_GET['currency'])) || 

  // Does language change require currency update?
  (isset($_GET['language']) && USE_DEFAULT_LANGUAGE_CURRENCY == 'true' && LANGUAGE_CURRENCY != $_SESSION['currency']  )

) {
  $_SESSION['currency'] = $new_currency;
  // redraw the page without the currency/language info in the URL
  if (isset($_GET['currency']) || isset($_GET['language'])) zen_redirect(zen_href_link($current_page_base, zen_get_all_get_params(array('currency','language'))));
}
?>
4 Jun 2010, 5:13 PM
#207
ekele avatar

ekele

Zen Follower

Join Date:
Apr 2010
Location:
UK
Posts:
150
Plugin Contributions:
0

Re: Currency Update (Automatic)

Hello, could anyone help with this?
I uploaded the script to /public_html/my shopname.com. I got the right command from my hosting company. They say it should be:
/usr/bin/php -q /home/my username/public_html/myshopname.com/currency_update.php and I have used wrong path. Yes, I used just '/', so I corrected it to: /public_html/my shopname.com/currency_update.php.

And now I get messages:
PHP Warning:
require_once(/public_html/myshopname.com/currency_update.phpincludes/configure.php)
[<a href='function.require-once'>function.require-once</a>]: failed to open stream:
No such file or directory in
/home/myusername/public_html/myshopname.com/currency_update.php on line 20
<br />
<b>Warning</b>:
require_once(/public_html/myshopname.com/currency_update.phpincludes/configure.php)
[<a href='function.require-once'>function.require-once</a>]: failed to open stream:
No such file or directory in
<b>/home/myusername/public_html/myshopname.com/currency_update.php</b> on line
<b>20</b><br />
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]:
Failed opening required
'/public_html/myshopname.com/currency_update.phpincludes/configure.php'
(include_path='.:/usr/lib/php:/usr/local/lib/php') in
/home/myusername/public_html/myshopname.com/currency_update.php on line 20
<br />
<b>Fatal error</b>: require_once() [<a href='function.require'>function.require</a>]: Failed opening required
'/public_html/myshopname.com/currency_update.phpincludes/configure.php'
(include_path='.:/usr/lib/php:/usr/local/lib/php') in
<b>/home/myusername/public_html/myshopname.com/currency_update.php</b> on line
<b>20</b><br />

What does it mean? What should I change?
Any help, please:(

4 Jun 2010, 7:08 PM
#208
ekele avatar

ekele

Zen Follower

Join Date:
Apr 2010
Location:
UK
Posts:
150
Plugin Contributions:
0

Re: Currency Update (Automatic)

OK, it seems to work now. My path is /home/myusername/public_html/myshopname.com/ without "currency_update.php"

8 Jun 2010, 10:44 PM
#209
vanson avatar

vanson

New Zenner

Join Date:
Feb 2009
Posts:
40
Plugin Contributions:
0

Re: Currency Update (Automatic)

kuroi:

Well yes, you could do that. But you could also just click the update button on the currencies page in the Admin.

should i press 'update' button every day?

9 Jun 2010, 8:02 AM
#210
kuroi avatar

kuroi

Totally Zenned

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

Re: Currency Update (Automatic)

@jezspain

Simply change

if (!isset($_SESSION['currency']) && !isset($_GET['currency']) ) $_SESSION['currency'] = DEFAULT_CURRENCY;
to
if (!isset($_SESSION['currency']) && !isset($_GET['currency']) ) $_SESSION['currency'] = 'EUR';

Then open up a new browser window as the change will work only when there's not an old php session lurking, and you'll see it as you customers will.

This assumes, of course, that you have dollars and euros enabled as currencies, though there is protection in that file for if you don't.

Kuroi Web Design and Development | Twitter

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

9 Jun 2010, 8:05 AM
#211
kuroi avatar

kuroi

Totally Zenned

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

Re: Currency Update (Automatic)

vanson:

should i press 'update' button every day?The purpose of this add-on mod is to automate the process by running a CRON job.

In the absence of that automation, it's probably easier to press update each day (or with whatever frequency you feel is appropriate to keep your currencies up-to-date - though more than daily won't have any effect) as it is to install this mod and run it from a browser.

Kuroi Web Design and Development | Twitter

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

10 Jun 2010, 10:38 AM
#212
jezspain avatar

jezspain

New Zenner

Join Date:
Dec 2008
Posts:
8
Plugin Contributions:
0

Re: Currency Update (Automatic)

@kuroi

That has worked fine, thanks for taking the time to reply.

26 Jun 2010, 12:57 AM
#213
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Currency Update (Automatic)

Hi,

I uploaded the file without any changes to store root. and setup the cron job by typing in the command field
"curl http://www.mysite.com/currency_update.php"

But I keep getting this message
/bin/sh: curl http://www.mysite.com/currency_update.php: No such file or directory

I also tried changing to the following but it doesn't work
DEFINE('PATH_TO_STORE_ROOT','/');

What did I do wrong? Please help. Thanks.

**The Team Behind DealByEthan.com | **Curating unique finds for a discerning community. Committed to a seamless and inspiring shopping experience. *Connect with us: *https://linktr.ee/dealbyethan

26 Jun 2010, 1:45 AM
#214
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Currency Update (Automatic)

No need to change anything on the store file system.

Try to set the cron job as:

wget http://www.yoursite.com/currency_update.php

with the appropriate frequency / time settings.

This has worked for me just fine.

Of course, you need to make sure that the currency_update.php file actually resides at top level

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

26 Jun 2010, 5:28 AM
#215
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Currency Update (Automatic)

Hi,

I think what I did actually works... just have to remove the quote marks
curl http://www.mysite.com/currency_update.php

The message I received is this. Does that mean it works?

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

**The Team Behind DealByEthan.com | **Curating unique finds for a discerning community. Committed to a seamless and inspiring shopping experience. *Connect with us: *https://linktr.ee/dealbyethan

26 Jun 2010, 5:40 AM
#216
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Currency Update (Automatic)

Hi,

I changed to what you suggested
wget http://www.mysite.com/currency_update.php

but received the following error. Please advise.

--00:35:01-- http://www.mysite.com/currency_update.php
=> `currency_update.php'
Resolving https://www.mysite.com... XXX.XXX.X.XX Connecting to www.mysite.com|XXX.XXX.X.XX|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
00:35:01 ERROR 403: Forbidden.

**The Team Behind DealByEthan.com | **Curating unique finds for a discerning community. Committed to a seamless and inspiring shopping experience. *Connect with us: *https://linktr.ee/dealbyethan

26 Jun 2010, 6:14 AM
#217
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Currency Update (Automatic)

dealbyethan.com:

Hi,

I changed to what you suggested
wget http://www.mysite.com/currency_update.php

but received the following error. Please advise.

--00:35:01-- http://www.mysite.com/currency_update.php
=> `currency_update.php'
Resolving https://www.mysite.com... XXX.XXX.X.XX Connecting to www.mysite.com|XXX.XXX.X.XX|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
00:35:01 ERROR 403: Forbidden.

That depends on your server configurations - seems the wget is disabled by your host. Could also be prevented by your .htaccess file.

You may want to go back to your previous configuration using curl. Then manually update your currencies in admin. Take note of the ex-rates after the manual update.

Set the cron job to run at the next full hour, wait until the script has run then check the new ex-rates against your notes. If there is a difference then rest assured that the automatic currencies updater works.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

27 Jun 2010, 7:40 AM
#218
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Currency Update (Automatic)

frank18:

That depends on your server configurations - seems the wget is disabled by your host. Could also be prevented by your .htaccess file.

You may want to go back to your previous configuration using curl. Then manually update your currencies in admin. Take note of the ex-rates after the manual update.

Set the cron job to run at the next full hour, wait until the script has run then check the new ex-rates against your notes. If there is a difference then rest assured that the automatic currencies updater works.

Hi, my host said they didn't disable it. They think our .htaccess file causing the issue but not sure about which rule. Do you have any idea?

I wouldn't want to use curl and also have to manually update the currencies in admin. The purpose of doing this is to automate it.

**The Team Behind DealByEthan.com | **Curating unique finds for a discerning community. Committed to a seamless and inspiring shopping experience. *Connect with us: *https://linktr.ee/dealbyethan

27 Jun 2010, 10:21 AM
#219
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Currency Update (Automatic)

One of my sites is updated with this cron:

/usr/local/bin/php /home/MY_ACCOUNT/public_html/currency_update.php

Note the space between php and /home

The first part /usr/local/bin/php would depend on the location of your php folder within your server's file structure. Your host should be able to tell you the path applicable to your server.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

23 Sep 2010, 12:07 PM
#220
webmc avatar

webmc

New Zenner

Join Date:
Jul 2010
Location:
Kent UK
Posts:
50
Plugin Contributions:
0

Re: Currency Update (Automatic)

kuroi:

The file outputs nothing.
The way I test it personally, is to tweak the currency rates in the database and then run it in a browser as you have and look in the database to see if they're changed.

This is what I have been doing and have noticed that - only Euro is being changed. I have INR (indian Rupee) and USD which stay the same - These are not being updated - I havent changed the default USD configuration in admin/currency. My default currency is GBP.

version. 1.3.9f