Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

State Based Region Shipping Rates


billythekid

Recommended Posts

I love this contribution but it doesn't seem to calculate correctly using the weight option for me.

 

I'm setup like this:

Region 1 States/Countries

Alaska,Hawaii

 

Region 1 Shipping Table

2:10.95,4:12.95,6:18.95,10000:27.95

 

I put one product in my cart with a products_weight of 0.45 and checkout to the state of Alaska.

 

Since this is less than 2, I would expect the shipping to be $10.95. However, it appears as $12.95. Is there some packaging default weight being added somewhere?

Link to comment
Share on other sites

No, that wasn't it but I think I figured it out.

 

In admin>config>shipping/packaging there is a "Package Tare weight" which is used to add in the weight of packing materials. I assumed that it was adding it once to each order but I think (from trial and error) that it actually adds it once per item.

 

So if an example order had 2 items: 1 lb, and 2 lbs and the Package Tare weight was set to 1.5 lb then the total weight becomes:

1 lb.

+1.5 lb. (package tare)

+2 lbs

+1.5 lb. (package tare)

_______

6 lbs.

Link to comment
Share on other sites

Thank you for a great solution to my problem.

 

Why does my database only allow for 255 maximum value for the max_box_weight field? If I could just enter like 5000 this would work. But at 255 it doubles the shipping price on a 400 lb item when I have 150 - 400 lbs is set as the same price. Or if I could get the number of boxes not to effect the shipping price that would work too, since it does not show the number of boxes to the customer.

Link to comment
Share on other sites

  • 2 weeks later...

I have installed this contribution, and it does exactly what I want, except for one thing.

 

I need to apply tax to one of the shipping zones (Canada), but the option is not there. I have read through the thread, and it seems to be an option that others need as well.

 

Is there an easy way to add this?? This is the only thing holding me back from going live.

 

Thanks

 

Chris

Link to comment
Share on other sites

Hi all,

 

I am looking to use this region module for a table of express shipping and another table of standard shipping. I have tried renaming functions/constants but for some reason the module does not show up on the listing.

 

Can anyone post a short howto on how to get mulitple copies of the region stuff working?

 

Thanks

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

First off really nice work. The only thing is I need to change the cost from a flat rate to a percentage or at least the ability to use a mulitplier. (i can play with the decimal points). I've seen the contribution for percentages which would be perfect, but I need your Zones for states configuration also. Can anyone help me modify this to meet those parameters? I've made a couple attempts, but i'm not completely understanding the use of the vars here, so I keep making things worse. At one point I had a freight charge of 1500.00 for 120.00 item... hmmm don't think the customers would go for that.

Really hope someone is smarter than I on this one. :unsure:

 

Thanks

Link to comment
Share on other sites

Well after many hours of beating my head against a wall :blink: I finally got the contribution to give me a percentage of sales based within the proper zone. If anyone else needs it, it really was a simple change (figures - lol)

 

if ((MODULE_SHIPPING_REGIONS_MODE == 'price') || (MODULE_SHIPPING_REGIONS_MODE == 'weight')) {

for ($i=0; $i<sizeof($regions_table); $i+=2) {

if ($order_total_price <= $regions_table[$i]) {

$shipping = ($order_total_price * ($regions_table[$i+1] /100));

$shipping_method = MODULE_SHIPPING_REGIONS_TEXT_WAY . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS;

break;

 

 

 

Now if I can just figure out how to create a flat charge for a minimum, I would be home free. Hope this info helps anyone else out there, and if anyone can help me with the flat charge minimum, I would be ohhhh so greatful.

 

Thanks

 

Ruth in AZ

Link to comment
Share on other sites

I have run across the same issue as some others and am wondering if anyone has figured out a solution for using this module for multiple types of shipping (overnight, 3-day, ground).

 

I have copied the two files and changes names to newname_regions, and then changed all instances of MODULE_SHIPPING_REGIONS becomes MODULE_SHIPPING_EXPRESS_REGIONS and regions becomes express_regions.

 

The modules all display correctly on checkout_shipping.php but when you choose the Express module and hit continue it takes you to checkout_shipping.php again, not to checkout_payment.php like it should.

 

Any help is greatly appreciated!!!

Link to comment
Share on other sites

Solved previous post - solution is to use names that do not include underscores.

 

For instance instead of MODULE_SHIPPING_EXPRESS_REGIONS use MODULE_SHIPPING_EXPRESSREGIONS.

For whatever reason, the code gets confused in the array if underscores are used.

 

I have this working with three different types of shipping (ground, three day, and

overnight). Here are examples for each of the variables I used without underscores

to get this to work. Also I noticed that the

 

In addition, the class and function names must be in lowercase. I was not able

to install the modules when they were in caps.

 

Example for variables:

ground - MODULE_SHIPPING_REGIONS_STATUS

three day - MODULE_SHIPPING_THREEDAYREGIONS_STATUS

overnight - MODULE_SHIPPING_NEXTDAYREGIONS_STATUS

 

Hope this helps!

Link to comment
Share on other sites

Katie, did any of your shipping methods require a "minimum' fee? I'm still stuck. I managed to change the zones to compute with percentages (see earlier post here), but I need to be able to charge a fee of 6.50 if order_total is <75.00USD for all zones I've tried every combination I can think of and it keeps erroring out on me.

 

Thanks

 

Ruth in AZ

Link to comment
Share on other sites

  • 2 weeks later...

started a new thread but has no replies, so i'm trying my luck here.

 

i have some questions about shipping mod "shipping by region"

 

it seems like it wouldnt recognize country codes such as SG, HK, US, CA.... how can i modify it to recog country codes. i do not need state codes.... thanks!

 

Due to some decisions made by store owner, i needed to use 4 shipping mods together... I am also using flat, zone and zonesworld.... i would like "region" country recognising power to behave like zone and zonesworld...

 

can someone point me in the right direction?

thanks

zwen

Link to comment
Share on other sites

  • 2 weeks later...

Hey I would like to know would this Modules work for way to pull out the shipping Price by putting in First 3 Digits of ZIP CODE and the price wound be in % and they can select there shipping handily like for Ground or rush shipping.

If so how wound I set this up to do this?

 

EXAMPLES: Lite say that a preson buy a merchandise it price is $250.00 that go to the Checkout page and the select a state that they live be Denver that is Zone 7 Flat Freight is 23% the Rate is $57.50 the Total price is $307.50.

 

How wound i go and setup this in my Files?

Link to comment
Share on other sites

  • 1 month later...

Hi all,

 

I found this contribution to be very useful - but unfortunately

due to the search on these boards it took me quite a few hours

to find it :huh:

 

I have made a couple of modifications to this contrib that judging

by the posts some of you may find helpful. Credit for the original code

should go to Jorge Suarez.

 

The modifications allow you to:

 

Set a Tax/VAT rate for the shipping cost

Set a Maximum shipping weight

Fix Icon location

Display the weight at checkout in line with other shipping modules

 

 

I have copied out the file below - the changes have been made to the:

catalog/includes/modules/shipping/regions.php file only

 

<?php

/*

 $Id: regions.php, v 1.0 2002/12/15 14:29:56 Jorge Exp $

 Based upon zones.php by wilt, written for:

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2002 osCommerce
 Released under the GNU General Public License

 -----------------------------------------------------------------------------
 REGIONS -  Rates Based on State or Regions (group of States) module for osC 2.2-CVS (new checkout)
  
 This module allows you create shipping regions by dividing states of the USA (or other country) in different groups. Each group will then have it's own shipping price which you can based on price or weight. 

 This module is perfect when for those of you need to charge different when shipping to different parts of the country.

 Features
 1..Regions can be composed of US States or of any other country
 2..Order weight or price can be used to calculate shipping price.
 3..Any number of regions
 4..Handling fee can be added.

 Jorge
 
 Set the number of regions you need with
 $this->regions = xx;  

 Please note that any country / state that is not in one of the groups
 will not be able to checkout if this the only shipping you provide.
 However it will display a nice message saying so.



 Written by Jorge ([email protected])

*/

 class regions {
   var $code, $title, $description, $enabled, $regions;

// class constructor
   function regions() {
     $this->code = 'regions';
     $this->title = MODULE_SHIPPING_REGIONS_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_REGIONS_TEXT_DESCRIPTION;
     $this->icon = DIR_WS_ICONS . 'shipping_amtrak.gif';
     $this->tax_class = MODULE_SHIPPING_REGIONS_TAX_CLASS;
     $this->enabled = MODULE_SHIPPING_REGIONS_STATUS;
     // CUSTOMIZE THIS SETTING FOR THE NUMBER OF States NEEDED
     $this->regions = 5;
   }

// class methods
   function quote($method = '') {
     global $order, $shipping_weight, $cart, $total_count;
     
     if (MODULE_SHIPPING_REGIONS_MODE == 'price') {
       $order_total_price = $cart->show_total();
     } 
     if (MODULE_SHIPPING_REGIONS_MODE == 'weight') {
       $order_total_price = $shipping_weight;
     }
     if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') {
       $order_total_price = $total_count;
     }      

     $dest_state = $order->delivery['state'];
     $dest_country = $order->delivery['country']['title'];
     
     $dest_region = 0;
     $error = false;

     for ($i=1; $i<=$this->regions; $i++) {
       $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i);
       $country_states_or_countries = split("[,]", $regions_table);
       if (in_array($dest_state, $country_states_or_countries)) {
         $dest_region = $i;
         break;
       }
     }
     if ($dest_region == 0) {
      for ($i=1; $i<=$this->regions; $i++) {
        $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i);
        $country_states_or_countries = split("[,]", $regions_table);
        if (in_array($dest_country, $country_states_or_countries)) {
          $dest_region = $i;
          break;
        }
      }
     }

     if ($dest_region == 0) {
       $error = true;
     } else {
       $shipping = -1;
       $region_cost = constant('MODULE_SHIPPING_REGIONS_COST' . $i);

       $regions_table = split("[:,]" , $region_cost);

       if ((MODULE_SHIPPING_REGIONS_MODE == 'price') || (MODULE_SHIPPING_REGIONS_MODE == 'weight')) {
        for ($i=0; $i<sizeof($regions_table); $i+=2) {
          if ($order_total_price <= $regions_table[$i]) {
            $shipping = $regions_table[$i+1];
//Modified line below to show shipping weight at checkout
            $shipping_method = MODULE_SHIPPING_REGIONS_TEXT_WAY . ' ' . "$dest_state, $dest_country: $shipping_weight" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS;
                             
            break;
          }
        }
       }
       if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') {
   $shipping = $regions_table[1] * $order_total_price;
             $shipping_method = MODULE_SHIPPING_REGIONS_ITEM . ' ' . $total_count . ' ' . MODULE_SHIPPING_REGIONS_ITEMS . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS;
   }        
       
       
       if ($shipping == -1) {
         $shipping_cost = 0;
         $shipping_method = MODULE_SHIPPING_REGIONS_UNDEFINED_RATE;
       } else {
         $shipping_cost = ($shipping + MODULE_SHIPPING_REGIONS_HANDLING + SHIPPING_HANDLING);
       }
     }

//Modification for maximum weight      
     
     $order_total = $shipping_weight;
 //change the number 40 to whatever maximum weight limit you want
 if ($order_total >= 40) {
 $error = 'over';
     } else {

 $this->quotes = array('id' => $this->code,
               //change the module name below to reflect the shipping module
                           'module' => MODULE_SHIPPING_REGIONS_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                   'title' => $shipping_method,
                                                   'cost'=> $shipping_cost)));
}

//end of maximum weight


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

     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);

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

    if ($error =='over') $this->quotes['error'] = 'Service Unavailable At This Weight';

     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_REGIONS_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 US Regions Method', 'MODULE_SHIPPING_REGIONS_STATUS', '1', 'Do you want to offer Regions 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_REGIONS_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_REGIONS_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, set_function, date_added) values ('Mode', 'MODULE_SHIPPING_REGIONS_MODE', 'weight', 'Is the shipping table based on total Weight or Total amount of order.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'per_item\'), ', now())");
     for ($i = 1; $i <= $this->regions; $i++) {
       $default_countries = '';
       if ($i == 1) {
         $default_states_or_countries = 'California';
         $default_prices = '30:8.95,75:10.95,150:16.95,400:21.95,10000:25.95';
       }
       if ($i == 2) {
         $default_states_or_countries = 'Alabama,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,M
aine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana';
         $default_prices = '30:10.95,75:12.95,150:18.95,400:23.95,10000:27.95';
       }
       if ($i == 3) {
         $default_states_or_countries = 'Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming';
         $default_prices = '30:10.95,75:12.95,150:18.95,400:23.95,10000:27.95';
       }
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Region " . $i ." States/Countries', 'MODULE_SHIPPING_REGIONS" . $i ."', '" . $default_states_or_countries . "', 'Comma separated list of States and/or Countries', '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 ('Region " . $i ." Shipping Table', 'MODULE_SHIPPING_REGIONS_COST" . $i ."', '" . $default_prices . "' , 'Example: 3:8.50,7:10.50.....(weight/price)<b>:</b>(shipping cost)', '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_REGIONS_STATUS', 'MODULE_SHIPPING_REGIONS_HANDLING', 'MODULE_SHIPPING_REGIONS_TAX_CLASS', 'MODULE_SHIPPING_REGIONS_MODE');

     for ($i=1; $i<=$this->regions; $i++) {
       $keys[] = 'MODULE_SHIPPING_REGIONS' . $i;
       $keys[] = 'MODULE_SHIPPING_REGIONS_COST' . $i;
     }

     return $keys;
   }
 }
?>

 

 

*** Please if you are going to upload the above then backup your original shipping

files and values first as these will be lost when you reinstall the above. ***

All the usual disclaimers - use at your own risk etc blah, blah.

I have indicated in the code above the changes made but you will notice that

after reinstalling there will be a selection to choose a tax rate if required.

 

Hope the above is helpful - it might be worth adding the changes to the next

update of the contrib :unsure:

 

Cheers

 

Steve

Link to comment
Share on other sites

dear billythekid,

dear all

 

Sorry to ask the same question but i cannot figure out why the module do not work(my fault for sure) with my own defined regions.

 

In the region1 I define region Plovdiv and then the rates.

 

The same way are defined the zones in my dbase.

If I put a comma it shows me only the Country (Bulgaria).

 

Please help!

http://www.vremeto.org - Weather in Stambolijski, 4210, BG
Link to comment
Share on other sites

  • 1 month later...

hi

 

to accepts 100 countries in one of the regions, i have read you have to change the mySQL structure in myphpadmin.

 

But which field should i change? a tad confused.

 

 

any help would be amazing.

 

regards

Link to comment
Share on other sites

  • 4 weeks later...

Regions.php it's excelent but I have a doubt.

 

When you confirm your order we receive the following mesage:

 

" Your Order Has Been Processed!

 

Your order has been successfully processed! Your products will arrive at their destination within 2-5 working days. "

 

 

How can I setup the time to delivery? 2-5 to "10-15" or "3 weeks - 5 weeks"

 

Regards

Link to comment
Share on other sites

  • 2 months later...

good contribution.

 

i have installed it. it works well. But i have a new question about it.

 

can i add a defualt regions for all undefined counties?

 

for example:

1, US 5.00

2, Canada, Hiiwa 10.00

3, All others countries. 20.00

 

Can it be done?

 

please let me know if anyone have good idea .thanks a lot

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...