Jump to content
Latest News: (loading..)
rebelsheep

Newbie Frozen install Update Currency Problem

Recommended Posts

I've just installed OSCommerce v2.3.4.1 CE (Frozen).

In admin I added a currency (GBP) and set it to default.

When I chose Update Exchange Rate I get errors:

Warning: include_once(includes/languages/english/modules/currencies/MODULE_ADMIN_CURRENCIES_INSTALLED): failed to open stream: No such file or directory in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 71

Warning: include_once(): Failed opening 'includes/languages/english/modules/currencies/MODULE_ADMIN_CURRENCIES_INSTALLED' for inclusion (include_path='.:/usr/lib/php7.1') in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 71

Warning: include_once(includes/modules/currencies/MODULE_ADMIN_CURRENCIES_INSTALLED): failed to open stream: No such file or directory in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 72

Warning: include_once(): Failed opening 'includes/modules/currencies/MODULE_ADMIN_CURRENCIES_INSTALLED' for inclusion (include_path='.:/usr/lib/php7.1') in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 72

Warning: call_user_func() expects parameter 1 to be a valid callback, class 'MODULE_ADMIN_CURRENCIES_INSTALLED' not found in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 76

Warning: Cannot modify header information - headers already sent by (output started at /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php:71) in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/includes/functions/general.php on line 38

 

...under includes/languages/english/modules/ there is no 'currencies folder.

Q1: Do I need to install a currencies / exchange rate under includes/languages/english/modules/?

Q2: Where do I look for modules compatible with Frozen?

Q3: Even though I installed an extra currency (there are 3 showing in admin Euro, Dollar and GBP) only dollars shows in the Front End and I can't see an icon / button to choose / switch between different currencies. ??

Q4: I installed OSCommerce to root, not in a catalog directory, is this a problem, will it cause problems further down the line??

Front end at:

http://notebookrepair.rocks/index.php

Thank you.

 

Share this post


Link to post
Share on other sites

In your Admin go:

Modules > Update Currency

Install one.

Then update your currencies.

Personally, I find "currencylayer" better than "fixer"...but you can give whichever one you like a go.

Edited by burt

This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

Thanks burt, that's great.

I've signed up to currencylayer for their free subscription and now have an API key.

I installed currencylayer under Modules > Update Currency with the API key provided.

...so a step forward, however..

Now if I choose 'Update Exchange Rate' under Currencies, there is no error but a message at the top of the screen 'Subscription plan does not support the requested API Function'.

Q1: It is ok if I have to upgrade the plan with currencylayer so that 'Upate Exchange Rate' works, that is fine - just a bit suprised that the free version doesn't at least allow a manual update of rate, otherwise what else is it for?? Or have I missed something?

Q2: Still no option to change currencies in the front end, and still in dollars (even though GBP is set as default in admin)??

Share this post


Link to post
Share on other sites

I think I just used CurrencyLayer without a problem.  I'll check what subscription I'm on, just a moment.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

IIRC currencylayer "free" now only supports USD as the source currency.  And it looks like Fixer has been incorporated into CurrencyLayer (or vice versa).
The last time I used the subscription service, it all worked as intended but that was on a developer account, so I cannot say if it would work "today".

It looks like I'll have to build another Currency Converter 😕

 


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

Please try:

https://github.com/gburton/Responsive-osCommerce/commit/84bb3c43da53b60040521dcef47195db6f8df34a

and report back your findings.  Thanks

Important note: 
only one currency converter should be installed, so turn off any others.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

So I have downloaded the above files (copied and pasted the contents in to editor and then saved them with same names - c_currencylayer.php, c_exchangeratesapi.php, c_fixer.php). But not sure if I am getting the whole file contents -eg. if I click on c_exchangeratesapi.php I only see 26 lines of code ending with // just english, performed directly in the module. It opens with <?php, but I can't see the closing ?> as I would expect. Are these just snippets of the files? Anyway uploaded them to /admin/includes/languages/english/modules/currencies and now all be broken in both in Modules > Update Currencies and Localization > Currencies > Update Exchange Rate.

Update Exchange Rate now gives:

Warning: include_once(includes/languages/english/modules/currencies/c_currencylayer.php;c_fixer.php): failed to open stream: No such file or directory in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 71

Warning: include_once(): Failed opening 'includes/languages/english/modules/currencies/c_currencylayer.php;c_fixer.php' for inclusion (include_path='.:/usr/lib/php7.1') in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 71

Warning: include_once(includes/modules/currencies/c_currencylayer.php;c_fixer.php): failed to open stream: No such file or directory in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 72

Warning: include_once(): Failed opening 'includes/modules/currencies/c_currencylayer.php;c_fixer.php' for inclusion (include_path='.:/usr/lib/php7.1') in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 72

Warning: call_user_func() expects parameter 1 to be a valid callback, class 'c_currencylayer.php;c_fixer' not found in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php on line 76

Warning: Cannot modify header information - headers already sent by (output started at /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/currencies.php:71) in /homepages/21/d219854835/htdocs/domains/notebookrepair.rocks/admin/includes/functions/general.php on line 38

 

I'm not sure if I am using GitHub correctly - surely I'm not seeing all the code for the three files (as previously mentioned).

Thank you for any help or advice.

 

Share this post


Link to post
Share on other sites

For c_exchangeratesapi.php all I see is:

<?php
/*
  Copyright (c) 2019, G Burton
  All rights reserved.
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
define('MODULE_ADMIN_CURRENCIES_EXCHANGERATESAPI_TITLE', 'Exchange Rates API');
define('MODULE_ADMIN_CURRENCIES_EXCHANGERATESAPI_DESCRIPTION', 'Update Currencies via the Exchange Rates API.<div class=\'secWarning\'>Uses https://exchangeratesapi.io/ as a data source.</div>');
// good
define('MODULE_ADMIN_CURRENCIES_EXCHANGERATESAPI_CURRENCIES_UPDATED', 'The exchange rate for %s was updated successfully via the Exchange Rates API.');
// bad
// no multi-lang capability for bad messages
// just english, performed directly in the module

 

...which surely is only part of a file??

Share this post


Link to post
Share on other sites

Make sure you have the language file in the language dir and the module file in the module dir.

Files should have no ending ?>

And you can have just one currency module installed at any one time...

This experimental code might not be suitable for someone brand new to osC (sorry, I hate that word "newbie") - can someone else please try it as well ? 
It seems to work well from my end.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

Hi, thank you, that now works.

I think I hadn't installed BOTH files - so now that I have, I can see Exchange Rates API in the choice of Currency Modules.

Installed Exchange Rates API and now in Localization > Currencies, if I click 'Update Exchange Rates'', the exchange rates are now updated successfully. Great!

Observation... if dollars are set as the default currency, 'Currency Layer' DOES work when you choose 'Update Exchange Rate' on the basic subscription - it doesn't work with other currencies as the default with the basic subscription.

Q: Not sure how to the default currency 'changes' in the front end?? A fresh install of OSCommerce (frozen) dollars are the default in front end and in admin. When I set the default to, say £ GBP in admin, I didn't change in front.... erm except after installing your files, and I came to test the site (front end) several days later, it has switched to £s. But now testing the site if I set the default back to dollars in Admin, it stays as £s in front end. Confused. Rather than just setting the default in Admin, do I have to do something else for the correct currency ($ or £ eg.) to show in the front end shop??

Thank you.

Edited by rebelsheep

Share this post


Link to post
Share on other sites
On 2/7/2019 at 8:07 PM, burt said:

IIRC currencylayer "free" now only supports USD as the source currency.  And it looks like Fixer has been incorporated into CurrencyLayer (or vice versa).
The last time I used the subscription service, it all worked as intended but that was on a developer account, so I cannot say if it would work "today".

It looks like I'll have to build another Currency Converter 😕

Fixer still works on live store with EUR base currency. Conversion to US$, GBP and CHF works flawless.

Share this post


Link to post
Share on other sites
16 minutes ago, raiwa said:

Fixer still works on live store with EUR base currency. Conversion to US$, GBP and CHF works flawless.

It didn't seem to want to work for me.  Could you try the new converter module I made and report back please...TY.

https://github.com/gburton/Responsive-osCommerce/pull/704

If good, I'll drop it into Core and it's then another option to choose from.

1 hour ago, rebelsheep said:

Installed Exchange Rates API and now in Localization > Currencies, if I click 'Update Exchange Rates'', the exchange rates are now updated successfully. Great!

TY.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
1 hour ago, burt said:

It didn't seem to want to work for me.  Could you try the new converter module I made and report back please...TY.

https://github.com/gburton/Responsive-osCommerce/pull/704

If good, I'll drop it into Core and it's then another option to choose from.

TY.

Tested under Windows local XAMPP PHP 7.29:

New module works fine.

I checked fixer on latest EDGE currency module update and it doesn't work neither.

Error: Error The current subscription plan does not support this API endpoint, you may need to upgrade your plan.

Meanwhile on the live store which is an older EDGE from 2017 it works fine.

The coding used there is the following in admin/includes/functions/ localization.php:

  function quote_fixer_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;

    $ch = curl_init('http://data.fixer.io/api/latest?access_key=MY_HARDCODED_ACCESS_KEY_HERE&base=' . $from . '&symbols=' . $to);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch); 
    curl_close($ch); 

    $currencies = json_decode($data, true);
    
    if (isset($currencies['rates'][$to])) {
      return $currencies['rates'][$to];
    } else {
      return false;
    }
  }

and in admin/currencies:

      case 'update':
        $server_used = CURRENCY_SERVER_PRIMARY;

        $currency_query = tep_db_query("select currencies_id, code, title from " . TABLE_CURRENCIES);
        while ($currency = tep_db_fetch_array($currency_query)) {
          $quote_function = 'quote_' . CURRENCY_SERVER_PRIMARY . '_currency';
          $rate = $quote_function($currency['code']);

          if (empty($rate) && (tep_not_null(CURRENCY_SERVER_BACKUP))) {
            $messageStack->add_session(sprintf(WARNING_PRIMARY_SERVER_FAILED, CURRENCY_SERVER_PRIMARY, $currency['title'], $currency['code']), 'warning');

            $quote_function = 'quote_' . CURRENCY_SERVER_BACKUP . '_currency';
            $rate = $quote_function($currency['code']);

            $server_used = CURRENCY_SERVER_BACKUP;
          }

          if (tep_not_null($rate)) {
            tep_db_query("update " . TABLE_CURRENCIES . " set value = '" . $rate . "', last_updated = now() where currencies_id = '" . (int)$currency['currencies_id'] . "'");

            $messageStack->add_session(sprintf(TEXT_INFO_CURRENCY_UPDATED, $currency['title'], $currency['code'], $server_used), 'success');
          } else {
            $messageStack->add_session(sprintf(ERROR_CURRENCY_INVALID, $currency['title'], $currency['code'], $server_used), 'error');
          }
        }

        tep_redirect(tep_href_link('currencies.php', 'page=' . $_GET['page'] . '&cID=' . $_GET['cID']));
        break;

and in admin/application_top.php:

  define('CURRENCY_SERVER_PRIMARY', 'fixer');
  define('CURRENCY_SERVER_BACKUP', '');

EDIT: Same fixer API Key used in both cases.

Edited by raiwa

Share this post


Link to post
Share on other sites

TY.  Have done investigation and found following;


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×