Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Dec 2004
    Location
    Redcliffe QLD, Australia
    Posts
    193
    Plugin Contributions
    1

    Help converting OSC SQL code to Zencart

    There have been a number of requests to migrate the Australian FASTWAY Shipping module from OSC MS2 to Zencart, and this is what I am attempting to do. Unfortunately I am stuck on one section.

    If someone could help convert the following OSC MS2 MYSQL code to Zencart compliant MYSQL code, I'm certain the module will work.

    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = tep_db_query($sql); 
    $rec = tep_db_fetch_array($qResult);
    Thanks

  2. #2
    Join Date
    Jul 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Help converting OSC SQL code to Zencart

    Quote Originally Posted by ozetrade View Post
    There have been a number of requests to migrate the Australian FASTWAY Shipping module from OSC MS2 to Zencart, and this is what I am attempting to do. Unfortunately I am stuck on one section.

    If someone could help convert the following OSC MS2 MYSQL code to Zencart compliant MYSQL code, I'm certain the module will work.

    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = tep_db_query($sql); 
    $rec = tep_db_fetch_array($qResult);
    Thanks
    I have the same problem like this, can anyone help me?

    Thanks

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Help converting OSC SQL code to Zencart

    Zen-Venom Get Bitten

  4. #4
    Join Date
    Jul 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Help converting OSC SQL code to Zencart

    Quote Originally Posted by kobra View Post
    Thank you for the reply, i was trying to change the query into:
    PHP Code:
    $sql "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult $db->Execute($sql); 
    $rec $db->Execute($qResult); 
    But still getting errors, could you advise me how should it be?

    Thanks

  5. #5
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Help converting OSC SQL code to Zencart

    But still getting errors
    What error?
    And is this correct?
    From:
    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = tep_db_query($sql); 
    $rec = tep_db_fetch_array($qResult);
    To:
    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = $db->Execute($sql); 
    $rec = $db->Execute($qResult);
    Zen-Venom Get Bitten

  6. #6
    Join Date
    Jul 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Help converting OSC SQL code to Zencart

    Quote Originally Posted by kobra View Post
    What error?
    And is this correct?
    From:
    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = tep_db_query($sql); 
    $rec = tep_db_fetch_array($qResult);
    To:
    Code:
    $sql = "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";
    $qResult = $db->Execute($sql); 
    $rec = $db->Execute($qResult);
    I'm not so sure about this, i followed the instructions on the wiki.
    $my_var_query = tep_db_query("query stuff"); >> $my_var = $db->Execute("query stuff");

    $rec = tep_db_fetch_array($qResult); >>$rec = $db->Execute($qResult); (Not sure about this)

  7. #7
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Help converting OSC SQL code to Zencart

    What is the error that you get/see?
    Zen-Venom Get Bitten

  8. #8
    Join Date
    Jul 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Help converting OSC SQL code to Zencart

    Quote Originally Posted by kobra View Post
    What is the error that you get/see?
    I got this error:

    PHP Fatal error: Call to a member function Execute() on a non-object in C:\AppServ\www\zen\includes\modules\shipping\fastway.php on line 80

  9. #9
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Help converting OSC SQL code to Zencart

    do you have an added table for fastway_zones?
    Zen-Venom Get Bitten

  10. #10
    Join Date
    Jul 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Help converting OSC SQL code to Zencart

    Yes i have, here is the fastway.php that need to be fixed:
    PHP Code:
    <?php
    /*
      $Id: fastway.php,v 1.0 2006/02/21

      osCommerce, Open Source E-Commerce Solutions
      http://www.oscommerce.com

      Copyright (c) 2003 osCommerce


      Released under the GNU General Public License
    */

    class fastway {
    var 
    $code$title$description$num_zones$surcharge_factor$icon$enabled;

    // class constructor

    function fastway() {
          global 
    $order$db;

          
    $this->code 'fastway';
          
    $this->title MODULE_SHIPPING_FASTWAY_TEXT_TITLE;
          
    $this->description MODULE_SHIPPING_FASTWAY_TEXT_DESCRIPTION;
          
    $this->sort_order MODULE_SHIPPING_FASTWAY_SORT_ORDER;
          
    $this->icon '';
          
    $this->tax_class MODULE_SHIPPING_FASTWAY_TAX_CLASS;
         
          if (
    zen_get_shipping_enabled($this->code)) {
            
    $this->enabled = ((MODULE_SHIPPING_FASTWAY_STATUS == 'True') ? true false);
          }

          if ( (
    $this->enabled == true) && ((int)MODULE_SHIPPING_FASTWAY_ZONE 0) ) {
          
    $check_flag false;
          
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_SHIPPING_FASTWAY_ZONE "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id");
          while (!
    $check->EOF) {
            if (
    $check->fields['zone_id'] < 1) {
              
    $check_flag true;
              break;
             } elseif (
    $check->fields['zone_id'] == $order->delivery['zone_id']) {
              
    $check_flag true;
              break;
            }
             
    $check->MoveNext();
          }

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

    // Customize this setting for the number of zones needed (no change required by default)
    $this->num_zones 6;

    //More options can be added later for Express, Overnight etc when someone codes it.
    $this->types = array('Fast Off-Peak' => 'std');

    // Change this surcharge factor to increase your profit margin on freight
    $this->surcharge_factor MODULE_SHIPPING_FASTWAY_SURCHARGE;
    }
    }
    // class methods

    function quote($method '') {

    global 
    $order$cart$shipping_weight$shipping_num_boxes,  $total_weight;

    // First get the dest zip and check the db for our dest zone
        
    $topcode $order->delivery['postcode'];

    if ( 
    $topcode == '' ){
    // Something is wrong, we didn't find any zone
        
    $this->quotes['error'] = MODULE_SHIPPING_FASTWAY_NO_POSTCODE_FOUND;
    return 
    $this->quotes;
    }

    $sql "SELECT * FROM fastway_zones WHERE $topcode >= f_postcode and $topcode <= f_postcode";


    $qResult $db->Execute($sql); 
    $rec $db->Execute($qResult); 


        if (
    $rec['f_delivery'] = 'S/D') {
        
    $days 'same';
        }
        if (
    $rec['f_delivery'] = 'N/D') {
        
    $days 'next';
        } else {
        
    $days $rec['f_delivery'];
    }

    if (
    $rec['f_zone'] == '1') {
            
    $shipping = -1;
    $dest_zone 1;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_1_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_1_HANDLING');
    }
    elseif (
    $rec['f_zone'] == '2') {
            
    $shipping = -1;
    $dest_zone 2;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_2_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_2_HANDLING');
    }
    elseif (
    $rec['f_zone'] == '3') {
            
    $shipping = -1;
    $dest_zone 3;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_3_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_3_HANDLING');
    }
    elseif (
    $rec['f_zone'] == '4') {;
            
    $shipping = -1;
    $dest_zone 4;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_4_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_4_HANDLING');
    }
    elseif (
    $rec['f_zone'] == 'L') {
            
    $shipping = -1;
    $dest_zone 5;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_LOCAL_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_LOCAL_HANDLING');
    }
    elseif (
    $rec['f_zone'] == 'S/H') {
            
    $shipping = -1;
    $dest_zone 6;
            
    $zones_cost constant('MODULE_SHIPPING_ZONE_SHORT_COST');
            
    $zones_handling constant('MODULE_SHIPPING_ZONE_SHORT_HANDLING');
    } else {
            
    // Something is wrong, we didn't find any zone
            
    $this->quotes['error'] = MODULE_SHIPPING_FASTWAY_NO_ZONE_FOUND;
            return 
    $this->quotes;
    }

            
    $zones_table split("[:,]" $zones_cost);
            
    $size sizeof($zones_table);
            for (
    $i=0$i<$size$i+=2) {
              if (
    $shipping_weight <= $zones_table[$i]) {
                
    $shipping $zones_table[$i+1];
                break;
              }
            }

            
    $handling MODULE_SHIPPING_FASTWAY_HANDLING;
              if (
    $handling >0) {
                
    $handling_details " $" MODULE_SHIPPING_FASTWAY_HANDLING " " .MODULE_SHIPPING_FASTWAY_TEXT_HANDLING;
              } else {
                
    $handling_details "";
              }

                  if (
    $handling  == 0) {
                    
    $fastways_addons "";
                  } else {
                    
    $fastways_addons " (" MODULE_SHIPPING_FASTWAY_TEXT_INCLUDE $handling_details.") ";
                  }


            if (
    $shipping == -1) {
              
    $shipping_cost 0;
              
    $shipping_method MODULE_SHIPPING_FASTWAY_UNDEFINED_RATE;
            } else {
              
    $shipping_cost = ($shipping $shipping_num_boxes) + MODULE_SHIPPING_FASTWAY_HANDLING $insurance;
              
    $shipping_method MODULE_SHIPPING_FASTWAY_TEXT_WAY" <b>"  $topcode "</b> - " $days " " MODULE_SHIPPING_FASTWAY_TEXT_SHIPPINGDAYS "<br>" .$shipping_num_boxes "&nbsp;" .MODULE_SHIPPING_FASTWAY_TEXT_BOXES  " " $total_weight MODULE_SHIPPING_FASTWAY_TEXT_UNITS $fastways_addons;

            }

          
    $this->quotes = array('id' => $this->code,
                                
    'module' => MODULE_SHIPPING_FASTWAY_TEXT_TITLE,
                                
    'methods' => array(array('id' => $this->code,
                                                         
    'title' => $shipping_method,
                                                         
    'cost' => $shipping_cost)));

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

          if (
    zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon$this->title);

          if (
    $error == true$this->quotes['error'] = MODULE_SHIPPING_FASTWAY_TEXT_ERROR;

          return 
    $this->quotes;
        }

    function 
    check() {
     global 
    $db;
    if (!isset(
    $this->_check)) {
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_SHIPPING_FASTWAY_STATUS'");
    $this->_check $check_query->RecordCount();
    }
    return 
    $this->_check;
    }

    function 
    install() {
     global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Fastway', 'MODULE_SHIPPING_FASTWAY_STATUS', 'True', 'Do you want to offer Fastway postcode/zone rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Insurance', 'MODULE_SHIPPING_FASTWAY_INSURANCE', '25:5.90', 'Insurance cost is based on the total cost of items. Example: 25:8.50,50:5.50,etc.. Up to $25 charge $8.50, from there to $50 charge $5.50, etc', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Surcharge', 'MODULE_SHIPPING_FASTWAY_SURCHARGE', '', 'Do you want to add a surcharge on your freight quote (this can cover additional handling costs.) Enter it in the format of 1.1 for 10% 1.2 for 20% etc', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Dispatch Postcode', 'MODULE_SHIPPING_FASTWAY_SPCODE', '2000', 'Dispatch Postcode?', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_FASTWAY_HANDLING', '10', 'Handling Fee for this shipping method (Flat rate $ value)', '6', '0', now())");
          
    $db->Execute("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_FASTWAY_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
          
    $db->Execute("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_FASTWAY_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");      
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_FASTWAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Zone Shipping Table', 'MODULE_SHIPPING_ZONE_LOCAL_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Local Zone destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Local Zone destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Zone Handling Fee', 'MODULE_SHIPPING_ZONE_LOCAL_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Short Haul Shipping Table', 'MODULE_SHIPPING_ZONE_SHORT_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Short Haul Zone destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Short Haul Zone destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Short Haul Handling Fee', 'MODULE_SHIPPING_ZONE_SHORT_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 1 Shipping Table', 'MODULE_SHIPPING_ZONE_1_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone 1 destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone 1 destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 1 Handling Fee', 'MODULE_SHIPPING_ZONE_1_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 2 Shipping Table', 'MODULE_SHIPPING_ZONE_2_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone 2 destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone 2 destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 2 Handling Fee', 'MODULE_SHIPPING_ZONE_2_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 3 Shipping Table', 'MODULE_SHIPPING_ZONE_3_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone 3 destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone 3 destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 3 Handling Fee', 'MODULE_SHIPPING_ZONE_3_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 4 Shipping Table', 'MODULE_SHIPPING_ZONE_4_COST', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone 4 destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone 4 destinations.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 4 Handling Fee', 'MODULE_SHIPPING_ZONE_4_HANDLING', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

        }

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

        function 
    keys() {
          return array(
    'MODULE_SHIPPING_FASTWAY_STATUS''MODULE_SHIPPING_FASTWAY_INSURANCE''MODULE_SHIPPING_FASTWAY_SURCHARGE''MODULE_SHIPPING_FASTWAY_MAX_SHIPWEIGHT''MODULE_SHIPPING_FASTWAY_SPCODE''MODULE_SHIPPING_FASTWAY_HANDLING''MODULE_SHIPPING_FASTWAY_ZONE''MODULE_SHIPPING_FASTWAY_TAX_CLASS''MODULE_SHIPPING_FASTWAY_SORT_ORDER''MODULE_SHIPPING_ZONE_LOCAL_COST''MODULE_SHIPPING_ZONE_LOCAL_HANDLING''MODULE_SHIPPING_ZONE_SHORT_COST''MODULE_SHIPPING_ZONE_SHORT_HANDLING''MODULE_SHIPPING_ZONE_1_COST''MODULE_SHIPPING_ZONE_1_HANDLING''MODULE_SHIPPING_ZONE_2_COST''MODULE_SHIPPING_ZONE_2_HANDLING''MODULE_SHIPPING_ZONE_3_COST''MODULE_SHIPPING_ZONE_3_HANDLING''MODULE_SHIPPING_ZONE_4_COST''MODULE_SHIPPING_ZONE_4_HANDLING');
        }
      }
    ?>

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Old OSC db Backup Need help converting
    By jbginz in forum General Questions
    Replies: 1
    Last Post: 26 Aug 2013, 08:46 PM
  2. v150 Converting osc contribution Post code Validation
    By vkd1980 in forum Contribution-Writing Guidelines
    Replies: 5
    Last Post: 25 Aug 2012, 05:59 AM
  3. Few lines code translation from osc to zencart - please help
    By Backstage in forum All Other Contributions/Addons
    Replies: 10
    Last Post: 14 Jul 2009, 08:49 AM
  4. Converting Header from OSC to Zen
    By msmith1111 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 15 Nov 2008, 04:49 AM
  5. Converting from osC to Zen
    By Therose in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 14 Jan 2008, 02:51 AM

Posting Permissions

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