Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal error: Cannot redeclare class order_total


doremient

Recommended Posts

I get:

Fatal error: Cannot redeclare class order_total in /home/recover5/public_html/store1/includes/classes/order_total.php on line 13

 

here is the code for that page. Someone ina previous forum mentioned something about a duplicate require calss field but I couldn't find it.

 

I have read through the forums to find this issue come up numerous times but no clear solution for it.

I am using paypal IPN as my payment method.

 

I would appreciate any help you can provide on this!

 

<?php
/*
$Id: order_total.php 1739 2007-12-20 00:52:16Z hpdl $

osCommerce, Open Source E-Commerce Solutions
[url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

Copyright © 2003 osCommerce

Released under the GNU General Public License
*/

class order_total {
var $modules;

// class constructor
function order_total() {
global $language;

if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
$this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);

reset($this->modules);
while (list(, $value) = each($this->modules)) {
include(DIR_WS_LANGUAGES . $language . '/modules/order_total/' . $value);
include(DIR_WS_MODULES . 'order_total/' . $value);

$class = substr($value, 0, strrpos($value, '.'));
$GLOBALS[$class] = new $class;
}
}
}

function process() {
$order_total_array = array();
if (is_array($this->modules)) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled) {
$GLOBALS[$class]->output = array();
$GLOBALS[$class]->process();

for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
$order_total_array[] = array('code' => $GLOBALS[$class]->code,
'title' => $GLOBALS[$class]->output[$i]['title'],
'text' => $GLOBALS[$class]->output[$i]['text'],
'value' => $GLOBALS[$class]->output[$i]['value'],
'sort_order' => $GLOBALS[$class]->sort_order);
}
}
}
}
}

return $order_total_array;
}

function output() {
$output_string = '';
if (is_array($this->modules)) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled) {
$size = sizeof($GLOBALS[$class]->output);
for ($i=0; $i<$size; $i++) {
$output_string .= ' <tr>' . "\n" .
' <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['title'] . '</td>' . "\n" .
' <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['text'] . '</td>' . "\n" .
' </tr>';
}
}
}
}

return $output_string;
}
// CCGV - START ADDITION
//
// This function is called in checkout payment after display of payment methods. It actually calls
// two credit class functions.
//
// use_credit_amount() is normally a checkbox used to decide whether the credit amount should be applied to reduce
// the order total. Whether this is a Gift Voucher, or discount coupon or reward points etc.
//
// The second function called is credit_selection(). This in the credit classes already made is usually a redeem box.
// for entering a Gift Voucher number. Note credit classes can decide whether this part is displayed depending on
// E.g. a setting in the admin section.
//
function credit_selection() {
$selection_string = '';
$close_string = '';
$credit_class_string = '';
if (MODULE_ORDER_TOTAL_INSTALLED) {
$header_string = '<tr>' . "\n";
$header_string .= ' <td><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
$output1_string .= ' <tr>' . "\n";
$header_string .= ' <td class="main"><b>' . TABLE_HEADING_CREDIT . '</b></td>' . "\n";
$header_string .= ' </tr>' . "\n";
$header_string .= ' </table></td>' . "\n";
$header_string .= ' </tr>' . "\n";
$header_string .= '<tr>' . "\n";
$header_string .= ' <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">' . "\n";
$header_string .= ' <tr class="infoBoxContents"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">' ."\n";
$header_string .= ' <tr><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n";
$header_string .= ' <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
$close_string = ' </table></td>';
$close_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
$close_string .= '</tr></table></td></tr></table></td>';
$close_string .= '<tr><td width="100%">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
reset($this->modules);
$output_string = '';
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) {
$use_credit_string = $GLOBALS[$class]->use_credit_amount();
if ($selection_string =='') $selection_string = $GLOBALS[$class]->credit_selection();
if ( ($use_credit_string !='' ) || ($selection_string != '') ) {
$output_string .= '<tr colspan="4"><td colspan="4" width="100%">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
$output_string = ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" >' . "\n" .
' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' .
' <td class="main"><b>' . $GLOBALS[$class]->header . '</b></td>' . $use_credit_string;
$output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
$output_string .= ' </tr>' . "\n";
$output_string .= $selection_string;
}

}
}
if ($output_string != '') {
$output_string = $header_string . $output_string;
$output_string .= $close_string;
}
}
return $output_string;
}


// if ($selection_string !='') {
// $output_string .= '</td>' . "\n";
// $output_string .= $selection_string;
// }




// update_credit_account is called in checkout process on a per product basis. It's purpose
// is to decide whether each product in the cart should add something to a credit account.
// e.g. for the Gift Voucher it checks whether the product is a Gift voucher and then adds the amount
// to the Gift Voucher account.
// Another use would be to check if the product would give reward points and add these to the points/reward account.
//
function update_credit_account($i) {
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
$GLOBALS[$class]->update_credit_account($i);
}
}
}
}
// This function is called in checkout confirmation.
// It's main use is for credit classes that use the credit_selection() method. This is usually for
// entering redeem codes(Gift Vouchers/Discount Coupons). This function is used to validate these codes.
// If they are valid then the necessary actions are taken, if not valid we are returned to checkout payment
// with an error
//
function collect_posts() {
global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
$post_var = 'c' . $GLOBALS[$class]->code;
if ($HTTP_POST_VARS[$post_var]) {
if (!tep_session_is_registered($post_var)) tep_session_register($post_var);
// ############ Added CCGV Contribution ##########
$post_var = $HTTP_POST_VARS[$post_var];
// ############ End Added CCGV Contribution ##########
}
// #################### End Added CGV JONYO ######################
$GLOBALS[$class]->collect_posts();
}

}
}
}
// pre_confirmation_check is called on checkout confirmation. It's function is to decide whether the
// credits available are greater than the order total. If they are then a variable (credit_covers) is set to
// true. This is used to bypass the payment method. In other words if the Gift Voucher is more than the order
// total, we don't want to go to paypal etc.
//
function pre_confirmation_check() {
global $payment, $order, $credit_covers;
if (MODULE_ORDER_TOTAL_INSTALLED) {

$total_deductions = 0;
reset($this->modules);
$order_total = $order->info['total'];
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
$order_total = $this->get_order_total_main($class,$order_total);
if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
$total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
$order_total = $order_total - $GLOBALS[$class]->pre_confirmation_check($order_total);
}
}
if ($order->info['total'] - $total_deductions <= 0 ) {
if(!tep_session_is_registered('credit_covers')) tep_session_register('credit_covers');
$credit_covers = true;
}
else{ // belts and suspenders to get rid of credit_covers variable if it gets set once and they put something else in the cart
if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers'); 
}
}
}
// this function is called in checkout process. it tests whether a decision was made at checkout payment to use
// the credit amount be applied aginst the order. If so some action is taken. E.g. for a Gift voucher the account
// is reduced the order total amount.
//
function apply_credit() {
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
$GLOBALS[$class]->apply_credit();
}
}
}
}
// Called in checkout process to clear session variables created by each credit class module.
//
function clear_posts() {
global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
$post_var = 'c' . $GLOBALS[$class]->code;
if (tep_session_is_registered($post_var)) tep_session_unregister($post_var);
}
}
}
}
// Called at various times. This function calulates the total value of the order that the
// credit will be appled aginst. This varies depending on whether the credit class applies
// to shipping & tax
//
function get_order_total_main($class, $order_total) {
global $credit, $order;
// if ($GLOBALS[$class]->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
// if ($GLOBALS[$class]->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
return $order_total;
}
// CCGV - END ADDITION
}
?>

Link to comment
Share on other sites

u have included the same file twice, or similar, check your code, its not a common issue, its a bug u have created!!

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

When was it working properly?

What has changed?

When do you get the error? - and thus narrow down to the file that may have reference to this file

Open it in notepad / any word editor and verify if order_total.php has been included or required

If yes - go ahead and comment out the line to see if you can continue to work without the error.

 

As spooks has said correctly - it is an error to indicate that you are trying to include something that is already occupying the lone seat it should occupy and thus no more place for second instance to get seated and thus the error ..

 

HTH

Best Regards,
Gaurav

Link to comment
Share on other sites

When was it working properly?

What has changed?

When do you get the error? - and thus narrow down to the file that may have reference to this file

Open it in notepad / any word editor and verify if order_total.php has been included or required

If yes - go ahead and comment out the line to see if you can continue to work without the error.

 

As spooks has said correctly - it is an error to indicate that you are trying to include something that is already occupying the lone seat it should occupy and thus no more place for second instance to get seated and thus the error ..

 

HTH

 

Thanks I have looked in a a few files and I don't see it doubled.

It happens when I use the paypal IPN and after completing the transaction on return to checkout process.

However, it works fine when I use paypal payments standard.

 

I am not sure If I should look at all the payment modules or the checkout modules. I guess I will just have to look at all of them.

 

You have said this isn't common however I have seen quite a few posts about this issue, just not really and ideas except for the doubling.

Link to comment
Share on other sites

One of the tools I often use is called Agent Ransack (google it..)

 

If you have a backup copy of your server files on your desktop, simply search for the string using agent ransack - and it would help to speed up the process and show where all the particular file has been referenced. You may use other tools too - if you have any !!!

 

Cheers

Best Regards,
Gaurav

Link to comment
Share on other sites

I'm getting a similar problem!

 

Except I'm trying to use an original OSC shipping module - item.php!!!

 

This brings up the following error on the shipping modules screen:

 

"Fatal error: Cannot redeclare class item in \catalog\includes\modules\shipping\item.php on line 13".

 

 

<?php
/*
 $Id: item.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 class item {
   var $code, $title, $description, $icon, $enabled;

// class constructor
   function item() {
     global $order;

     $this->code = 'item';
     $this->title = MODULE_SHIPPING_ITEM_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_ITEM_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_ITEM_SORT_ORDER;
     $this->icon = '';
     $this->tax_class = MODULE_SHIPPING_ITEM_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_ZONE > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEM_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['zone_id'] < 1) {
           $check_flag = true;
           break;
         } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
           $check_flag = true;
           break;
         }
       }

       if ($check_flag == false) {
         $this->enabled = false;
       }
     }
   }

// class methods
   function quote($method = '') {
     global $order, $total_count;

     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
                                                    'cost' => (MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING)));

     if ($this->tax_class > 0) {
       $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }

     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

     return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEM_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Item Shipping', 'MODULE_SHIPPING_ITEM_STATUS', 'True', 'Do you want to offer per item rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_ITEM_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_ITEM_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ITEM_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_ITEM_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ITEM_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_ITEM_STATUS', 'MODULE_SHIPPING_ITEM_COST', 'MODULE_SHIPPING_ITEM_HANDLING', 'MODULE_SHIPPING_ITEM_TAX_CLASS', 'MODULE_SHIPPING_ITEM_ZONE', 'MODULE_SHIPPING_ITEM_SORT_ORDER');
   }
 }
?>

 

Any help would be great!

 

Thanks.

Link to comment
Share on other sites

Where does the error occur? During checkout?

 

I get my error after the payment process and it is the redirect from paypal back to my store.

However this only happens when I use the paypal ipn and not web payments standard

Link to comment
Share on other sites

Replace

require(DIR_WS_CLASSES . 'order_total.php');

with

 require_once(DIR_WS_CLASSES . 'order_total.php');

 

in checkout_confirmation.php & checkout_process.php

 

Also,

were you able to run search and find out if where all does

 require(DIR_WS_CLASSES . 'order_total.php');

appear in your codebase?

 

* You may also change in one file at a time to narrow down further. Again, if this class is being referenced at any other place, making these changes will NOT change the outcome - so you do need to find out where all is it declared as required.

 

Thx

Best Regards,
Gaurav

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...