Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Zone Shipping by State, Ver. 1.0


Skittles

Recommended Posts

Hi Anita,

 

i am very interesting to know if i could use this module for an online shop in Spain, i would like to define different shipping prices depends on weight and Zone (Provinces), I think this module could help me in that,

 

Additionally to that, I would be interesting in finding a developer for installing it,

 

thanks,

 

Miguel

Miguel,

 

In theory, this module should work for any country.

 

A quick look at the zones table in the oscommerce database shows shows the following zones (provinces?):

'A Coruña', 'Alava', 'Albacete', 'Alicante', 'Almeria',
'Asturias', 'Avila', 'Badajoz', 'Baleares', 'Barcelona', 'Burgos',
'Caceres', 'Cadiz', 'Cantabria', 'Castellon', 'Ceuta', 'Ciudad Real', 
'Cordoba', 'Cuenca', 'Girona', 'Granada', 'Guadalajara',
'Guipuzcoa', 'Huelva', 'Huesca', 'Jaen', 'La Rioja', 'Las Palmas',
'Leon', 'Lleida', 'Lugo', 'Madrid', 'Malaga', 'Melilla', 'Murcia', 
'Navarra', 'Ourense', 'Palencia', 'Pontevedra', 'Salamanca', 
'Santa Cruz De Tenerife', 'Segovia', 'Sevilla', 'Soria', 
'Tarragona', 'Teruel', 'Toledo', 'Valencia', 'Valladolid', 'Vizcaya', 
'Zamora', 'Zaragoza',

It does not include any abbreviations for these zones. If there are abbreviations, you should update your table, as using the full names can get a bit ugly in the admin. It isn't functional. If Spain's postal system doesn't use abbreviations, then we'll just have to make do.

 

Specifically, in the Admin, I have the code set to break the list on both semi-colons and spaces, so the list can wrap and keep the column at a reasonable width. However, your zones have several names with spaces as part of the name. That would cause problems, so either the name cannot include the spaces or the code needs to be changed. Changing the code to support the space in the name is not a major issue.

 

Mi Español es muy malo. But if I don't need to undertand Spanish to work on the site, I'd be happy to integrate this into your site. Just send me a PM with your email address (don't post it!) and I'll get back to you.

 

-Skittles

Link to comment
Share on other sites

  • Replies 112
  • Created
  • Last Reply

Top Posters In This Topic

Hi Anita,

 

I got this installed and seemed working, but I notice that when I try to check out, the sub total is $0.00 and the Total is just the shipping charge (when I purchase as an out of state) person.

 

Any ideas what happened or what I may have messed up?

 

Thanks again,

 

Don

I am still stuck on this.

 

Anyone, please.

Thanks,

Don

Just so you all know, Don and I figured this one out via PM. The problem was caused by another mod, not Zone Shipping by State, and we found and fixed the mistake.

 

-Skittles

Edited by Skittles
Link to comment
Share on other sites

Hi Skittles,

Thanks for the great contribution.

I use it in Romania but I have a question.

My setup is the folowing;

Zone 1 - one county

Zone 2 - the rest of the counties.

My shipping fees are something like this:

1$ for the first kilogram and after that add 0.1$ for each kilogram.

This is my exact Zone 1 shipping table: 1:8.33, 2:9.52, 3:10.71, 4:11.90, 5:13.90, 6:14.28, 7:15.47, 8:16.66, 9:17.85 , 10:19.04 , 11:20.23, 12:21.42, 13:22.61, 14:23.8, 15:24.99, 16:26.18, 17:27.37, 18:28.56, 19:29.75, 20:30.94, 21:32.13, 22:33.32, 23:34.51, 24:35.7, 25:36.89, 26:38.08,100:100

 

As you can see I have shipping prices from 1 kilo to 26 kilos. I want to add the rest of the prices up to 100 kilos individually but when I click update it seems to truncate my fees to the maximum length of what is above.

What do I have to chage in order to be able to include the rest of the shipping fees from weights from 26 to 100. So I want to have 100 distinct shipping fees.

Thanks a lot,

Alex

Link to comment
Share on other sites

Hi Skittles,

Thanks for the great contribution.

I use it in Romania but I have a question.

My setup is the folowing;

Zone 1 - one county

Zone 2 - the rest of the counties.

My shipping fees are something like this:

1$ for the first kilogram and after that add 0.1$ for each kilogram.

This is my exact Zone 1 shipping table: 1:8.33, 2:9.52, 3:10.71, 4:11.90, 5:13.90, 6:14.28, 7:15.47, 8:16.66, 9:17.85 , 10:19.04 , 11:20.23, 12:21.42, 13:22.61, 14:23.8, 15:24.99, 16:26.18, 17:27.37, 18:28.56, 19:29.75, 20:30.94, 21:32.13, 22:33.32, 23:34.51, 24:35.7, 25:36.89, 26:38.08,100:100

 

As you can see I have shipping prices from 1 kilo to 26 kilos. I want to add the rest of the prices up to 100 kilos individually but when I click update it seems to truncate my fees to the maximum length of what is above.

What do I have to chage in order to be able to include the rest of the shipping fees from weights from 26 to 100. So I want to have 100 distinct shipping fees.

Thanks a lot,

Alex

Alex,

 

The problem is in the database.

 

The shipping module information is stored in the configuration table of the database. The field that stores the values is a varchar field, which has a maximum length of 256 characters. It may be possible to alter the table, and change that field to a text field. However, I do not know how that would impact your database, or other configuration values stored in the table.

 

Another way to handle it might be to customize the code to look for both the county and the weight, and have four zones for the primary county and four zones for the rest of the counties.

 

Something like this:

$test = ($dest_state == '[primary_county_name_here]')?true:false;
 switch(true) {
case ($test && ($weight <= 25) : $dest_zone = 1; break;
case ($test && ($weight >= 26) && ($weight <= 50)) : $dest_zone = 2; break;
case ($test && ($weight >= 51) && ($weight <= 75)) : $dest_zone = 3; break;
case ($test && ($weight >= 76) && ($weight <= 100)) : $dest_zone = 4; break;
case (!$test && ($weight <= 25) : $dest_zone = 5; break;
case (!$test && ($weight >= 26) && ($weight <= 50)) : $dest_zone = 6; break;
case (!$test && ($weight >= 51) && ($weight <= 75)) : $dest_zone = 7; break;
case (!$test && ($weight >= 76) && ($weight <= 100)) : $dest_zone = 8; break;
 }

Instead of this:

for ($i=1; $i<=$this->num_zones; $i++) {
	$state_table = constant('INTERSTATE_STATES_' . $i);
	$state_zones = split("[ ,]", $state_table);
	if (in_array($dest_state, $state_zones)) {
	  $dest_zone = $i;
	  break;
	}
  }

 

This customization doesn't compare the contents of the States field, so instead of listing the counties in "Zone 1 States" through "Zone 8 States", you could enter a description like "xyz county 25 Kilograms and under." and "xyz county 26 through 50 Kilograms.", etc.

 

It would "hard code" the primary county, but I doubt you'd need to change that very often, if at all.

 

Then enter your shipping weight/cost values accordingly.

 

Do understand that the example code above has not been tested. It's just an idea to get you started.

 

-Skittles

Link to comment
Share on other sites

Hi Skittles,

Thanks for the quick reply.

I'm kind of new to php so my question is: after using the code you gave to me as an example with my primary county inserted ($test = ($dest_state == '[bU]')?true:false;) and the rest as you submited , what else do I have to change/add?

If I upload only with this modification I get a :

Parse error: syntax error, unexpected ':' in /home/alibaba/public_html/abrazive/includes/modules/shipping/interstate.php on line 48

Line 48 is this one: case ($test && ($weight <= 25) : $dest_zone = 1; break;

Any sugestion is highly appreciated :blush: as I'm hoping to have this final issue fixed so I can start the shop.

Have a nice end of the weekend,

Alex

Link to comment
Share on other sites

Hi Skittles,

Thanks for the quick reply.

I'm kind of new to php so my question is: after using the code you gave to me as an example with my primary county inserted ($test = ($dest_state == '[bU]')?true:false;) and the rest as you submited , what else do I have to change/add?

If I upload only with this modification I get a :

Parse error: syntax error, unexpected ':' in /home/alibaba/public_html/abrazive/includes/modules/shipping/interstate.php on line 48

Line 48 is this one: case ($test && ($weight <= 25) : $dest_zone = 1; break;

Any sugestion is highly appreciated :blush: as I'm hoping to have this final issue fixed so I can start the shop.

Have a nice end of the weekend,

Alex

Alex,

 

I just threw that code together as an example. It will probably work, except for that little mistake :-" :

 

On line 48 and line 52, there should be two ')' after the 25...

case ($test && ($weight <= 25)) : $dest_zone = 1; break;
and
case (!$test && ($weight <= 25)) : $dest_zone = 1; break;

 

and you need to remove the square brackets from your county, too:

$test = ($dest_state == 'BU')?true:false;

 

Fix that and see what happens.

 

I'll be waiting for an update!

-Skittles

Link to comment
Share on other sites

that was fast :)

now it works, no more errors.

when I go to edit in the admin section everithing is the same up to: Zone 2 Handling Fee

After the box for Zone 2 Handling Fee now I have 9 new boxes.

Now the questions:

Why 9 and not 8 , one for each case?

Should I fill in each of them the respective fees? i.e in the first on the fee for case ($test && ($weight <= 25) and so on?

Link to comment
Share on other sites

that was fast :)

now it works, no more errors.

when I go to edit in the admin section everithing is the same up to: Zone 2 Handling Fee

After the box for Zone 2 Handling Fee now I have 9 new boxes.

Now the questions:

Why 9 and not 8 , one for each case?

Should I fill in each of them the respective fees? i.e in the first on the fee for case ($test && ($weight <= 25) and so on?

Alex,

 

First, "Remove" the module.

 

Open the file and set the number of zones to 8 (around line 32):

$this->num_zones = 8;

 

Then "Install" the module.

 

You should only have 8 zones, each with three boxes in the admin: States, Shipping Table and Handling Fee.

 

If it still looks wrong after reinstalling it, you'll need to remove all the entries in the database. Let me know if that's the case, and I'll whip up a little script that will do it for you.

 

-Skittles

Link to comment
Share on other sites

Ok, I removed/installed and now I have from 1 up to :

 

Zone 8 States

Zone 8 Shipping Table

Zone 8 Handling Fee

As I understand Zone i States will be the description , something like : BU 25 Kilograms and under, and so on for the rest of them.

 

in the Zone i Shipping Table I will fill in the appropiate shipping values for that set.

Thanks for all your help, it seems to have worked.

I'll insert the values tomorow morning and test to see if everithing works fine.

After I test it I'll tell you what tha outcome was. For now, good night (in Romania it's 00:38 now)

Alex

Link to comment
Share on other sites

I inserted 2 fees for each zone for quick test but I only get the Undefined price message (INTERSTATE_UNDEFINED_RATE) so from what I understand from the code it seems I remain with $shipping = -1 instead of getting the right one.

I see in the code that $shipping is asigned a value inside the : if ($dest_zone == 0) { else ....} do I have to change something there?

Thanks and good night again :) ,

Alex

Edited by alex2k7
Link to comment
Share on other sites

I inserted 2 fees for each zone for quick test but I only get the Undefined price message (INTERSTATE_UNDEFINED_RATE) so from what I understand from the code it seems I remain with $shipping = -1 instead of getting the right one.

I see in the code that $shipping is asigned a value inside the : if ($dest_zone == 0) { else ....} do I have to change something there?

Thanks and good night again :) ,

Alex

Alex,

 

I'll take a more in depth look at the code later today, while your getting your beauty rest. ;)

 

I'll figure out. You just get some sleep.

 

-Skittles

Link to comment
Share on other sites

Good morning,

Any ideas why it's showing 0 shipping cost?

I set for every category some shipping fees but I get shipping price 0 even if the test customer is in the first zone or in the other.

Good morning Alex.

 

I do have an idea...

 

It occurred to me later, after I got some sleep. :)

 

This code looks for the "state", but you want to use the "county".

 

You will need to make changes to the form so that your customers are prompted to include their county instead of state. If Romania doesn't have states, that will work without requiring modification to the order class.

 

However, you need to add the counties to the zones table in the database. Here is an example of the SQL query to add the counties as zones to the zones table:

INSERT INTO `zones` 
VALUES ('', 175, 'BU', 'FullName'),
		('', 175, '', 'FullName'),
		('', 175, '', 'FullName'),
		('', 175, '', 'FullName');

 

You can add as many lines as it takes, just make sure each line has a comma at the end, except for the last line. It needs the semi-colon, as shown above.

 

There are four fields per record. The first field is the zones id and is entered automatically (auto-increment), the second is the country id, which is 175 in my database. You should check your database and make sure Romania is 175 in your database before running the SQL query. Then add the abbreviation and the full name of the county for each county.

 

When you're done, anyone entering the full name for the county will have the abbreviation show up in their address. If that is unacceptable to your postal system, you can put the full name in both fields.

 

It's now time for my beauty rest, so make the updates to your database and test the shipping module. It should be working. If not, post here, and I'll get back to you in the morning. (Monday morning for me.)

 

Talk to you soon,

-Skittles

Link to comment
Share on other sites

One quick question before making the database modifications.

I allready have in my database all the counties with codes/full names. The export of the zones sql table looks like this:

INSERT INTO `zones` VALUES (223, 175, 'BU', 'Bucuresti');

INSERT INTO `zones` VALUES (222, 175, 'CT', 'Constanta');

INSERT INTO `zones` VALUES (221, 175, 'CL', 'Calarasi');

INSERT INTO `zones` VALUES (220, 175, 'IL', 'Ialomita');

INSERT INTO `zones` VALUES (219, 175, 'IL', 'Ilfov');

INSERT INTO `zones` VALUES (218, 175, 'GR', 'Giurgiu');

INSERT INTO `zones` VALUES (217, 175, 'TR', 'Teleorman');

INSERT INTO `zones` VALUES (216, 175, 'OT', 'Olt');

INSERT INTO `zones` VALUES (215, 175, 'DJ', 'Dolj');

INSERT INTO `zones` VALUES (214, 175, 'TL', 'Tulcea');

INSERT INTO `zones` VALUES (213, 175, 'BR', 'Braila');

INSERT INTO `zones` VALUES (212, 175, 'BZ', 'Buzau');

INSERT INTO `zones` VALUES (211, 175, 'PH', 'Prahova');

INSERT INTO `zones` VALUES (210, 175, 'DB', 'Dambovita');

INSERT INTO `zones` VALUES (209, 175, 'AG', 'Arges');

INSERT INTO `zones` VALUES (208, 175, 'VL', 'Valcea');

INSERT INTO `zones` VALUES (207, 175, 'GJ', 'Gorj');

INSERT INTO `zones` VALUES (206, 175, 'MH', 'Mehedinti');

INSERT INTO `zones` VALUES (205, 175, 'CS', 'Caras Severin');

INSERT INTO `zones` VALUES (204, 175, 'GL', 'Galati');

INSERT INTO `zones` VALUES (203, 175, 'VN', 'Vrancea');

INSERT INTO `zones` VALUES (202, 175, 'CV', 'Covasna');

INSERT INTO `zones` VALUES (201, 175, 'BV', 'Brasov');

INSERT INTO `zones` VALUES (200, 175, 'SB', 'Sibiu');

INSERT INTO `zones` VALUES (199, 175, 'AB', 'Alba');

INSERT INTO `zones` VALUES (198, 175, 'HD', 'Hunedoara');

INSERT INTO `zones` VALUES (197, 175, 'AR', 'Arad');

INSERT INTO `zones` VALUES (196, 175, 'TM', 'Timis');

INSERT INTO `zones` VALUES (195, 175, 'VS', 'Vaslui');

INSERT INTO `zones` VALUES (194, 175, 'IS', 'Iasi');

INSERT INTO `zones` VALUES (193, 175, 'BC', 'Bacau');

INSERT INTO `zones` VALUES (192, 175, 'NT', 'Neamt');

INSERT INTO `zones` VALUES (191, 175, 'HR', 'Harghita');

INSERT INTO `zones` VALUES (190, 175, 'MS', 'Mures');

INSERT INTO `zones` VALUES (189, 175, 'CJ', 'Cluj');

INSERT INTO `zones` VALUES (188, 175, 'SJ', 'Salaj');

INSERT INTO `zones` VALUES (187, 175, 'BH', 'Bihor');

INSERT INTO `zones` VALUES (186, 175, 'BT', 'Botosani');

INSERT INTO `zones` VALUES (185, 175, 'SV', 'Suceava');

INSERT INTO `zones` VALUES (184, 175, 'BN', 'Bistrita Nasaud');

INSERT INTO `zones` VALUES (183, 175, 'MM', 'Maramures');

INSERT INTO `zones` VALUES (182, 175, 'SM', 'Satu Mare');

 

When using the default module you made everithing worked fine (only that I could insert only 25 fees/billing zone) so I think something in the last "switch - case" isn't functioning 100% now.

10x again for the patience.

Have a nice week :)

Alex

Link to comment
Share on other sites

One quick question before making the database modifications.

I allready have in my database all the counties with codes/full names.

 

...

 

When using the default module you made everithing worked fine (only that I could insert only 25 fees/billing zone) so I think something in the last "switch - case" isn't functioning 100% now.

10x again for the patience.

Have a nice week :)

Alex

Alex,

 

Okay. Now that I have the counties added to my database, I can do some real testing. I'll get back to you here as soon as I figure out what is going on...

 

-Skittles

Link to comment
Share on other sites

:) you're a life saver

Alex,

 

I found the error. The variable is $shipping_weight, not $weight.

 

I ran into a problem that took a while to figure out. So I want to warn you: Double check your shipping tables. Each entry needs to be 'weight:cost,' For example: 31:15.32,

 

I inadvertently had a period where I should have had a comma, and it threw the values off for that zone. I'm happy to report I didn't pull ALL of my hair out... :'(

 

I am attaching the modified interstate.php file. For testing purposes, the tables have values in them that tell me which zone and what weight. For example, shipping to Zone 5, package weight of 21 kilograms would show a cost of 5.21.

 

You will need to change the values in the Shipping Tables for each zone to the correct values.

 

You will also need to modify the language file to support Romanian and to add the following constant definition (Romanian equivalent, of course):

 

define('INTERSTATE_TEXT_MULTI_PKGS', ' (x %s Pkgs)');

 

The '%s' is where the sprintf function will insert the number of packages.

 

In the Admin Configuration->Shipping/Packaging, you need to set the maximum weight you will ship. I set it to 100 to test.

 

If you set it to 50, every order over 50 will be divided equally into halves, thirds etc so that the packages are never more than 50. Then the shipping for one package will be looked up in the table. That value will be multiplied by the number of boxes.

 

The defined constant above provides an extra bit of text informing the customer how many boxes for the order, but only if there is more than 1 box.

 

I think that takes care of it.

 

Have fun!

-Skittles

interstate.php

Link to comment
Share on other sites

yupi :) 10x a lot. I just corrected the error and everithing looks just as it should.

I don't know why I'm not able to download the test file :( ... it's like you read my mind with the packages, just what I wanted to add.

When you have time can you please e-mail me the test file with the modifications to use multiple packages at ? (my e-mail is adevar at gmail dot com)

Thanks again for all your help , excelent contribution support :thumbsup: ,

Alex

Link to comment
Share on other sites

  • 3 weeks later...
and in the Cat->Inc->Lang->Mod->Ship Interstate1.php I changed it to...

 

Line 23 app.

 

Line 31 app. to

 

lines 111 - 121 app. for the 2 zones...

 

1) for the continental US (USPS Ground)

2) for the other 2 states (USPS Ground [i know that the truck cant physically go to Hawaii])

 

Out side of the phpMyadmin db changes, am I missing anything?

 

Thanks,

Don

 

Don,

 

You're getting close.

 

In the Cat->Inc->Lang->Eng->Mod->Ship Interstate1.php, change it like this:

 

INTERSTATE1_TEXT_TITLE is the title shown in your Admin, in the right column.

INTERSTATE1_TEXT_DESCRIPTION is also shown in the Admin, in the list of modules.

INTERSTATE1_TEXT_SECTION_TITLE is the title, or label, of the service displayed during checkout.

 

In the module, every instance of "interstate" needs to be changed to "interstate1", and every instance of "INTERSTATE" needs to be changed to "INTERSTATE1". Rather than take up a lot of space here, I'm attaching the interstate1.php file already modified for your application.

 

You can use it to guide you when making changes for the other three.

 

-Skittles

 

 

Hello Skittles,

First I would like to thank you for contributing the shipping method. This is exactly what I want for my shipping. However, I am greedy too =P, I would liket to add some more options like 2nd day or next day delivery for my customers to choose. Before I found this thread, I modified your files to "INTERSTATEX" (like your INTERSTATE1) in both langurage and module. And I installed the INTERSTATEX into my shipping module successfully. However, when I go to the website, the INTERSTATEX option didn't show up. Only the original INTERSTATE option there (which I downloaded from your contribution). I don't know what problem is that.

 

Since I cannot download from here, I wounder if you can email your INTERSTATE1.PHP file to me. Maybe I didn't modify your file correctly. My email address is [email protected].

 

Thanks a lot...

 

Fanny

Link to comment
Share on other sites

Hello Skittles,

First I would like to thank you for contributing the shipping method. This is exactly what I want for my shipping. However, I am greedy too =P, I would liket to add some more options like 2nd day or next day delivery for my customers to choose. Before I found this thread, I modified your files to "INTERSTATEX" (like your INTERSTATE1) in both langurage and module. And I installed the INTERSTATEX into my shipping module successfully. However, when I go to the website, the INTERSTATEX option didn't show up. Only the original INTERSTATE option there (which I downloaded from your contribution). I don't know what problem is that.

 

Since I cannot download from here, I wounder if you can email your INTERSTATE1.PHP file to me. Maybe I didn't modify your file correctly. My email address is [email protected].

 

Thanks a lot...

 

Fanny

Hi Fanny,

 

Sorry to take so long to reply. I seem to be having trouble getting my notices.

 

I'm just shutting things down for the night, and I decided to take a quick peek at threads where I'm active simply because I haven't gotten a notification all day. And Oops, here you are.

 

I'll send you an email tomorrow.

 

Cheers.

-Skittles

Link to comment
Share on other sites

Hi Fanny,

 

Sorry to take so long to reply. I seem to be having trouble getting my notices.

 

I'm just shutting things down for the night, and I decided to take a quick peek at threads where I'm active simply because I haven't gotten a notification all day. And Oops, here you are.

 

I'll send you an email tomorrow.

 

Cheers.

-Skittles

 

Hello Skittles,

 

Thank you for replying me. However, I haven't got your email yet. I hope I didn't accidently delete it because I probably get more than 50 junk mails everyday. Most of time, I just delete all the emails from people I don't know. I am not sure if I had deleted yours. If you sent the email to me already, could you please re-send it again? If not, could you please drop me a line here and let me know what's the subject after you send the email out, so I will pay attention on it...

Thank you again and sorry to bring you so much inconvenience....

 

Fanny

Link to comment
Share on other sites

Hello Skittles,

 

Thank you for replying me. However, I haven't got your email yet. I hope I didn't accidently delete it because I probably get more than 50 junk mails everyday. Most of time, I just delete all the emails from people I don't know. I am not sure if I had deleted yours. If you sent the email to me already, could you please re-send it again? If not, could you please drop me a line here and let me know what's the subject after you send the email out, so I will pay attention on it...

Thank you again and sorry to bring you so much inconvenience....

 

Fanny

Hi Fanny,

 

I originally sent the email on the 13th. I just re-sent it, without any changes.

 

The subject is "osCommerce shipping module" and it is coming from my gmail account.

 

If you have trouble receiving it, due to the attachment, I can make other arrangements.

 

-Skittles

Link to comment
Share on other sites

Hi Fanny,

 

I originally sent the email on the 13th. I just re-sent it, without any changes.

 

The subject is "osCommerce shipping module" and it is coming from my gmail account.

 

If you have trouble receiving it, due to the attachment, I can make other arrangements.

 

-Skittles

 

 

Got it... I will try it tonight... Thank you soooooooooooooooo much.... :)

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