Jump to content
blucollarguy

Multi_Vendor_Shipping new thread

Recommended Posts

I looked at your vendor email contribution before and would like to implement it but I thought I wait until MVS is released. I thought you would implement Vendor Email into this Multi Vendor Shipping contrib and I worried that there might be problems with MVS if I implement VE. So, if there are no problems to expect, I will probably implement VE.

 

Thanks guys you are great!

 

Uli

***Note, VendorEmail is ALREADY implemented in MVS, it has been a part of the code from the beginning. If you have installed MVS then you have also installed VendorEmail. You can use it NOW, no need to install VendorEmail seperately, its already there. I was pointing you to the code so you could see the functionality, not to install it. So no worries, enjoy!

Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
***Note, VendorEmail is ALREADY implemented in MVS, it has been a part of the code from the beginning. If you have installed MVS then you have also installed VendorEmail. You can use it NOW, no need to install VendorEmail seperately, its already there. I was pointing you to the code so you could see the functionality, not to install it. So no worries, enjoy!

Craig :)

 

Oh, I see. My apologies, I have not installed MVS yet. That's why I am not very familiar with the functionality.

 

So far I did all mods on a live system. I installed about 16 contributions so far and did my own mods mainly in the order admin system.

 

Therefore it is about time to set up a test store before I make further modifications. Also I cannot live w/o the order editor so I will have to wait or find a way to keep it running after installing MVS.

 

I am currently setting up a test system and will buy probably have to run out to buy some literature such as php and html for runaways or so :blush:

I did assembler and some C-coding years ago but don't really know what I am doing in php....

 

Thanks,

Uli

Share this post


Link to post
Share on other sites
Oh, I see. My apologies, I have not installed MVS yet. That's why I am not very familiar with the functionality.

 

So far I did all mods on a live system. I installed about 16 contributions so far and did my own mods mainly in the order admin system.

 

Therefore it is about time to set up a test store before I make further modifications. Also I cannot live w/o the order editor so I will have to wait or find a way to keep it running after installing MVS.

 

I am currently setting up a test system and will buy probably have to run out to buy some literature such as php and html for runaways or so  :blush:

I did assembler and some C-coding years ago but don't really know what I am doing in php....

 

Thanks,

Uli

Ok Uli, good luck, Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Kymation,

 

I'm still trying to make the USPS modules work, both my modified USPS module and the one you've packaged with MVS and I've found a couple of things.

 

First, according to your modules.txt, when converting a shipping module for use with MVS, one of the first modifications to make is to change this

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

to

// class constructor
 function usps() {
   global $order, $vendors_id;

It looks like this was missed in your usps.php, however, adding it made no difference.

 

Second, in my usps.php, things appear to be working with the same results as your usps.php, but I'm getting an error in my httpd logs that looks like halfway through processing the usps.php file, the $vendors_id variable is lost! I'm getting the following error in my log for all the lines below

  function getQuote() {
    global $order;

Here's the error message

[error] PHP Warning: constant(): Couldn't find constant MODULE_SHIPPING_USPS_OPTIONS_ in /usr/local/httpd/catalog/includes/modules/vendors_shipping/usps.php on line 324
Note the constant ends with the underscore, not a number. This is repeated 5 times, once on each of these lines 324, 328, 340 and 396, twice on line 328. All of the lines above 324 that have the contant in them are apparently handled OK. I am able to install and uninstall the module and it works just as yours does including not giving a quote. I'm going to attach my usps.php here. Maybe you can take a quick look and see why the $vendors_id variable seems to get dropped.

 

<?php

/*

 $Id: usps.php,v 1.47 2003/04/08 23:23:42 dgw_ Exp $

 ++++ modified as USPS Methods 2.5 08/02/03 by Brad Waite and Fritz Clapp ++++

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

 

 class usps {

   var $code, $title, $description, $icon, $enabled, $countries;

 

// class constructor

   function usps() {

     global $order, /* MVS */$vendors_id;

// Added MVS  

  $this->vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id'];

// End ADD

 

     $this->code = 'usps';

     $this->title = MODULE_SHIPPING_USPS_TEXT_TITLE;

     $this->description = MODULE_SHIPPING_USPS_TEXT_DESCRIPTION;

     $this->icon = DIR_WS_ICONS . 'shipping_usps.gif';

 

// Removed MVS

/*

     $this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;

     $this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;

     $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);

 

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_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_USPS_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;

       }

     }

End of Remove

*/

     $this->types = array('Express' => 'Express Mail',

                          'First Class' => 'First-Class Mail',

                          'Priority' => 'Priority Mail',

                          'Parcel' => 'Parcel Post');

 

     $this->intl_types = array('GXG Document' => 'Global Express Guaranteed Document Service',

                               'GXG Non-Document' => 'Global Express Guaranteed Non-Document Service',

                               'Express' => 'Global Express Mail (EMS)',

                               'Priority Lg' => 'Global Priority Mail - Flat-rate Envelope (large)',

                               'Priority Sm' => 'Global Priority Mail - Flat-rate Envelope (small)',

                               'Priority Var' => 'Global Priority Mail - Variable Weight Envelope (single)',

                               'Airmail Letter' => 'Airmail Letter Post',

                               'Airmail Parcel' => 'Airmail Parcel Post',

                               'Surface Letter' => 'Economy (Surface) Letter Post',

                               'Surface Post' => 'Economy (Surface) Parcel Post');

 

     $this->countries = $this->country_list();

   }

 

// MVS ADD

   function sort_order($vendors_id='0') {

     if (defined (constant ('MODULE_SHIPPING_USPS_SORT_ORDER_' . $vendors_id))) {

       $this->sort_order = constant('MODULE_SHIPPING_USPS_SORT_ORDER_' . $vendors_id);

     } else {

       $this->sort_order = '0';

     }

     return $this->sort_order;

   }

 

   function tax_class($vendors_id='1') {

     $this->tax_class = constant('MODULE_SHIPPING_USPS_TAX_CLASS_' . $vendors_id);

     return $this->tax_class;

   }

 

   function enabled($vendors_id='1') {

     $this->enabled = false;

     $status = constant('MODULE_SHIPPING_USPS_STATUS_' . $vendors_id);

  if (isset ($status) && $status != '') {

       $this->enabled = (($status == 'True') ? true : false);

     }

     return $this->enabled;

   }

 

   function zones($vendors_id='1') {

     if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_USPS_ZONE_' . $vendors_id) > 0) ) {

       $check_flag = false;

       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_USPS_ZONE_' . $vendors_id) . "' 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

       }//while

 

       if ($check_flag == false) {

         $this->enabled = false;

       }//if

     }//if

     return $this->enabled;

   }//function

// EOADD MVS

 

// class methods

// Changed MVS

//    function quote($method = '') {

function quote($method = '', $module = '', $vendors_id = '1') {

// EOCHANGE

 

// BOF: UPS USPS

     global $order, $shipping_weight, $shipping_num_boxes, $transittime;

 

     if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {

       $this->_setService($method);

     }

 

     $this->_setMachinable('False');

     $this->_setContainer('None');

     $this->_setSize('REGULAR');

 

// usps doesnt accept zero weight

     $shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

     $shipping_pounds = floor ($shipping_weight);

     $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));

     $this->_setWeight($shipping_pounds, $shipping_ounces);

// BOF: UPS USPS

 

     if (in_array('Display weight', explode(', ', constant('MODULE_SHIPPING_USPS_OPTIONS_' . $vendors_id)))) {

       $shiptitle = ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)';

     } else {

       $shiptitle = '';

     }

// EOF: UPS USPS

 

     $uspsQuote = $this->_getQuote();

 

     if (is_array($uspsQuote)) {

       if (isset($uspsQuote['error'])) {

         $this->quotes = array('module' => $this->title,

                               'error' => $uspsQuote['error']);

       } else {

 

// Added MVS

     $vendors_data_query = tep_db_query("select handling_charge,

                                                handling_per_box

                                         from " . TABLE_VENDORS . "

                                         where vendors_id = '" . (int)$vendors_id . "'"

                                       );

     $vendors_data = tep_db_fetch_array($vendors_data_query);

 

     $handling_charge = $vendors_data['handling_charge'];

     $handling_per_box = $vendors_data['handling_per_box'];

     if ($handling_charge > $handling_per_box*$shipping_num_boxes) {

       $handling = $handling_charge;

     } else {

       $handling = $handling_per_box*$shipping_num_boxes;

     }

// EOADD MVS

 

/* Original

         $this->quotes = array('id' => $this->code,

                               'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)');

*/

// BOF: UPS USPS

         $this->quotes = array('id' => $this->code,

                               'module' => $this->title . $shiptitle);

// EOF: UPS USPS

 

         $methods = array();

         $size = sizeof($uspsQuote);

         for ($i=0; $i<$size; $i++) {

           list($type, $cost) = each($uspsQuote[$i]);

 

// BOF: UPS USPS

           $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);

           if(in_array('Display transit time', explode(', ', constant('MODULE_SHIPPING_USPS_OPTIONS_' . $vendors_id))))    $title .= $transittime[$type];

 

/* ORIGINAL

           $methods[] = array('id' => $type,

                              'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

                              'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

*/

           $methods[] = array('id' => $type,

                              'title' => $title,

                              'cost' => ($cost + $handling) * $shipping_num_boxes);

         }

// EOF: UPS USPS

 

         $this->quotes['methods'] = $methods;

 

         if ($this->tax_class > 0) {

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

         }

       }

     } else {

       $this->quotes = array('module' => $this->title,

                             'error' => MODULE_SHIPPING_USPS_TEXT_ERROR);

     }

 

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

 

     return $this->quotes;

   }

 

// MVS Added/Changed    

// function check() {

   function check($vendors_id = '1') {

//EOMVS

 

     if (!isset($this->_check)) {

// MVS Added/Changed

//        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_STATUS'");

       $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key = 'MODULE_SHIPPING_USPS_STATUS_" . $vendors_id . "'");

// EOMVS    

   

 $this->_check = tep_db_num_rows($check_query);

     }

     return $this->_check;

   }

 

// MVS Added/Changed

/*

   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 USPS Shipping', 'MODULE_SHIPPING_USPS_STATUS', 'True', 'Do you want to offer USPS 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 ('Enter the USPS User ID', 'MODULE_SHIPPING_USPS_USERID', 'NONE', 'Enter the USPS USERID assigned to you.', '6', '0', now())");

// BOF: UPS USPS

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enter the USPS Password', 'MODULE_SHIPPING_USPS_PASSWORD', 'NONE', 'See USERID, above.', '6', '0', now())");

     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 ('Which server to use', 'MODULE_SHIPPING_USPS_SERVER', 'production', 'An account at USPS is needed to use the Production server', '6', '0', 'tep_cfg_select_option(array(\'test\', \'production\'), ', 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_USPS_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_USPS_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_USPS_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_USPS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

     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 ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express, Priority, First Class, Parcel', 'Select the domestic services to be offered:', '6', '14', 'tep_cfg_select_multioption(array(\'Express\', \'Priority\', \'First Class\', \'Parcel\'), ',  now())");

     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 ('Int\'l Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_INTL', 'GXG Document, GXG Non-Document, Express, Priority Lg, Priority Sm, Priority Var, Airmail Letter, Airmail Parcel, Surface Letter, Surface Post', 'Select the international services to be offered:', '6', '15', 'tep_cfg_select_multioption(array(\'GXG Document\', \'GXG Non-Document\', \'Express\', \'Priority Lg\', \'Priority Sm\', \'Priority Var\', \'Airmail Letter\', \'Airmail Parcel\', \'Surface Letter\', \'Surface Post\'), ',  now())");

     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 ('USPS Options', 'MODULE_SHIPPING_USPS_OPTIONS', 'Display weight, Display transit time', 'Select from the following the USPS options.', '6', '16', 'tep_cfg_select_multioption(array(\'Display weight\', \'Display transit time\'), ',  now())");

// EOF: UPS USPS

   }

*/

   function install($vendors_id = '1') {

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable USPS Shipping', 'MODULE_SHIPPING_USPS_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer USPS shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Enter the USPS User ID', 'MODULE_SHIPPING_USPS_USERID_" . $vendors_id . "', 'NONE', 'Enter the USPS USERID assigned to you.', '6', '0', now(), '" . $vendors_id . "')");

// BOF: UPS USPS

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Enter the USPS Password', 'MODULE_SHIPPING_USPS_PASSWORD_" . $vendors_id . "', 'NONE', 'See USERID, above.', '6', '0', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Which server to use', 'MODULE_SHIPPING_USPS_SERVER_" . $vendors_id . "', 'production', 'An account at USPS is needed to use the Production server', '6', '0', 'tep_cfg_select_option(array(\'test\', \'production\'), ', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Handling Fee', 'MODULE_SHIPPING_USPS_HANDLING_" . $vendors_id . "', '0', 'Handling fee for this shipping method.', '6', '0', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_USPS_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_USPS_ZONE_" . $vendors_id . "', '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(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_USPS_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_" . $vendors_id . "', 'Express, Priority, First Class, Parcel', 'Select the domestic services to be offered:', '6', '14', 'tep_cfg_select_multioption(array(\'Express\', \'Priority\', \'First Class\', \'Parcel\'), ',  now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Int\'l Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_INTL_" . $vendors_id . "', 'GXG Document, GXG Non-Document, Express, Priority Lg, Priority Sm, Priority Var, Airmail Letter, Airmail Parcel, Surface Letter, Surface Post', 'Select the international services to be offered:', '6', '15', 'tep_cfg_select_multioption(array(\'GXG Document\', \'GXG Non-Document\', \'Express\', \'Priority Lg\', \'Priority Sm\', \'Priority Var\', \'Airmail Letter\', \'Airmail Parcel\', \'Surface Letter\', \'Surface Post\'), ',  now(), '" . $vendors_id . "')");

     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('USPS Options', 'MODULE_SHIPPING_USPS_OPTIONS_" . $vendors_id . "', 'Display weight, Display transit time', 'Select from the following the USPS options.', '6', '16', 'tep_cfg_select_multioption(array(\'Display weight\', \'Display transit time\'), ',  now(), '" . $vendors_id . "')");

// EOF: UPS USPS

   }

// EOADD

 

// MVS Added/Changed

/*

   function remove() {

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

   }

*/

   function remove($vendors_id) {

     tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')");

   }

// EOADD

 

// MVS Added/Changed

/*    

function keys() {

// BOF: UPS USPS

// ORIGINAL      return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER');

     return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER', 'MODULE_SHIPPING_USPS_OPTIONS', 'MODULE_SHIPPING_USPS_TYPES', 'MODULE_SHIPPING_USPS_TYPES_INTL');

// EOF: UPS USPS

   }

*/

function keys($vendors_id) {

// BOF: UPS USPS

// ORIGINAL      return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER');

     return array('MODULE_SHIPPING_USPS_STATUS_' . $vendors_id, 'MODULE_SHIPPING_USPS_USERID_' . $vendors_id, 'MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id, 'MODULE_SHIPPING_USPS_SERVER_' . $vendors_id, 'MODULE_SHIPPING_USPS_HANDLING_' . $vendors_id, 'MODULE_SHIPPING_USPS_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_USPS_ZONE_' . $vendors_id, 'MODULE_SHIPPING_USPS_SORT_ORDER_' . $vendors_id, 'MODULE_SHIPPING_USPS_OPTIONS_' . $vendors_id, 'MODULE_SHIPPING_USPS_TYPES_' . $vendors_id, 'MODULE_SHIPPING_USPS_TYPES_INTL_' . $vendors_id);

// EOF: UPS USPS

   }

// EOADD MVS

 

   function _setService($service) {

     $this->service = $service;

   }

 

   function _setWeight($pounds, $ounces=0) {

     $this->pounds = $pounds;

     $this->ounces = $ounces;

   }

 

   function _setContainer($container) {

     $this->container = $container;

   }

 

   function _setSize($size) {

     $this->size = $size;

   }

 

   function _setMachinable($machinable) {

     $this->machinable = $machinable;

   }

 

   function _getQuote() {

// BOF: UPS USPS

     global $order, $vendors_id, $transittime;

 

     if(in_array('Display transit time', explode(', ', constant('MODULE_SHIPPING_USPS_OPTIONS_' . $vendors_id)))) $transit = TRUE;

// EOF: UPS USPS

 

     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {

       $request  = '<RateRequest USERID="' . constant('MODULE_SHIPPING_USPS_USERID_' . $vendors_id) . '" PASSWORD="' . constant('MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id) . '">';

       $services_count = 0;

 

       if (isset($this->service)) {

         $this->types = array($this->service => $this->types[$this->service]);

       }

 

       $dest_zip = str_replace(' ', '', $order->delivery['postcode']);

       if ($order->delivery['country']['iso_code_2'] == 'US') $dest_zip = substr($dest_zip, 0, 5);

 

       reset($this->types);

// BOF: UPS USPS

       $allowed_types = explode(", ", constant('MODULE_SHIPPING_USPS_TYPES_' . $vendors_id));

       while (list($key, $value) = each($this->types)) {

// BOF: UPS USPS

  if ( !in_array($key, $allowed_types) ) continue;

         $request .= '<Package ID="' . $services_count . '">' .

                     '<Service>' . $key . '</Service>' .

                     '<ZipOrigination>' . SHIPPING_ORIGIN_ZIP . '</ZipOrigination>' .

                     '<ZipDestination>' . $dest_zip . '</ZipDestination>' .

                     '<Pounds>' . $this->pounds . '</Pounds>' .

                     '<Ounces>' . $this->ounces . '</Ounces>' .

                     '<Container>' . $this->container . '</Container>' .

                     '<Size>' . $this->size . '</Size>' .

                     '<Machinable>' . $this->machinable . '</Machinable>' .

                     '</Package>';

 

// BOF: UPS USPS

         if($transit){

           $transitreq  = 'USERID="' . constant('MODULE_SHIPPING_USPS_USERID_' . $vendors_id) .

                        '" PASSWORD="' . constant('MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id) . '">' .

                        '<OriginZip>' . STORE_ORIGIN_ZIP . '</OriginZip>' .

                        '<DestinationZip>' . $dest_zip . '</DestinationZip>';

 

           switch ($key) {

             case 'Express':  $transreq[$key] = 'API=ExpressMail&XML=' .

                              urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');

                              break;

             case 'Priority': $transreq[$key] = 'API=PriorityMail&XML=' .

                              urlencode( '<PriorityMailRequest ' . $transitreq . '</PriorityMailRequest>');

                              break;

             case 'Parcel':   $transreq[$key] = 'API=StandardB&XML=' .

                              urlencode( '<StandardBRequest ' . $transitreq . '</StandardBRequest>');

                              break;

             default:         $transreq[$key] = '';

                              break;

           }

         }

// EOF: UPS USPS

 

         $services_count++;

       }

       $request .= '</RateRequest>';

 

       $request = 'API=Rate&XML=' . urlencode($request);

     } else {

       $request  = '<IntlRateRequest USERID="' . constant('MODULE_SHIPPING_USPS_USERID_' . $vendors_id) . '" PASSWORD="' . constant('MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id) . '">' .

                   '<Package ID="0">' .

                   '<Pounds>' . $this->pounds . '</Pounds>' .

                   '<Ounces>' . $this->ounces . '</Ounces>' .

                   '<MailType>Package</MailType>' .

                   '<Country>' . $this->countries[$order->delivery['country']['iso_code_2']] . '</Country>' .

                   '</Package>' .

                   '</IntlRateRequest>';

 

       $request = 'API=IntlRate&XML=' . urlencode($request);

     }

 

     switch (constant('MODULE_SHIPPING_USPS_SERVER_' . $vendors_id)) {

       case 'production': $usps_server = 'production.shippingapis.com';

                          $api_dll = 'shippingapi.dll';

                          break;

       case 'test':

       default:           $usps_server = 'testing.shippingapis.com';

                          $api_dll = 'ShippingAPITest.dll';

                          break;

     }

 

     $body = '';

 

     $http = new httpClient();

     if ($http->Connect($usps_server, 80)) {

       $http->addHeader('Host', $usps_server);

       $http->addHeader('User-Agent', 'osCommerce');

       $http->addHeader('Connection', 'Close');

 

       if ($http->Get('/' . $api_dll . '?' . $request)) $body = $http->getBody();

// BOF: UPS USPS

//  mail('you@yourdomain.com','USPS rate quote response',$body,'From: <you@yourdomain.com>');

       if ($transit && is_array($transreq) && ($order->delivery['country']['id'] == STORE_COUNTRY)) {

         while (list($key, $value) = each($transreq)) {

           if ($http->Get('/' . $api_dll . '?' . $value)) $transresp[$key] = $http->getBody();

         }

       }

// EOF: UPS USPS

 

       $http->Disconnect();

     } else {

       return false;

     }

 

     $response = array();

     while (true) {

       if ($start = strpos($body, '<Package ID=')) {

         $body = substr($body, $start);

         $end = strpos($body, '</Package>');

         $response[] = substr($body, 0, $end+10);

         $body = substr($body, $end+9);

       } else {

         break;

       }

     }

 

     $rates = array();

     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {

       if (sizeof($response) == '1') {

         if (ereg('<Error>', $response[0])) {

           $number = ereg('<Number>(.*)</Number>', $response[0], $regs);

           $number = $regs[1];

           $description = ereg('<Description>(.*)</Description>', $response[0], $regs);

           $description = $regs[1];

 

           return array('error' => $number . ' - ' . $description);

         }

       }

 

       $n = sizeof($response);

       for ($i=0; $i<$n; $i++) {

         if (strpos($response[$i], '<Postage>')) {

           $service = ereg('<Service>(.*)</Service>', $response[$i], $regs);

           $service = $regs[1];

           $postage = ereg('<Postage>(.*)</Postage>', $response[$i], $regs);

           $postage = $regs[1];

 

           $rates[] = array($service => $postage);

 

// BOF: UPS USPS

           if ($transit) {

             switch ($service) {

               case 'Express':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);

                                   $time = $tregs[1];

                                   if ($time == '' || $time == 'No Data') {

                                     $time = '1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   } else {

                                     $time = 'Tomorrow by ' . $time;

                                   }

                                   break;

               case 'Priority':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

                                   $time = $tregs[1];

                                   if ($time == '' || $time == 'No Data') {

                                     $time = '2 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   } elseif ($time == '1') {

                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;

                                   } else {

                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   }

                                   break;

               case 'Parcel':      $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

                                   $time = $tregs[1];

                                   if ($time == '' || $time == 'No Data') {

                                     $time = '4 - 7 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   } elseif ($time == '1') {

                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;

                                   } else {

                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   }

                                   break;

               case 'First Class': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

                                   break;

               default:            $time = '';

                                   break;

             }

             if ($time != '') $transittime[$service] = ' (' . $time . ')';

           }

// EOF: UPS USPS

         }

       }

     } else {

       if (ereg('<Error>', $response[0])) {

         $number = ereg('<Number>(.*)</Number>', $response[0], $regs);

         $number = $regs[1];

         $description = ereg('<Description>(.*)</Description>', $response[0], $regs);

         $description = $regs[1];

 

         return array('error' => $number . ' - ' . $description);

       } else {

         $body = $response[0];

         $services = array();

         while (true) {

           if ($start = strpos($body, '<Service ID=')) {

             $body = substr($body, $start);

             $end = strpos($body, '</Service>');

             $services[] = substr($body, 0, $end+10);

             $body = substr($body, $end+9);

           } else {

             break;

           }

         }

 

// BOF: UPS USPS

         $allowed_types = array();

         foreach( explode(", ", constant('MODULE_SHIPPING_USPS_TYPES_INTL_' . $vendors_id)) as $value ) $allowed_types[$value] = $this->intl_types[$value];

// EOF: UPS USPS

 

         $size = sizeof($services);

         for ($i=0, $n=$size; $i<$n; $i++) {

           if (strpos($services[$i], '<Postage>')) {

             $service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);

             $service = $regs[1];

             $postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);

             $postage = $regs[1];

// BOF: UPS USPS

             $time = ereg('<SvcCommitments>(.*)</SvcCommitments>', $services[$i], $tregs);

             $time = $tregs[1];

             $time = preg_replace('/Weeks$/', MODULE_SHIPPING_USPS_TEXT_WEEKS, $time);

             $time = preg_replace('/Days$/', MODULE_SHIPPING_USPS_TEXT_DAYS, $time);

             $time = preg_replace('/Day$/', MODULE_SHIPPING_USPS_TEXT_DAY, $time);

 

             if( !in_array($service, $allowed_types) ) continue;

// EOF: UPS USPS

             if (isset($this->service) && ($service != $this->service) ) {

               continue;

             }

 

             $rates[] = array($service => $postage);

// BOF: UPS USPS

      if ($time != '') $transittime[$service] = ' (' . $time . ')';

// EOF: UPS USPS

           }

         }

       }

     }

 

     return ((sizeof($rates) > 0) ? $rates : false);

   }

 

   function country_list() {

     $list = array('AF' => 'Afghanistan',

                   'AL' => 'Albania',

                   'DZ' => 'Algeria',

                   'AD' => 'Andorra',

                   'AO' => 'Angola',

                   'AI' => 'Anguilla',

                   'AG' => 'Antigua and Barbuda',

                   'AR' => 'Argentina',

                   'AM' => 'Armenia',

                   'AW' => 'Aruba',

                   'AU' => 'Australia',

   

Share this post


Link to post
Share on other sites

Using $vendors_id as a global was an idea that didn't work. Please take that out of the global lists.

 

To make this work, try changing line 150 from

     $uspsQuote = $this->_getQuote();

to

     $uspsQuote = $this->_getQuote($vendors_id);

Then change line 320 from

   function _getQuote() {

to

   function _getQuote($vendors_id) {

 

That should get the vendors_id passed correctly. To get the shipper's zip code and country correct, add the following around line 323

      $vendors_data_query = tep_db_query("select vendor_country,
                                                vendors_zipcode 
                                         from " . TABLE_VENDORS . " 
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );
     $vendors_data = tep_db_fetch_array($vendors_data_query);

then change SHIPPING_ORIGIN_COUNTRY (around 327) to $vendors_data['vendor_country'] and STORE_ORIGIN_ZIP (around 359) to $vendors_data['vendors_zipcode'].

 

There may be more of these. I'll take another look later.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
Using $vendors_id as a global was an idea that didn't work. Please take that out of the global lists.

Thanks Jim,

 

I'll give it a try and let you know how it works.

 

Rick Knight

Share this post


Link to post
Share on other sites

Jim,

 

That's getting closer. After making those changes, I no longer get any error messages from the USPS module. In a test transaction I get the following error in the Shipping Methods > Products box under United States Postal Service...

  -2147219080 - Missing value for Country.
This looks like a USPS error code, so my ID and Password are being passed off to USPS and something is getting back. I think.

 

Thanks again,

Rick Knight

Share this post


Link to post
Share on other sites

Yes, that's a typical USPS error code. The country is either not getting passed, or it's getting passed in the wrong format. I need to fix the SQL to give the country in the right format. Do you know what format USPS wants? I can't find it in the docs.

 

There's another constant as well: SHIPPING_ORIGIN_ZIP around line 346.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
Yes, that's a typical USPS error code. The country is either not getting passed, or it's getting passed in the wrong format. I need to fix the SQL to give the country in the right format. Do you know what format USPS wants? I can't find it in the docs.

 

There's another constant as well: SHIPPING_ORIGIN_ZIP  around line 346.

 

Regards

Jim

You know, I kept looking at SHIPPING_ORIGIN_ZIP and thinking it should be changed somehow.

 

I think the USPS country format is standard 2 character code, like US, GB etc. If you look at the bottom of my USPS module you'll see a country code list and it's all standard 2 character, but it doesn't list the US. If I have time tonight I'll look at SHIPPING_ORIGIN_ZIP some more.

 

Thanks,

Rick Knight

Share this post


Link to post
Share on other sites
You know, I kept looking at SHIPPING_ORIGIN_ZIP and thinking it should be changed somehow.

 

I think the USPS country format is standard 2 character code, like US, GB etc. If you look at the bottom of my USPS module you'll see a country code list and it's all standard 2 character, but it doesn't list the US. If I have time tonight I'll look at SHIPPING_ORIGIN_ZIP some more.

 

Thanks,

Rick Knight

"SHIPPING_ORIGIN_ZIP" is an osC constant, it is in the database as a "configuration key". That will have to be replaced with the "vendors_zipcode" from the query earlier in the code calling the module during checkout. The country code should be fixed with the change Jim posted earlier to the "vendors.php" file. You can look in the database to see how it is being stored, the "vendors" table. I have been wrapped up with a number of other issues and hope to get to this soon as well. We will get it, it's very close, and we appreciate your efforts and patience Rick, Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
The country code should be fixed with the change Jim posted earlier to the "vendors.php" file.

BlueCollarGuy,

 

I've searched the thread for Jim's fix for vendors.php, but I can't find it. Do you mean the fix he posted for vendor_modules.php?

 

Thanks,

Rick Knight

Share this post


Link to post
Share on other sites

I don't think that I ever posted that code here. I did send it to Craig to review. So, check your files, and if these changes don't already exist, please make them as follows.

 

In admin/includes/functions/html_output.php, add the following near the bottom:

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = '', $parameters = '') {
   $countries = tep_get_countries();

   return tep_draw_pull_down_menu($name, $countries, $selected, $parameters);
 }

Then in admin/vendors.php, find this code (line332):

  echo tep_draw_input_field('vendor_country', $vInfo->vendor_country, 'maxlength="64"');

and replace it with this:

  echo tep_get_country_list('vendor_country', $vInfo->vendor_country);

Now you will need to go to the Vendors page in your Admin and select the country from the dropdown for each vendor. Then you can change this code in your usps.php from

      $vendors_data_query = tep_db_query("select vendor_country,
                                                vendors_zipcode
                                         from " . TABLE_VENDORS . "
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );

to

      $vendors_data_query = tep_db_query("select c.countries_iso_code_2 as vendor_country,
                                                v.vendors_zipcode
                                         from " . TABLE_VENDORS . " v,
                                              " . TABLE_COUNTRIES . c"
                                         where v.vendors_id = '" . (int)$vendors_id . "'
                                           and c.countries_id = v.vendor_country"
                                       );

Now your USPS query should work. Oh, and replace SHIPPING_ORIGIN_ZIP with $vendors_data['vendors_zipcode'].

 

This is all untested, since my USPS password still doesn't work on their production server. Looks like I need to give them a call.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
I don't think that I ever posted that code here. I did send it to Craig to review. So, check your files, and if these changes don't already exist, please make them as follows.

 

In admin/includes/functions/html_output.php, add the following near the bottom:

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = '', $parameters = '') {
   $countries = tep_get_countries();

   return tep_draw_pull_down_menu($name, $countries, $selected, $parameters);
 }

Then in admin/vendors.php, find this code (line332):

  echo tep_draw_input_field('vendor_country', $vInfo->vendor_country, 'maxlength="64"');

and replace it with this:

  echo tep_get_country_list('vendor_country', $vInfo->vendor_country);

Now you will need to go to the Vendors page in your Admin and select the country from the dropdown for each vendor. Then you can change this code in your usps.php from

      $vendors_data_query = tep_db_query("select vendor_country,
                                                vendors_zipcode
                                         from " . TABLE_VENDORS . "
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );

to

      $vendors_data_query = tep_db_query("select c.countries_iso_code_2 as vendor_country,
                                                v.vendors_zipcode
                                         from " . TABLE_VENDORS . " v,
                                              " . TABLE_COUNTRIES . c"
                                         where v.vendors_id = '" . (int)$vendors_id . "'
                                           and c.countries_id = v.vendor_country"
                                       );

Now your USPS query should work. Oh, and replace SHIPPING_ORIGIN_ZIP with $vendors_data['vendors_zipcode'].

 

This is all untested, since my USPS password still doesn't work on their production server. Looks like I need to give them a call.

 

Regards

Jim

 

Jim,

 

I haven't made these changes yet, but I will today. In the mean time, I changed SHIPPING_ORIGIN_ZIP in my sups.php as you suggested and then took a look at my configuration table and found that the country codes required for USPS are numeric and the US is 223. I put 223 into the vendor_country field in the vendors table and it worked. I'm getting quotes from USPS. Do your mods do the same thing, that is, convert the ISO code to the numeric code?

 

Thanks,

Rick Knight

Share this post


Link to post
Share on other sites

Rick: Yes, that was my intention. The first two code snippits insert the country code into the database. If you have the rest working, you can forget my suggested changes to your USPS module.

 

Glad to hear that you got it working.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Sorry about that guys, I thought you had posted it here as well Jim, my bungle. Glad it's working Rick, we'll keep at it. Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Craig, Jim,

 

That works. I added just the top two code snippets and left my usps.php as is. I think I'll apply the changes in usps.php to fedex1.php and see how it goes. I'll let you know how I do.

 

I can't wait to see the rest of this mod!

 

Thanks,

Rick Knight

Share this post


Link to post
Share on other sites

Hello all,

Great work on this module, it seems to be shaping up very well, and also is going to be a great addition to oscommerce.

I'm curious when the next beta release/release canidate will be packaged up. Is there a chance it will be before March 31st?

If so, then great! If not, no problems, I'll just have to do more legwork.

Thanks,

Joseph

Share this post


Link to post
Share on other sites

Joseph: There's a pretty good chance. I just sent Craig my latest set of patches to the backend. If he's satisfied, the next Release Candidate will be ready to go. This should add all of the functionality that we have in mind for the first release. We might add a couple of shipping modules, or those may get done after the release.

 

If you want to start working on it, most of the code is already up. We're just working on a few pages for the Admin: Orders, Invoice, and Packing Slips. The rest of the code won't be changing (Unless we find another bug, which is always possible.) So you can safely use what's there and just add in the new files when they go up.

 

I should repeat the warning that this is still beta code. I wouldn't suggest using it in a live site just yet. That said, I'm breaking my own rule and adding this to a client's heavily-modified site. I'm keeping my fingers crossed.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Jim,

Unfortunately, I have break your advice as well. I have a heavily modified site for a client that needs a TINY bit of the functionality that this module provides. I'm skilled enough at module hacking that any problems I run into should be quickly fixed.

Anyways, if I run into anything that I can fix, I'll let you guys know.

Keep up the great work!

Joseph

Share this post


Link to post
Share on other sites

Joseph: Good luck with your mod. We'll be happy to take any bug fixes or reports, and suggestions for improvement are also welcome.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
      $vendors_data_query = tep_db_query("select vendor_country,
                                                vendors_zipcode
                                         from " . TABLE_VENDORS . "
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );

to

      $vendors_data_query = tep_db_query("select c.countries_iso_code_2 as vendor_country,
                                                v.vendors_zipcode
                                         from " . TABLE_VENDORS . " v,
                                              " . TABLE_COUNTRIES . c"
                                         where v.vendors_id = '" . (int)$vendors_id . "'
                                           and c.countries_id = v.vendor_country"
                                       );

Now your USPS query should work. Oh, and replace SHIPPING_ORIGIN_ZIP with $vendors_data['vendors_zipcode'].

 

There is a small typo in the replacement code. It should be this:

      $vendors_data_query = tep_db_query("select c.countries_iso_code_2 as vendor_country,
                                                v.vendors_zipcode
                                         from " . TABLE_VENDORS . " v,
                                              " . TABLE_COUNTRIES . " c
                                         where v.vendors_id = '" . (int)$vendors_id . "'
                                           and c.countries_id = v.vendor_country"
                                       );

 

The typo is the 'c' was on the wrong side of the quotation mark in the 4th line.

 

Joseph

Share this post


Link to post
Share on other sites

Joseph: Good work. I should always check my typing; I do this a lot. Thanks for the correction.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Jim,

After looking at the code for a while, isn't this more of what we want?

$vendors_data_query = tep_db_query("select v.vendor_country,
                                                  v.vendors_zipcode
                                           from " . TABLE_VENDORS . " v,
                                                " . TABLE_COUNTRIES . " c
                                           where v.vendors_id = '" . (int)$vendors_id . "'
                                           and v.vendor_country = c.countries_id"
                                         );
       $vendors_data = tep_db_fetch_array($vendors_data_query);

This gives us the numeric country ID (which is what we need to use for the USPS module). Then we can replace SHIPPING_ORIGIN_COUNTRY with $vendors_data[vendor_country]

Let me know if I'm missing/overlooking something.

Joseph

Share this post


Link to post
Share on other sites

Thjat's probably right. I was originally thinking that the module needed the ISO two-character country code, which is what my original code did. It appears that I was wrong; it actually uses the ID number and converts that. My error.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Jim, Craig & Tanaka,

 

I've been working on getting the FREESHIPPER shipping module to work on this, but I'm not having much luck. I think I've made all the changes in Jim's modules.txt, but this simple mod just isn't working. I'm posting here in hopes that someone can take a quick look at it and tell me what I've missed.

 

Also, Craig I know you guys are busy trying to get another release out the door, but have you had a chance to look at the Fedex1 module I sent?

 

Here's the FREESHIPPER module...

<?php
/*
 WebMakers.com Added: Free Payments and Shipping
 Written by Linda McGrath osCOMMERCE@WebMakers.com
 http://www.thewebmakerscorner.com

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

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

// BOF: WebMakers.com Added: Free Payments and Shipping
// class constructor
   function freeshipper() {
     global $order, $cart;
// MVS Added   
     $this->vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id']; 
// EOADD   
     $this->code = 'freeshipper';
     $this->title = MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_FREESHIPPER_TEXT_DESCRIPTION;
     $this->icon = DIR_WS_ICONS . 'shipping_free_shipper.jpg';
// MVS Add/Changed
/*      
  $this->sort_order = MODULE_SHIPPING_FREESHIPPER_SORT_ORDER;
     $this->tax_class = MODULE_SHIPPING_FREESHIPPER_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_FREESHIPPER_STATUS == 'True') ? true : false);

// Only show if weight is 0
//      if ( (!strstr($PHP_SELF,'modules.php')) || $cart->show_weight()==0) {
       $this->enabled = MODULE_SHIPPING_FREESHIPPER_STATUS;
       if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREESHIPPER_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_FREESHIPPER_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;
         }
       }
*/
// EOADD  
//      }
// EOF: WebMakers.com Added: Free Payments and Shipping
   }

// MVS Added	
   function sort_order($vendors_id='0') {
     if (defined (constant ('MODULE_SHIPPING_FREESHIPPER_SORT_ORDER_' . $vendors_id))) {
       $this->sort_order = constant('MODULE_SHIPPING_FREESHIPPER_SORT_ORDER_' . $vendors_id);
     } else {
       $this->sort_order = '0';
     }
     return $this->sort_order;
   }

   function tax_class($vendors_id='1') {
     $this->tax_class = constant('MODULE_SHIPPING_FREESHIPPER_TAX_CLASS_' . $vendors_id);
     return $this->tax_class;
   }

   function enabled($vendors_id='1') {
     $this->enabled = false;
     $status = constant('MODULE_SHIPPING_FREESHIPPER_STATUS_' . $vendors_id);
	 if (isset ($status) && $status != '') {
       $this->enabled = (($status == 'True') ? true : false);
     }
     return $this->enabled;
   }
 
   function zones($vendors_id='1') {
     if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_FREESHIPPER_ZONE_' . $vendors_id) > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_FREESHIPPER_ZONE_' . $vendors_id) . "' 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
       }//while

       if ($check_flag == false) {
         $this->enabled = false;
       }//if
     }//if
     return $this->enabled;
   }//function
// EOADD	
// class methods
// MVS Added/Changed
//    function quote($method = '') {
   function quote($method = '', $module = '', $vendors_id = '1') {
// EOADD
     global $order;
// MVS Added
/*      
  $vendors_data_query = tep_db_query("select handling_charge, 
                                                handling_per_box 
                                         from " . TABLE_VENDORS . " 
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );
     $vendors_data = tep_db_fetch_array($vendors_data_query);
*/
     $vendors_data_query = tep_db_query("select v.vendor_country,
                                          v.vendors_zipcode
                                          from " . TABLE_VENDORS . " v,
                                               " . TABLE_COUNTRIES . " c
                                          where v.vendors_id = '" . (int)$vendors_id . "'
                                          and v.vendor_country = c.countries_id"
                                        );
     $vendors_data = tep_db_fetch_array($vendors_data_query);
     $handling_charge = $vendors_data['handling_charge'];
     $handling_per_box = $vendors_data['handling_per_box'];
     if ($handling_charge > $handling_per_box*$shipping_num_boxes) {
       $handling = $handling_charge;
     } else {
       $handling = $handling_per_box*$shipping_num_boxes;
     }
// EOADD
     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => '<FONT COLOR=FF0000><B>' . MODULE_SHIPPING_FREESHIPPER_TEXT_WAY . '</B></FONT>',
// MVS Added/Changed
//                                                     'cost' => SHIPPING_HANDLING + MODULE_SHIPPING_FREESHIPPER_COST)));
                                                    'cost' => $shipping + $handling)));
// EOADD

     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(/*MVS*/$vendors_id='1') {
     if (!isset($this->_check)) {
// MVS Added/Changed        
//  $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREESHIPPER_STATUS'");
       $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key = 'MODULE_SHIPPING_FREESHIPPER_STATUS_" . $vendors_id . "'");
// EOADD
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

// MVS Added/Changed
/*    
function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable Free Shipping', 'MODULE_SHIPPING_FREESHIPPER_STATUS', '1', 'Do you want to offer Free shipping?', '6', '5', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Free Shipping Cost', 'MODULE_SHIPPING_FREESHIPPER_COST', '0.00', 'What is the Shipping cost? The Handling fee will also be added.', '6', '6', 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_FREESHIPPER_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_FREESHIPPER_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_FREESHIPPER_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
   }
*/	
   function install($vendors_id='1') {
     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Enable Free Shipping', 'MODULE_SHIPPING_FREESHIPPER_STATUS_" . $vendors_id . "', '1', 'Do you want to offer Free shipping?', '6', '5', now(), '" . $vendors_id . "')");
     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Free Shipping Cost', 'MODULE_SHIPPING_FREESHIPPER_COST_" . $vendors_id . "', '0.00', 'What is the Shipping cost? The Handling fee will also be added.', '6', '6', now(), '" . $vendors_id . "')");
     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_FREESHIPPER_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "')");
     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_FREESHIPPER_ZONE_" . $vendors_id . "', '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(), '" . $vendors_id . "')");
     tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_FREESHIPPER_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')");
   }
// EOADD

   function remove(/*MVS*/$vendors_id='1') {
//      $keys = '';
//      $keys_array = $this->keys();
//      for ($i=0; $i<sizeof($keys_array); $i++) {
//        $keys .= "'" . $keys_array[$i] . "',";
//      }
//      $keys = substr($keys, 0, -1);

// MVS Added/Changed
//      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
     tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')");
// EOADD    
}

   function keys(/*MVS*/$vendors_id='1') {
     return array('MODULE_SHIPPING_FREESHIPPER_STATUS' . $vendors_id, 'MODULE_SHIPPING_FREESHIPPER_COST' . $vendors_id, 'MODULE_SHIPPING_FREESHIPPER_TAX_CLASS' . $vendors_id, 'MODULE_SHIPPING_FREESHIPPER_ZONE' . $vendors_id, 'MODULE_SHIPPING_FREESHIPPER_SORT_ORDER' . $vendors_id);
   }
 }
?>

Thanks guys,

Rick Knight

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

×