Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fedex Zone Contrib version 2.0 ready


wasson65

Recommended Posts

  • 4 months later...
  • Replies 145
  • Created
  • Last Reply

Top Posters In This Topic

I installed this module ver 2.2 (dated 10 Nov 04) but when I go to the shipping page, I just get 0.00 for the rate and none of the FedEx shipping methods are displayed.  Any ideas how to fix this would be great.

 

I'm having the same problem; I just get 0.00 for the rate and none of the FedEx shipping methods are displayed. Did you happen to figure it out? Can you help?

MurphyDM722

Link to comment
Share on other sites

Well, I got some things working and changed, but I'm not a PHP programmer, so I don't know if what I did is correct, but I did get the rates to show up.

 

I changed this line (approx line 113):

	foreach( $retArr as $aquote );

 

to:

	foreach( $retArr as $aquote){

 

by removing the semicolon, it allowed the foreach loop to actually loop through each item.

 

I also changed (approx line 116):

  $title = $aquote['shiptype_id'];

 

to:

 

  $title = $aquote['shiptype_name'];

 

which allowed for the Name to showup on the checkout page, rather than the ID

 

I made some additional changes to allow for corrected rounding (approx line 124) from:

   	 ' (' . $shipping_num_boxes . ' x ' . round($shipping_weight, 1) . ' ' . MODULE_SHIPPING_FEDEXZIPZONES_TEXT_UNITS .')' ,

 

to:

   	 ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_FEDEXZIPZONES_TEXT_UNITS .')' ,

 

 

 

Now, most of this works, my only problem comes when I have a shipping address other than US or CA, I get the following error:

 

Warning: Invalid argument supplied for foreach() in /home/soma/WWW/catalog/includes/modules/shipping/fedexzipzones.php on line 110

 

I understand that this module does not support International shipping, but I have UPS and USPS modules installed that do, so it should just show the UPS and USPS options for International, and not even list FedEx. So, I do not know why I am getting the error, so if anyone knows why I get this error, that would be great.

 

 

Since I am using other modules other than just the FedEx, I wanted the option to be able to sort the shipping methods, and this module did not support sorting, so I added the code to allow me to do the sorting, so if you're interested, I can also post those additons.

Link to comment
Share on other sites

  • 2 weeks later...
Well, I got some things working and changed, but I'm not a PHP programmer, so I don't know if what I did is correct, but I did get the rates to show up.

 

I changed this line (approx line 113):

	foreach( $retArr as $aquote );

 

to:

	foreach( $retArr as $aquote){

 

by removing the semicolon, it allowed the foreach loop to actually loop through each item.

 

I also changed (approx line 116):

 ?$title = $aquote['shiptype_id'];

 

to:

 

 ?$title = $aquote['shiptype_name'];

 

which allowed for the Name to showup on the checkout page, rather than the ID

 

I made some additional changes to allow for corrected rounding (approx line 124) from:

 ? ?	' (' . $shipping_num_boxes . ' x ' . round($shipping_weight, 1) . ' ' . MODULE_SHIPPING_FEDEXZIPZONES_TEXT_UNITS .')' ,

 

to:

 ? ?	' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_FEDEXZIPZONES_TEXT_UNITS .')' ,

Now, most of this works, my only problem comes when I have a shipping address other than US or CA, I get the following error:

 

Warning: Invalid argument supplied for foreach() in /home/soma/WWW/catalog/includes/modules/shipping/fedexzipzones.php on line 110

 

I understand that this module does not support International shipping, but I have UPS and USPS modules installed that do, so it should just show the UPS and USPS options for International, and not even list FedEx.  So, I do not know why I am getting the error, so if anyone knows why I get this error, that would be great.

Since I am using other modules other than just the FedEx, I wanted the option to be able to sort the shipping methods, and this module did not support sorting, so I added the code to allow me to do the sorting, so if you're interested, I can also post those additons.

 

I made these changes, but still get $0.00 for the shipping cost when I try and checkout.

 

Any idea?

 

--Adam

Link to comment
Share on other sites

Well, if you have a file comparison program, like Beyond Compare, you can compare your version with my complete file:

 

<?php
/*


 Released under the GNU General Public License

*/

 class fedexzipzones {
   var $code, $title, $description, $enabled, $num_zones, $surcharge_factor;

// class constructor:w

   function fedexzipzones() {
     $this->code = 'fedexzipzones';
     $this->title = MODULE_SHIPPING_FEDEXZIPZONES_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_FEDEXZIPZONES_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_FEDEX_SORT_ORDER;
     $this->icon = DIR_WS_ICONS . 'shipping_fedex.gif';
     $this->enabled = MODULE_SHIPPING_FEDEXZIPZONES_STATUS;

     // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
     $this->num_zones = 1;

     $this->types = array(
      	 'FedEx Standard Overnight' => 'std',
	 'FedEx Priority Overnight' => 'pri',
	 'FedEx Ground'             => 'gnd',
	 //'FedEx First Overnight'    => 'frs',
	 'FedEx Express Saver'      => 'sav',
	 'FedEx 2Day'               => 'two',
	 );

     // change this surcharge factor to cover the gas surcharge from fedex, or to bury packaging costs
     $this->surcharge_factor = 2;
   }

// class methods

   function quote($method = '')
{

     global $order, $shipping_weight, $shipping_num_boxes;

     $rounded_weight = ceil($shipping_weight);

     // Tim's new code to read the db and come up with a value.

     // first get the dest zip and check the db for our dest zone
     $zip = $order->delivery['postcode'];
     if ( $zip == '' ){
    	 // something is wrong, we didn't find any zone
 $this->quotes['error'] = MODULE_SHIPPING_FEDEXZIPZONES_NO_ZIPCODE_FOUND;
    	 return $this->quotes;
     }

     $sql = "SELECT *
       FROM fedex_pcode_to_zone_xref
 WHERE
	 $zip >= pcode_from and
	 $zip <= pcode_to";
     $qResult = tep_db_query($sql); // run the query
     $rec = tep_db_fetch_array($qResult); // get the first row of the result

     $zone_id = $rec['zone_id'];

     if ( $zone_id == '' ){
    	 // something is wrong, we didn't find any zone
 $this->quotes['error'] = MODULE_SHIPPING_FEDEXZIPZONES_NO_ZONE_FOUND;
    	 return $this->quotes;
     }
     $sql = "SELECT
      	 fedex_zone_rates.shiptype_id,
	 fedex_shiptype.shiptype_name,
	 fedex_zones.zone_name,
	 fedex_zone_rates.zonerate_id,
	 fedex_zone_rates.zone_cost
       FROM
	 fedex_zone_rates,
	 fedex_zones,
	 fedex_shiptype
 WHERE
	 ";

if ($method != ''){
 // they asked for a particular method, let's give that to them
 foreach($this->types as $key=>$type){
	 if ($type == $method){
   break; // we found the right one.
	 }
 }
 // limit the query to the specific method listed
 $sql .= "fedex_shiptype.shiptype_name = '$key' AND ";

}

$sql .=
	 "fedex_zone_rates.zone_id = fedex_zones.zone_id and
	 fedex_zone_rates.shiptype_id = fedex_shiptype.shiptype_id and
	 fedex_zone_rates.weight = $rounded_weight and
	 fedex_zone_rates.zone_id = $zone_id
 ORDER BY
	 fedex_zone_rates.zone_cost";
     $qResult = tep_db_query($sql); // run the query

     while($rec = tep_db_fetch_array($qResult)) {
       $retArr[] = $rec;
     }

foreach( $retArr as $aquote){
 $cost = $aquote['zone_cost'];
 $title = $aquote['shiptype_name'];
 $methods[] = array(
   'id' => $this->types[$title],
   'title' => $title,
   'cost' => (round(($cost * $this->surcharge_factor * $shipping_num_boxes),2)) + ' . MODULE_SHIPPING_FEDEXZIPZONES_HANDLING .');
}
     $this->quotes = array('id' => $this->code,
        	 'module' => MODULE_SHIPPING_FEDEXZIPZONES_TEXT_TITLE .
  	 ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_FEDEXZIPZONES_TEXT_UNITS .')' ,
                            #'module' => MODULE_SHIPPING_FEDEXZIPZONES_TEXT_TITLE,
                         'methods' => $methods);
     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
     if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_FEDEXZIPZONES_INVALID_ZONE;
     return $this->quotes;
   }

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

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Enable Fedex Zipcode Zones Method', 'MODULE_SHIPPING_FEDEXZIPZONES_STATUS', '1', 'Do you want to offer fedex zip zone rate shipping?', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_FEDEXZIPZONES_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, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_FEDEX_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
     for ($i = 1; $i <= $this->num_zones; $i++) {
       $default_countries = '';
       if ($i == 1) {
         $default_countries = 'US,CA';
       }
 #      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Fedex Zone " . $i ." Countries', 'MODULE_SHIPPING_FEDEXZIPZONES_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', now())");
  #     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Fedex Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_FEDEXZIPZONES_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " 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 " . $i . " destinations.', '6', '0', now())");
     }
   }

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

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
   }

   function keys() {
     $keys = array('MODULE_SHIPPING_FEDEXZIPZONES_STATUS', 'MODULE_SHIPPING_FEDEXZIPZONES_HANDLING','MODULE_SHIPPING_FEDEX_SORT_ORDER');

     for ($i=1; $i<=$this->num_zones; $i++) {
       $keys[] = 'MODULE_SHIPPING_FEDEXZIPZONES_COUNTRIES_' . $i;
       $keys[] = 'MODULE_SHIPPING_FEDEXZIPZONES_COST_' . $i;
     }

     return $keys;
   }
 }
?>

 

Hope this helps

Link to comment
Share on other sites

I just installed the latest version of this contrib and included the upgraded file by dlpuma and it works great EXCEPT that all my shipping rates are too high.

 

After researching I discovered that although most shippers don't use a Zone 1 and begin local shipping with Zone 2, the buildfedexdata.php builds rate tables begining with Zone 1 and populates the tables with the 'rate.csv which all begin with Zone 2. Therefore each zone is using the rates for the next higher zone.

 

-Mike

Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...

Right now, I am actually working on the contribution to see what I can do to fix it again. I realized since the last time I've updated some people are having problems, if I can get it fixed, I'll keep you updated and try and bring this contribution back again.

Installed Contributions: AJAX Menu, AJAX Attributed Manager, AP URL ReWriting, Credit Class and Gift Vouchers, CCGV Report, Date of Birth PullDown, FCKEditor for Product Desc., Monthly Installment Payments, More Pictures 6, MSRP Savings, Must Agree to Terms on Checkout, Order Editor, Payment Method Fee, PopUp Promo, Private Messages, Purchase Order, Purchase Order Application, Secure Admin Login-Logout, STS Plus, SugarCRM Integration, Supertracker, Tax Exempt and Organization Discounts, Your Recent History.

 

23 Total Contributions Installed :)

Link to comment
Share on other sites

Hi all,

 

I have released a v3.0 for this contribution.

 

Enhancements

- Contribution should be working now;

- Supports both FedEx zones in Alaska, Puerto Rico and Hawaii now;

- 2005 FedEx US rates;

- Many new admin variables to update tables more easily such as

a) Fuel surcharges;

b) Free ground shipping option;

c) Individual service surcharges;

d) Bundling of packages;

e) FedEx discounts;

Changes

- Some structural changes in database tables;

- Clean up old codes;

- Renamed import files to FedEx default naming so that its easy to know when the rates are based;

- Heavy revised install.txt to install.html

Bug Fixes

- Corrected multiple similiar zone codes during rates retrieval;

- Corrected $0 problem;

- Corrected buildfedexdata.php

 

All feedback welcomed. Enjoy!

- The Jackal

Link to comment
Share on other sites

Hi all,

 

I have released a v3.0 for this contribution.

 

 

Hi Jackal,

 

Could you check your contribution? I copies the files in v3.0 over an existing one, uninstalled and installed this one under admin. Only problem is the only button I found was 'Cancel.'

 

Thanks,

Mark

Link to comment
Share on other sites

Something is not right. I have tested it on the fresh copy of OSC2.2MS2.

 

Try the following checks:

1. Did you copy the languages file?

2. Try to 'install' again.

 

Let me know.

- The Jackal

Link to comment
Share on other sites

  • 2 weeks later...

I just can't get FedEx to show up. I know the docs say sort order is buggy, but I've tried most of the values from 0 to 10 and nothing is working. Sometimes it even screws up my "flat rate shipping" display.

 

On my admin page, I've got:

 

Flat Rate: 1

USPS : 2

Federal Express : 3

 

On the checkout page, I get:

Flat Rate: $5.00

USPS:

EXPRESS: $22.05

Priority : $5.75

 

...and that's it. I'm running a modified MS2.2; it's got QTPro, the USPS Method, thumbnailing and some other small contributions.

 

I've even tried setting them all to Sort Order = 0. Anybody got some help for me?

If this were easy, everybody would do it.

Link to comment
Share on other sites

  • 2 weeks later...
Have you fixed the problem with Alaska, Hawaii and Puerto Rico. I would like to be able to ship to at least Alaska and Hawaii. I had to delete them to get contribution to work.

Yeap. It has been fixed in the latest version. It supports both 2 different zones rates for Ground and Express now.

- The Jackal

Link to comment
Share on other sites

Nice job TheJackal, I feel terrible that everybody requested it and I didn't ever get time to finish it, thanks for getting it done, and I must say, I'm definitely feelin' what a wonderful job you've done. Great job again.

Installed Contributions: AJAX Menu, AJAX Attributed Manager, AP URL ReWriting, Credit Class and Gift Vouchers, CCGV Report, Date of Birth PullDown, FCKEditor for Product Desc., Monthly Installment Payments, More Pictures 6, MSRP Savings, Must Agree to Terms on Checkout, Order Editor, Payment Method Fee, PopUp Promo, Private Messages, Purchase Order, Purchase Order Application, Secure Admin Login-Logout, STS Plus, SugarCRM Integration, Supertracker, Tax Exempt and Organization Discounts, Your Recent History.

 

23 Total Contributions Installed :)

Link to comment
Share on other sites

I feel embarassed ... coz I am merely building on your contribution and everyone else before ..and very much doing it for myself actually. And don't feel terrible, coz everyone benefitted from it, and you provided a platform for others to build upon.

 

Besides, I have benefitted tremendously from this community and I gathered this is a great opportunity to give back in my own little way. :)

- The Jackal

Link to comment
Share on other sites

  • 1 month later...

Hi everyone,

 

There have been some substantial increase in fuel surcharges due to the recent high oil prices.

As of Oct 2005, its 3.5% for Ground, 15.5% for Express.

 

Please update your rates accordingly in the Admin panel. See http://fedex.com/cgi-bin/fuelsurcharge.cgi...anguage=english.

- The Jackal

Link to comment
Share on other sites

  • 4 weeks later...

I installed this module yesterday and all seems to work ok with one small problem.

I do not get all of the shipping options when I order.

 

Shipping Method FedEX

 

This is currently the only shipping method available to use on this order.

Federal Express

Home Delivery $4.28

Express Saver - 3 days $10.28

2nd Day $10.86

Standard Overnight - by 3PM $21.08

Priority Overnight $25.70

First Overnight $54.57

 

As you can see I have no ground, and there may be others missing. According to the instructions I have everything active. Any ideas?

 

Any help would be greatly appriciated.

 

CM

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...