Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

kep@

PHP Fatal error: Cannot declare class currencies_mod, because the name is already in use in

Recommended Posts

When I replace it I still get the same error

PHP Fatal error:  Cannot declare class currencies_mod, because the name is already in use in /home/public_html/includes/modules/bootstrap/bt_price_display.php on line 63

HTTP ERROR 500

 

Edited by kep@

Share this post


Link to post
Share on other sites

Check the first few lines of your includes/classes/currencies.php

  class currencies {
    var $currencies;

// class constructor
    function __construct() {

 

Share this post


Link to post
Share on other sites

I already have that

// class constructor
    function __construct() {
      $this->currencies = array();
      $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from currencies");
      while ($currencies = tep_db_fetch_array($currencies_query)) {
        $this->currencies[$currencies['code']] = array('title' => $currencies['title'],
                                                       'symbol_left' => $currencies['symbol_left'],
                                                       'symbol_right' => $currencies['symbol_right'],
                                                       'decimal_point' => $currencies['decimal_point'],
                                                       'thousands_point' => $currencies['thousands_point'],
                                                       'decimal_places' => (int)$currencies['decimal_places'],
                                                       'value' => $currencies['value']);
      }
    }
 

 

Share this post


Link to post
Share on other sites

@kep@In the bt_price file try changing this line

  if (class_exists('currencies')) {

to

  if (class_exists('currencies') && ! class_exists('currencies_mod')) {

That may get rid of the error but the code may fail if that class exists for some other purpose.


Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Share this post


Link to post
Share on other sites
5 hours ago, Jack_mcs said:

@kep@In the bt_price file try changing this line


  if (class_exists('currencies')) {

 to


  if (class_exists('currencies') && ! class_exists('currencies_mod')) {

 That may get rid of the error but the code may fail if that class exists for some other purpose.

After this change, it shows the prices that should be available only to registered users.

Share this post


Link to post
Share on other sites
9 hours ago, kep@ said:

Problem is that st_tax_below_price.php also calls class mod_currencies

You can make the same change in that file.

 

9 hours ago, kep@ said:

After this change, it shows the prices that should be available only to registered users.

I don't know if this means it is working or not but, if not, it is probably because the existing currencies_mod class doesn't have the needed function. You can rename all occurrences of currencies_mod in those two files to something unique and that should allow it to work as designed.


Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Share this post


Link to post
Share on other sites

When I change the class name from currencies_mod to for example mod_currencies then I don't have a problem with error 500 but it doesn't show me the tax.
And what this module should do

Share this post


Link to post
Share on other sites

If you haven't done so, be sure to also change the line with "new currencies_mod" to the changed name.  Other than that I can only suggest you contact the person that wrote the code. Since it isn't an addon I have installed I can't check why it is failing.


Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Share this post


Link to post
Share on other sites
On 2/23/2022 at 7:03 AM, kep@ said:

When I change the class name from currencies_mod to for example mod_currencies then I don't have a problem with error 500 but it doesn't show me the tax.
And what this module should do

Geez, it is a wild wild west. The tax below price module used the same technique and class name to extend the currencies class to display tax. Ya, pick either module, do a search and replace of all the "currencies_mod" to "currencies_mod_copy" should fix ur problem. I recall these module files were self-contained within the module's directory. Do a uninstall and install of that module afterward to activate the change. I suggest to use something like Sublime text editor to do the search and replace...unless PHPStorm is available to you...good luck!

Yeah, you can't redeclare a class name.

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

×