Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2006
    Posts
    34
    Plugin Contributions
    0

    Default Fatal error: Cannot redeclare class order

    On the first page of my checkout, I'm getting the following error

    Fatal error: Cannot redeclare class order in /homepages/11/d210728506/htdocs/includes/classes/order.php on line 20

    I'm also having another issue where the only checkout module I can get to work is a freeshipper module. All the other one's don't work at all. Could the two issues be related?

    part of my order.php is below, line 20 is bold

    PHP Code:
    <?php
    /**
     * File contains the order-processing class ("order")
     *
     * @package classes
     * @copyright Copyright 2003-2007 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: order.php 0000 2007-09-19 00:00:00Z kuroi $
     */
    /**
     * order class
     *
     * Handles all order-processing functions
     *
     * @package classes
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
    [
    b]class order extends base {[/b]
      var 
    $info$totals$products$customer$delivery$content_type$email_low_stock$products_ordered_attributes,
      
    $products_ordered$products_ordered_email;

      function 
    order($order_id '') {
        
    $this->info = array();
        
    $this->totals = array();
        
    $this->products = array();
        
    $this->customer = array();
        
    $this->delivery = array();

        if (
    zen_not_null($order_id)) {
          
    $this->query($order_id);
        } else {
          
    $this->cart();
        }
      }

      function 
    query($order_id) {
        global 
    $db;

        
    $order_id zen_db_prepare_input($order_id);

        
    $order_query "select customers_id, customers_name, customers_company,
                             customers_street_address, customers_suburb, customers_city,
                             customers_postcode, customers_state, customers_country,
                             customers_telephone, customers_email_address, customers_address_format_id,
                             delivery_name, delivery_company, delivery_street_address, delivery_suburb,
                             delivery_city, delivery_postcode, delivery_state, delivery_country,
                             delivery_address_format_id, billing_name, billing_company,
                             billing_street_address, billing_suburb, billing_city, billing_postcode,
                             billing_state, billing_country, billing_address_format_id,
                             payment_method, payment_module_code, shipping_method, shipping_module_code,
                             coupon_code, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value,
                             date_purchased, orders_status, last_modified, order_total, order_tax, ip_address
                            from " 
    TABLE_ORDERS "
                            where orders_id = '" 
    . (int)$order_id "'";

        
    $order $db->Execute($order_query);

        
    $totals_query "select title, text, class
                             from " 
    TABLE_ORDERS_TOTAL "
                             where orders_id = '" 
    . (int)$order_id "'
                             order by sort_order"
    ;

        
    $totals $db->Execute($totals_query);

        while (!
    $totals->EOF) {
          
    $this->totals[] = array('title' => $totals->fields['title'],
                                  
    'text' => $totals->fields['text'],
                                  
    'class' => $totals->fields['class']);
          
    $totals->MoveNext();
        }

        
    $order_total_query "select text, value
                                 from " 
    TABLE_ORDERS_TOTAL "
                                 where orders_id = '" 
    . (int)$order_id "'
                                 and class = 'ot_total'"
    ;


        
    $order_total $db->Execute($order_total_query);


        
    $shipping_method_query "select title, value
                                    from " 
    TABLE_ORDERS_TOTAL "
                                    where orders_id = '" 
    . (int)$order_id "'
                                    and class = 'ot_shipping'"
    ;


        
    $shipping_method $db->Execute($shipping_method_query);

        
    $order_status_query "select orders_status_name
                                 from " 
    TABLE_ORDERS_STATUS "
                                 where orders_status_id = '" 
    $order->fields['orders_status'] . "'
                                 and language_id = '" 
    . (int)$_SESSION['languages_id'] . "'";

        
    $order_status $db->Execute($order_status_query);

        
    $this->info = array('currency' => $order->fields['currency'],
                            
    'currency_value' => $order->fields['currency_value'],
                            
    'payment_method' => $order->fields['payment_method'],
                            
    'payment_module_code' => $order->fields['payment_module_code'],
                            
    'shipping_method' => $order->fields['shipping_method'],
                            
    'shipping_module_code' => $order->fields['shipping_module_code'],
                            
    'coupon_code' => $order->fields['coupon_code'],
                            
    'cc_type' => $order->fields['cc_type'],
                            
    'cc_owner' => $order->fields['cc_owner'],
                            
    'cc_number' => $order->fields['cc_number'],
                            
    'cc_expires' => $order->fields['cc_expires'],
                            
    'date_purchased' => $order->fields['date_purchased'],
                            
    'orders_status' => $order_status->fields['orders_status_name'],
                            
    'last_modified' => $order->fields['last_modified'],
                            
    'total' => $order->fields['order_total'],
                            
    'tax' => $order->fields['order_tax'],
                            
    'ip_address' => $order->fields['ip_address']
                            );

        
    $this->customer = array('id' => $order->fields['customers_id'],
                                
    'name' => $order->fields['customers_name'],
                                
    'company' => $order->fields['customers_company'],
                                
    'street_address' => $order->fields['customers_street_address'],
                                
    'suburb' => $order->fields['customers_suburb'],
                                
    'city' => $order->fields['customers_city'],
                                
    'postcode' => $order->fields['customers_postcode'],
                                
    'state' => $order->fields['customers_state'],
                                
    'country' => $order->fields['customers_country'],
                                
    'format_id' => $order->fields['customers_address_format_id'],
                                
    'telephone' => $order->fields['customers_telephone'],
                                
    'email_address' => $order->fields['customers_email_address']);

        
    $this->delivery = array('name' => $order->fields['delivery_name'],
                                
    'company' => $order->fields['delivery_company'],
                                
    'street_address' => $order->fields['delivery_street_address'],
                                
    'suburb' => $order->fields['delivery_suburb'],
                                
    'city' => $order->fields['delivery_city'],
                                
    'postcode' => $order->fields['delivery_postcode'],
                                
    'state' => $order->fields['delivery_state'],
                                
    'country' => $order->fields['delivery_country'],
                                
    'format_id' => $order->fields['delivery_address_format_id']);

        if (empty(
    $this->delivery['name']) && empty($this->delivery['street_address'])) {
          
    $this->delivery false;
        }

        
    $this->billing = array('name' => $order->fields['billing_name'],
                               
    'company' => $order->fields['billing_company'],
                               
    'street_address' => $order->fields['billing_street_address'],
                               
    'suburb' => $order->fields['billing_suburb'],
                               
    'city' => $order->fields['billing_city'],
                               
    'postcode' => $order->fields['billing_postcode'],
                               
    'state' => $order->fields['billing_state'],
                               
    'country' => $order->fields['billing_country'],
                               
    'format_id' => $order->fields['billing_address_format_id']);

        
    $index 0;
        
    $orders_products_query "select orders_products_id, products_id, products_name,
                                     products_model, products_price, products_tax,
                                     products_quantity, final_price,
                                     onetime_charges,
                                     products_priced_by_attribute, product_is_free, products_discount_type,
                                     products_discount_type_from
                                      from " 
    TABLE_ORDERS_PRODUCTS "
                                      where orders_id = '" 
    . (int)$order_id "'";

        
    $orders_products $db->Execute($orders_products_query);

        while (!
    $orders_products->EOF) {
          
    // convert quantity to proper decimals - account history
          
    if (QUANTITY_DECIMALS != 0) {
            
    $fix_qty $orders_products->fields['products_quantity'];
            switch (
    true) {
              case (!
    strstr($fix_qty'.')):
              
    $new_qty $fix_qty;
              break;
              default:
              
    $new_qty preg_replace('/[0]+$/'''$orders_products->fields['products_quantity']);
              break;
            }
          } else {
            
    $new_qty $orders_products->fields['products_quantity'];
          }

          
    $new_qty round($new_qtyQUANTITY_DECIMALS);

          if (
    $new_qty == (int)$new_qty) {
            
    $new_qty = (int)$new_qty;
          }

          
    $this->products[$index] = array('qty' => $new_qty,
                                          
    'id' => $orders_products->fields['products_id'],
                                          
    'name' => $orders_products->fields['products_name'],
                                          
    'model' => $orders_products->fields['products_model'],
                                          
    'tax' => $orders_products->fields['products_tax'],
                                          
    'price' => $orders_products->fields['products_price'],
                                          
    'final_price' => $orders_products->fields['final_price'],
                                          
    'onetime_charges' => $orders_products->fields['onetime_charges'],
                                          
    'products_priced_by_attribute' => $orders_products->fields['products_priced_by_attribute'],
                                          
    'product_is_free' => $orders_products->fields['product_is_free'],
                                          
    'products_discount_type' => $orders_products->fields['products_discount_type'],
                                          
    'products_discount_type_from' => $orders_products->fields['products_discount_type_from']);

          
    $subindex 0;
          
    $attributes_query "select products_options_id, products_options_values_id, products_options, products_options_values,
                                  options_values_price, price_prefix from " 
    TABLE_ORDERS_PRODUCTS_ATTRIBUTES "
                                   where orders_id = '" 
    . (int)$order_id "'
                                   and orders_products_id = '" 
    . (int)$orders_products->fields['orders_products_id'] . "'";

          
    $attributes $db->Execute($attributes_query);
          if (
    $attributes->RecordCount()) {
            while (!
    $attributes->EOF) {
              
    $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options'],
                                                                       
    'value' => $attributes->fields['products_options_values'],
                                                                       
    'prefix' => $attributes->fields['price_prefix'],
                                                                       
    'price' => $attributes->fields['options_values_price']);

              
    $subindex++;
              
    $attributes->MoveNext();
            }
          }

          
    $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';

          
    $index++;
          
    $orders_products->MoveNext();
        }
      }

      function 
    cart() {
        global 
    $db$currencies;

        
    $this->content_type $_SESSION['cart']->get_content_type();

        
    $customer_address_query "select c.customers_firstname, c.customers_lastname, c.customers_telephone,
                                        c.customers_email_address, ab.entry_company, ab.entry_street_address,
                                        ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id,
                                        z.zone_name, co.countries_id, co.countries_name,
                                        co.countries_iso_code_2, co.countries_iso_code_3,
                                        co.address_format_id, ab.entry_state
                                       from (" 
    TABLE_CUSTOMERS " c, " TABLE_ADDRESS_BOOK " ab )
                                       left join " 
    TABLE_ZONES " z on (ab.entry_zone_id = z.zone_id)
                                       left join " 
    TABLE_COUNTRIES " co on (ab.entry_country_id = co.countries_id)
                                       where c.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                       and ab.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                       and c.customers_default_address_id = ab.address_book_id"
    ;

        
    $customer_address $db->Execute($customer_address_query);

        
    $shipping_address_query "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,
                                        ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,
                                        ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,
                                        c.countries_id, c.countries_name, c.countries_iso_code_2,
                                        c.countries_iso_code_3, c.address_format_id, ab.entry_state
                                       from " 
    TABLE_ADDRESS_BOOK " ab
                                       left join " 
    TABLE_ZONES " z on (ab.entry_zone_id = z.zone_id)
                                       left join " 
    TABLE_COUNTRIES " c on (ab.entry_country_id = c.countries_id) 
                                       where ab.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                       and ab.address_book_id = '" 
    . (int)$_SESSION['sendto'] . "'";

        
    $shipping_address $db->Execute($shipping_address_query);

        
    $billing_address_query "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,
                                       ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,
                                       ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,
                                       c.countries_id, c.countries_name, c.countries_iso_code_2,
                                       c.countries_iso_code_3, c.address_format_id, ab.entry_state
                                      from " 
    TABLE_ADDRESS_BOOK " ab
                                      left join " 
    TABLE_ZONES " z on (ab.entry_zone_id = z.zone_id)
                                      left join " 
    TABLE_COUNTRIES " c on (ab.entry_country_id = c.countries_id) 
                                      where ab.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                      and ab.address_book_id = '" 
    . (int)$_SESSION['billto'] . "'";

        
    $billing_address $db->Execute($billing_address_query);
        
    //STORE_PRODUCT_TAX_BASIS

        
    switch (STORE_PRODUCT_TAX_BASIS) {
          case 
    'Shipping':

          
    $tax_address_query "select ab.entry_country_id, ab.entry_zone_id
                                  from " 
    TABLE_ADDRESS_BOOK " ab
                                  left join " 
    TABLE_ZONES " z on (ab.entry_zone_id = z.zone_id)
                                  where ab.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                  and ab.address_book_id = '" 
    . (int)($this->content_type == 'virtual' $_SESSION['billto'] : $_SESSION['sendto']) . "'";
          
    $tax_address $db->Execute($tax_address_query);
          break;
          case 
    'Billing':

          
    $tax_address_query "select ab.entry_country_id, ab.entry_zone_id
                                  from " 
    TABLE_ADDRESS_BOOK " ab
                                  left join " 
    TABLE_ZONES " z on (ab.entry_zone_id = z.zone_id)
                                  where ab.customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                                  and ab.address_book_id = '" 
    . (int)$_SESSION['billto'] . "'";
          
    $tax_address $db->Execute($tax_address_query);
          break;
          case 
    'Store':
          if (
    $billing_address->fields['entry_zone_id'] == STORE_ZONE) {

  2. #2
    Join Date
    Jul 2006
    Location
    Montreal, Canada
    Posts
    2,277
    Plugin Contributions
    0

    Default Re: Fatal error: Cannot redeclare class order

    a quote by DrByte.

    "cannot redeclare class" means that somewhere in your program code that class is being loaded twice.
    You'll have to hunt down where it's loaded and stop it from loading a second time.
    Perhaps you have duplicate or backup copies of files that are getting automatically loaded ?
    have you renamed any core file ? have backed up any file that is still on your sever ? zencart autoloads many files , if you have renamed a file that still contains .php extension ,might be loading as well causing this error.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,711
    Plugin Contributions
    6

    Default Re: Fatal error: Cannot redeclare class order

    Do a search in the Tools ... Developers Tool Kit ... in the bottom input box on:
    class order

    See what files are using it ... there can be only one, as indicated ...

    You may have a backup or a renamed file or a misplaced file in one of the auto loading directories causing this ...

    The Developers Tool Kit is your friend ... and will help you locate the problem ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  4. #4
    Join Date
    Oct 2006
    Posts
    34
    Plugin Contributions
    0

    Default Re: Fatal error: Cannot redeclare class order

    This is the result the developers toolkit gave me, as far as I can see, class order is used twice, one is in the admin. Should those two be affecting each other? the result I got is

    Code:
    Searching 48 files ... for: class order
       
    /homepages/11/d210728506/htdocs/admin/includes/classes/order.php
    Line #22 :   class order { 
        
    /homepages/11/d210728506/htdocs/includes/classes/order.php
    Line #19 : class order extends base { 
        
    /homepages/11/d210728506/htdocs/includes/classes/order_total.php
    Line #19 : class order_total extends base { 
      Match Lines found: 3
    Thanks for the help so far.

  5. #5
    Join Date
    Oct 2006
    Posts
    34
    Plugin Contributions
    0

    Default Re: Fatal error: Cannot redeclare class order

    I must also say that I had a stock by attributes plugin installed a while ago and I have the ultimate SEO urls plugin installed, I also had the one page checkout installed and I told the programmer to disable that and he did. I don't know if its remnants of those that are giving the problems.

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,711
    Plugin Contributions
    6

    Default Re: Fatal error: Cannot redeclare class order

    You show:
    Searching 48 files

    Make sure that you are using the bottom input box, you should see 900+ files being searched ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  7. #7
    Join Date
    Oct 2006
    Posts
    34
    Plugin Contributions
    0

    Default Re: Fatal error: Cannot redeclare class order

    This is what I got from the bottom input box

    Code:
    Searching 1440 files ... for: class order     
    /homepages/11/d210728506/htdocs/admin/includes/classes/order.php
    Line #22 :   class order { 
        
    /homepages/11/d210728506/htdocs/includes/classes/order.php
    Line #19 : class order extends base { 
        
    /homepages/11/d210728506/htdocs/includes/classes/order_total.php
    Line #19 : class order_total extends base { 
      Match Lines found: 3

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,711
    Plugin Contributions
    6

    Default Re: Fatal error: Cannot redeclare class order

    Well ... this rules out two files with the same class ...

    But now it is harder in that "some file or files" is calling the order twice ... and that is much harder to find ...

    One thing you might try, for an obvious double call, is try a search on:
    require(DIR_WS_CLASSES . 'order.php');

    This comes up with 11 calls from various files ...

    What version of Zen Cart?

    Do you have any add ons?

    On the off chance it is something with a template and override, what happens if you switch to Classic Template?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

 

 

Similar Threads

  1. Fatal error: Cannot redeclare class soapclient
    By srw134 in forum Addon Payment Modules
    Replies: 4
    Last Post: 1 Jun 2009, 06:54 PM
  2. Fatal error: Cannot redeclare class template_func
    By jimh3768 in forum General Questions
    Replies: 1
    Last Post: 22 Jan 2008, 05:17 AM
  3. Fatal error: Cannot redeclare class moneyorder
    By bekinky in forum Customization from the Admin
    Replies: 2
    Last Post: 10 Mar 2007, 07:51 PM
  4. Fatal error: Cannot redeclare class base:order
    By DogTags in forum Installing on a Linux/Unix Server
    Replies: 10
    Last Post: 13 Jan 2007, 02:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •