KPGroup Posted February 20, 2007 Share Posted February 20, 2007 Hello, I need 2 copies of the UPSXML shipping module with different settings for 2 different zones (one for Canada and one for USA). I copied renamed copies of the following files to their proper directories: catalog/includes/modules/shipping/upsxml.php to upsxmlusa.php catalog/includes/languages/english/modules/shipping/upsxml.php to upsxmlusa.php And I didn't change the following files: catalog/admin/includes/classes/xmldocument.php catalog/includes/classes/xmldocument.php I get the following error: Fatal error: Cannot redeclare class xmldocument in /home/mydomain/public_html/admin/includes/classes/xmldocument.php on line 19 Does anybody know how t go around this? the xmldocument class seems to be redeclared. What should I do? Thanks in advance :thumbsup: Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2007 Share Posted February 20, 2007 When you are looking at the shipping modules it is loading your USA one and the Canada one so it is calling the xmldocument from each file. You will need to rename the class also and make the changes in the other files. Why do you need one for each country??? It should work for shipping anywhere in the world. Link to comment Share on other sites More sharing options...
KPGroup Posted February 20, 2007 Author Share Posted February 20, 2007 When you are looking at the shipping modules it is loading your USA one and the Canada one so it is calling the xmldocument from each file. You will need to rename the class also and make the changes in the other files. Why do you need one for each country??? It should work for shipping anywhere in the world. Thank you for the quick reply. I will try renaming the class, making the changes and see how it goes. I need 2 copies of the module because I need to apply a handling fee for certain zones. Is there a simpler way to do this? Thanks again ;) Link to comment Share on other sites More sharing options...
KPGroup Posted February 21, 2007 Author Share Posted February 21, 2007 Thank you for the quick reply. I will try renaming the class, making the changes and see how it goes. I need 2 copies of the module because I need to apply a handling fee for certain zones. Is there a simpler way to do this? Thanks again ;) I renamed the class and I started having errors for other classes being declared twice. I renamed them too. Now I have a shipping module with no name in Admin. If I click on it I get the info for the other UPSXML module already there. If I make changes to this module, they affect the other. I think I also need to rename all the fields in the database that a created for this new module. If anybody has tips for doing this, please let me know. Thanks. Link to comment Share on other sites More sharing options...
KPGroup Posted February 22, 2007 Author Share Posted February 22, 2007 Can anobody help me with this? I renamed the classes. Then I got errors for a duplicate function. I renamed it too. Now I have a shipping module in admin with no name (just blank). I managed to install it. I set it up. Everything seemed fine (other than the blank name). When I go to the store side, the shipping module is not there. Am I forgetting something? I am sure it is not too hard but I just can't figure it out. Link to comment Share on other sites More sharing options...
KPGroup Posted February 22, 2007 Author Share Posted February 22, 2007 anybody? I really can't figure it out. I am sure someone tried that before. Link to comment Share on other sites More sharing options...
shooter-boy Posted February 23, 2007 Share Posted February 23, 2007 It has no name, because you also need to also create the language file to match the new class. The easiest way to do this is to copy the one for the module you have duplicated and amend it as required (it will have the same filename as the shipping module, but it will be in the languages directory). Alternatively, you could just write a small bit of custom code to pull the customer's country from their account info and apply the fee based on that result. It would be MUCH cleaner. Rob Rob Bell - Inspired Graphix Customising osCommerce in Australia, and the world! View my profile for web and email links. I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture. However viewing my profile may provide links to my website or something like that which you may find useful. Link to comment Share on other sites More sharing options...
djmonkey1 Posted February 23, 2007 Share Posted February 23, 2007 I have done this, and in fact I have 3 copies of the UPSXML file; upsxml.php, upsxml2.php, and upsxml3.php. To make the first copy, upsxml2.php, within the original file I renamed every instance of upsxml to upsxml2 and every instance of UPSXML to UPSXML2. This may not be necessary in every case but it helps to avoid confusion (and helps if you want to do things like error logging as each file would create a separate error log). Also, as you have found, there are a few other classes that need to be renamed with 2, 3, etc. I also changed every instance of xmldocument to xmldocument2 and created a clone copy of the xmldocument with the appropriate name, xmldocument2.php, in both admin and catalog folders (important). As shooter-boy mentioned you also need a new language file for each new file. This is all I can think of right now, but it should get you close and at least you know someone else has done it. :) Do, or do not. There is no try. Order Editor 5.0.6 "Ultra Violet" is now available! For support or to post comments, suggestions, etc, please visit the Order Editor support thread. Link to comment Share on other sites More sharing options...
shooter-boy Posted February 23, 2007 Share Posted February 23, 2007 Make sure you update the link to the language file within the shipping class file too. Rob Rob Bell - Inspired Graphix Customising osCommerce in Australia, and the world! View my profile for web and email links. I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture. However viewing my profile may provide links to my website or something like that which you may find useful. Link to comment Share on other sites More sharing options...
KPGroup Posted February 23, 2007 Author Share Posted February 23, 2007 What is the language file for the new class? I have made a copy of the upsxml.php language file (named upsxml1.php). I am not sure I understand where I should copy it. I have it in the same directory as the original upsxml language file. The alternative way sounds good but I don't have the skills to do it. It has no name, because you also need to also create the language file to match the new class.The easiest way to do this is to copy the one for the module you have duplicated and amend it as required (it will have the same filename as the shipping module, but it will be in the languages directory). Alternatively, you could just write a small bit of custom code to pull the customer's country from their account info and apply the fee based on that result. It would be MUCH cleaner. Rob Link to comment Share on other sites More sharing options...
KPGroup Posted February 23, 2007 Author Share Posted February 23, 2007 That is pretty much what I did. I guess I am close :thumbsup: The only thing I am confused about is the language files. I have only one: catalog/includes/languages/english/modules/shipping/upsxml.php which I copied and renamed to upsxml1.php. Do I need other language files? Thanks in advance. I have done this, and in fact I have 3 copies of the UPSXML file; upsxml.php, upsxml2.php, and upsxml3.php. To make the first copy, upsxml2.php, within the original file I renamed every instance of upsxml to upsxml2 and every instance of UPSXML to UPSXML2. This may not be necessary in every case but it helps to avoid confusion (and helps if you want to do things like error logging as each file would create a separate error log). Also, as you have found, there are a few other classes that need to be renamed with 2, 3, etc. I also changed every instance of xmldocument to xmldocument2 and created a clone copy of the xmldocument with the appropriate name, xmldocument2.php, in both admin and catalog folders (important). As shooter-boy mentioned you also need a new language file for each new file. This is all I can think of right now, but it should get you close and at least you know someone else has done it. :) Link to comment Share on other sites More sharing options...
KPGroup Posted February 23, 2007 Author Share Posted February 23, 2007 Make sure you update the link to the language file within the shipping class file too. Rob Where do I have to do this. I have checked the shipping class file. Everything seems fine. <?php /* $Id: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shipping { var $modules; // class constructor function shipping($module = '') { global $language, $PHP_SELF; if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) { $this->modules = explode(';', MODULE_SHIPPING_INSTALLED); $include_modules = array(); if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) { $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); } else { reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); $include_modules[] = array('class' => $class, 'file' => $value); } } for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) { include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $include_modules[$i]['file']); include(DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file']); $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']; } } } function quote($method = '', $module = '') { global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes; $quotes_array = array(); if (is_array($this->modules)) { $shipping_quoted = ''; $shipping_num_boxes = 1; $shipping_weight = $total_weight; if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) { $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT; } else { $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100); } if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT); $shipping_weight = $shipping_weight/$shipping_num_boxes; } $include_quotes = array(); reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if (tep_not_null($module)) { if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) { $include_quotes[] = $class; } } elseif ($GLOBALS[$class]->enabled) { $include_quotes[] = $class; } } $size = sizeof($include_quotes); for ($i=0; $i<$size; $i++) { $quotes = $GLOBALS[$include_quotes[$i]]->quote($method); if (is_array($quotes)) $quotes_array[] = $quotes; } } return $quotes_array; } function cheapest() { if (is_array($this->modules)) { $rates = array(); reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $quotes = $GLOBALS[$class]->quotes; for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) { if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) { $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'], 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')', 'cost' => $quotes['methods'][$i]['cost']); } } } } $cheapest = false; for ($i=0, $n=sizeof($rates); $i<$n; $i++) { if (is_array($cheapest)) { if ($rates[$i]['cost'] < $cheapest['cost']) { $cheapest = $rates[$i]; } } else { $cheapest = $rates[$i]; } } return $cheapest; } } } ?> Link to comment Share on other sites More sharing options...
djmonkey1 Posted February 23, 2007 Share Posted February 23, 2007 That is pretty much what I did. I guess I am close :thumbsup: You changed every single instance of upsxml to upsxml1, and every single instance of UPSXML to UPSXML1 in both the shipping module itself and the new language file (sorry I forgot to mention that before)? Also, you have to be careful, because if you installed the new module without completing this step first your configuration table is going to be clogged with a whole mess of duplicate entries that will cause problems for your original UPS XML module. The only thing I am confused about is the language files. I have only one: catalog/includes/languages/english/modules/shipping/upsxml.php which I copied and renamed to upsxml1.php. Do I need other language files? You should now have two language files, upsxml.php and upsxml1.php. Do, or do not. There is no try. Order Editor 5.0.6 "Ultra Violet" is now available! For support or to post comments, suggestions, etc, please visit the Order Editor support thread. Link to comment Share on other sites More sharing options...
KPGroup Posted February 23, 2007 Author Share Posted February 23, 2007 You changed every single instance of upsxml to upsxml1, and every single instance of UPSXML to UPSXML1 in both the shipping module itself and the new language file (sorry I forgot to mention that before)? Also, you have to be careful, because if you installed the new module without completing this step first your configuration table is going to be clogged with a whole mess of duplicate entries that will cause problems for your original UPS XML module.You should now have two language files, upsxml.php and upsxml1.php. I will recheck everything but in theory this is what I was trying to do. I do have 2 language files, the original one and the copy. So I should be all good. I'll check again. Thanks for your time :thumbsup: Link to comment Share on other sites More sharing options...
KPGroup Posted February 28, 2007 Author Share Posted February 28, 2007 I restarted from scratch and was very careful not to forget anything. I now have a fully functionning second copy of the UPSXML shipping module. Thank you guys for the help. It is much appreciated. :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.