Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Zone Shipping by State, Ver. 1.0


Skittles

Recommended Posts

Well I tried comma-space anyways and it didnt work still Invalid Zone.

 

I think I am looking more for the solution stated below as one of my zones have two words. Any idea anyone? (or Skittles please help)

 

Did you see my post at the top of this page? It's post:

http://www.oscommerce.com/forums/index.php?sho...t&p=1152740

 

Those square brackets make the string a regular expression which means "any one of the characters in square brackets". To split the string on comma-space you need:

 

$state_zones = split(", ", $state_table); // comma+space NO SQUARE BRACKETS

 

If you have the square brackets, the space inside state names becomes a splitting character, as does every comma. Without brackets, in-state-name-spaces are not recognised as a split. We had "Kuala Lumpur" working just fine with the interstate module as a state name with the code above. Note the the split string has TWO characters inside it, a comma and a space. The split occurs on every occurrence of a comma followed by a space.

Link to comment
Share on other sites

  • Replies 112
  • Created
  • Last Reply

Top Posters In This Topic

Yes, you have to install each zone individually. Maybe someone could write a little piece of SQL to do it copy-and-paste, but there are only 14 states, so it's not that bad. This is how my zones page looks:

 

Country	  Zones	  Code
Malaysia	  Johor	  Johor	   
Malaysia 	Kedah 	Kedah
Malaysia 	Kelantan 	Kelantan
Malaysia 	Kuala Lumpur 	Kuala Lumpur
Malaysia 	Malacca 	Melaka
Malaysia 	Negeri Sembilan 	Negeri Sembilan
Malaysia 	Pahang 	Pahang 
Malaysia 	Penang 	Penang
Malaysia 	Perak 	Perak
Malaysia 	Perlis 	Perlis
Malaysia 	Sabah 	Sabah
Malaysia 	Sarawak 	Sarawak 
Malaysia 	Selangor 	Selangor 
Malaysia 	Terengganu 	Terengganu

 

I don't know what happened to Malacca, seems to work out ok.

 

Yup everything works out fine thanks heaps for the contribution. Melaka is the spelling in malaysia for the state from our country's language. Though in English its called Malacca. Local people usually spell it as the Malay name instead of Malacca.

 

Ive actually created an sql query which people could update their zones table for local. It uses all the states that are categorised from Pos Malaysia. Here it is

#Malaysia states taken from www.pos.com.my
INSERT INTO zones VALUES (NULL,129,'Wilayah Persekutuan','Wilayah Persekutuan');
INSERT INTO zones VALUES (NULL,129,'Selangor','Selangor');
INSERT INTO zones VALUES (NULL,129,'Terengganu','Terengganu');
INSERT INTO zones VALUES (NULL,129,'Sarawak','Sarawak');
INSERT INTO zones VALUES (NULL,129,'Kedah','Kedah');
INSERT INTO zones VALUES (NULL,129,'Kelantan','Kelantan');
INSERT INTO zones VALUES (NULL,129,'Negeri Sembilan','Negeri Sembilan');
INSERT INTO zones VALUES (NULL,129,'Sabah','Sabah');
INSERT INTO zones VALUES (NULL,129,'Pulau Pinang','Pulau Pinang');
INSERT INTO zones VALUES (NULL,129,'Johor','Johor');
INSERT INTO zones VALUES (NULL,129,'Melaka','Melaka');
INSERT INTO zones VALUES (NULL,129,'Perlis','Perlis');
INSERT INTO zones VALUES (NULL,129,'Perak','Perak');
INSERT INTO zones VALUES (NULL,129,'Pahang','Pahang');

 

Note: Values are respective in this order - zone_id, zone_country_id, zone_code, zone_name. Same as in your zones table.

 

The Federal Territory (Malay: Wilayah Persekutuan) is a collective of three territories, namely Kuala Lumpur, Putrajaya and Labuan if your wondering where Kuala Lumpur went.

Link to comment
Share on other sites

Good work on the "Wilayah Persekutuan" potatocake! I wondered what that meant...

 

Your SQL doesn't work for me, or for anybody who might have reloaded their countries table, or changed the format of their zones table. A query that does work for me is this one using a MySQL variable and named insert columns:

 

SELECT @cid:=countries_id from countries where countries_name = 'Malaysia' limit 1;

DELETE FROM zones WHERE zone_country_id = @cid;

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Wilayah Persekutuan','Wilayah Persekutuan');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Selangor','Selangor');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Terengganu','Terengganu');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Sarawak','Sarawak');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Kedah','Kedah');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Kelantan','Kelantan');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Negeri Sembilan','Negeri Sembilan');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Sabah','Sabah');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Pulau Pinang','Pulau Pinang');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Johor','Johor');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Melaka','Melaka');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Perlis','Perlis');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Perak','Perak');

INSERT INTO zones (zone_country_id, zone_code, zone_name) VALUES (@cid,'Pahang','Pahang');

 

I'll update the malaysiastate module to use the new state names. This all exposes a bit of a flaw with hard-coded shipping calculations though: installing an updated module will result in the loss of any local modifications to the zones or rates. I'll try splitting the module into the rating part and a 'require'd rates part that must be renamed on first installation.

Link to comment
Share on other sites

Your SQL doesn't work for me, or for anybody who might have reloaded their countries table, or changed the format of their zones table. A query that does work for me is this one using a MySQL variable and named insert columns:

 

Sorry if it doesnt work for you I was hoping people could elaborate or change the SQL to suit. Because my zones table only displays zones from Malaysia only so Ive actually got a drop table SQL query that drops the table before the inserts of new values in. But I didnt display the drop table query with people who have different zones other than those of malaysia as it would be an inappropriate thing to do. Thanks for updating and correcting me though. :)

 

I'll update the malaysiastate module to use the new state names. This all exposes a bit of a flaw with hard-coded shipping calculations though: installing an updated module will result in the loss of any local modifications to the zones or rates. I'll try splitting the module into the rating part and a 'require'd rates part that must be renamed on first installation.

 

Before you change it to Wilayah Persekutuan you might want to check with your courier company first in the event they separated their costs for the federal territories - KL, Putrajaya, Labuan. Im using this because my shipping is using the domestic PosLaju postal states.

Link to comment
Share on other sites

  • 5 months later...

hi ... im from colombia .. so if u dont understand me , sorry :blink:

 

anyway... i got a problem when im im checkout_shipping.php .... i dont know why say "rate indefined" if i have all correct, i get the state like AM and the rate is 3:7200 ... and the weight of my product is 3 ..i dont know why show the price of shipping $0

 

thanks if somebody or anita can help me.

 

bye bye

Link to comment
Share on other sites

  • 11 months later...

Hello Anita,

 

I have problem but I don't know if it has been answered. I read quickly the previous posts but I didn't find any answer. I have an issue with the weight. Despite the fact that I'm using kilos instead of lbs, it's unaccurate.

 

Here, there are 8 products of 1kg each and are total 8kgs.

http://img39.imageshack.us/img39/5938/picmkh.jpg

 

But why it shows 8.8 ??

I have changed "Package Tare weight" to 0 or 0.00 but nothing happened and in this way the shipping costs are not correct.

 

Any help?

 

Thank you in advance!!!

Link to comment
Share on other sites

Hello Anita,

 

I have problem but I don't know if it has been answered. I read quickly the previous posts but I didn't find any answer. I have an issue with the weight. Despite the fact that I'm using kilos instead of lbs, it's unaccurate.

 

Here, there are 8 products of 1kg each and are total 8kgs.

http://img39.imageshack.us/img39/5938/picmkh.jpg

 

But why it shows 8.8 ??

I have changed "Package Tare weight" to 0 or 0.00 but nothing happened and in this way the shipping costs are not correct.

 

Any help?

 

Thank you in advance!!!

 

OK, I found it.

No worries.

Link to comment
Share on other sites

  • 3 years later...

Hello everyone,

First thank you so much Anita for this great contribution.

I have installed it with some modifications so I would have standard, express, by air shipping options for the selected state. Anyway everything works perfectly.

 

I just only want to add a shipping estimator on product info page or in shopping card page, so my customers would be able to see how much the shipping would be without creating an account or signing in, but just after they input their zip code or select the state from drop down list.

 

Can you help me with this?

 

Thank you in advance. Vartan

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...
  • 7 months later...

Hi Im using ver 1.5 but this seems to be the closest thing to a forum for that so i hope you can help.

 

I have modified this add-on to work for australia which has a bunch of different postal zones per state. As a result I have created a new table within my database that has a list of all australian postcodes and the corresponding postal zone, I've called this aus_postcodes.

 

I have got the actual interstate.php file work fine with this so the correct postage shows up on the checkout_shipping.php page... however...

 

When I select the postage the website does not progress to the next page but instead reloads checkout_shipping.php. I assume that the problem lies within the classes/order.php file as I have added the new postal zone (simply called "zone" in my aus_postcodes table).

 

Do you think I have to add this 'zone' somewhere into this section of orders.php (around line 163):

 

$shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, z.zone_code, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'");

 

and then change this line to reflect the changes as well (around line 262):

 

'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_code']),

 

And if I do have to change it, do you have any idea how i go about it???

 

Or do you think there is a problem somewhere else??

 

Thanks for any help that can be given!!!

Edited by bigbird_3156
Link to comment
Share on other sites

  • 5 years later...

Hello, I just installed and this will solve my problem, however, i am getting the depreciated split function error for line 59 of interstate.php. I have xxxed out the direct path in the error below...Any idea what this could be?

 

Deprecated: Function split() is deprecated in xxxxxxx/includes/modules/shipping/interstate.php on line 59 Warning: Cannot modify header information - headers already sent by (output started at xxxxxx/includes/modules/shipping/interstate.php:59) in xxxxxx /includes/functions/general.php on line 45

 

Thanks!

 

Brad

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