Jump to content


  • Content count

  • Joined

  • Last visited

Posts posted by sean4u

  1. I realise this is an ancient post but it comes up high in searches for "oscommerce uk shipping" - so here I am.


    We have a little osCommerce shop which moved from Malaysia to the UK recently. I wrote some shipping modules for it years ago which now offer some Royal Mail Airmail International quotes, along with 1st,2nd,Standard etc local parcels and some newer shipping outfits like myHermes and Collect+. Because it's based on an API hosted elsewhere, you need only install a single shipping module (there's one available for ZenCart too) for all the available shipping methods. The shipping module shows in the checkout only those shipping methods suitable for the origin+destination and the weight. You can further restrict the module to your preferred methods in your osCommerce admin panel.


    The available shipping methods can be tested here:




    Shipping modules are here:




    and API (if you want to roll your own) is here:




    ... it's all free and likely to remain that way unless I get lots of users and then I may try to charge a few quid for heavy users - lightweight use will always be free or prospective users won't be able to test it. Some feedback would be nice.

  2. Thanks! It work!... Now a new prob..


    Its says .."Unable to obtain a Pos Malaysia Air Parcel quote. Please inform the store owner."

    The modules do print some helpful messages to your site’s error log. If you can read your error log, that may tell you what is going wrong. Alternatively (and it’s not ideal for a production site) you can edit includes/modules/shipping/posmyair.php and remove the ‘@’ signs from the front of the network functions (stream_context_create, fopen, stream_get_contents). If the problem is with them, you may see error messages printed to your checkout page. You could also check whether your host is PHPv4 or v5, and adjust the setting in the shipping module's admin panel appropriately.


    There might be some useful info available at any of these places:




    For your malaysiastate problems you mentioned in the PM:

    http://forums.oscommerce.com/index.php?sho...39938&st=80 (malaysiastate discussion starts at bottom of page and continues on next page)


    Oh and make sure you read the README included in the zipfile - there's a chance you don't have Malaysian states set up.


    Hope this helps

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

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



    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.

  5. Thanks Sean for the contribution. Trying to install it atm, in your readme file you said:


    Make sure your Malaysian states are setup in Admin..Locations/Taxes..Zones


    Do I have to add each insert each zones individually to make it work? as it just currently displays:


    Country Zone

    Malaysia All Zones


    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.

  6. I finally figured out how to do this. Sorry I should have read more closely.




    I tried this and got the value Kuala Lumpur. This is stored the same as the zone_code in the database. Is it due to the spaces?


    There's an issue with the interstate code (there should be a post a couple of pages back!) with splitting the string of state names, you can fix it by choosing to split on comma-space, rather than comma, if I recall correctly. I said ages ago I'd have a go at a zoned module myself, and a problem on a site of mine that occurred yesterday pushed me into editing! There's a route through the interstate code that allows a checkout to continue without shipping being added. In my case, I'd forgotten to add one of the Malaysian states to the default_states string, so the module returned 'invalid zone', but no error. I'm not sure whether it's a feature of the original code, or whether I introduced it myself with a careless edit. I can check, if it helps.


    So anyway, I wrote a module that doesn't save the rates to the DB. Since part of configuring interstate requires editing the code, I thought I might as well go the whole hog and just leave the rates right in the code. It should be trivial to change the code for any zoned shipping calculation. If you're happy to use a text editor to update your zone rates, this might be a reasonable alternative. The resulting code is a little bit simpler.


    You can download the module from the contributions page at lolyco.com, it's called malaysiastate.zip

  7. Just wonder anyone install this module? I have tried, but this does not populate as one of the option in the buyer shipping section.

    It only quotes for international deliveries. Was your test buyer located in the same country as your shop? This is by far the most common 'problem' reported for the module. I had to search for this thread to know that you had a problem - if you want quicker help, try replying to the news article at Lolyco.com about the shipping modules we originated:


    Hope this helps.

  8. Skittles & Sean


    Thought I would give you an update. I corrected the '}' problem and uploaded the files again. Worked this time without any errors - thanks. Only one thing, I have already on the 'select shipping' method a 'UPS Ground' which uses the State name to determine costs by zones. If I activate the interstate shipping method, which I wanted to use for UPS 2nd day air shipping, it prevents the 'ground' option from appearing. Could I change the interstate to accept state names, instead of the abbreviation and leave the order.php file as is, or would that totally screw things up? Or is that not the reason I'm not seeing the first option?



    Hello ADW - I'm sorry, you've got me this time! Did you try changing the 'sort order' of the shipping modules, or checking the error output from your web server?

  9. Aaaarrgghhh my eyes! No indentation... still, thanks to the wonders of gvim and its ability to select a block of code based on open and close curly brackets, I see you've misplaced a 'close curly bracket' after the $i==6 option you've added. It seems you've added it to the bottom of the file (there are 3 in a row, should only be two) to make the brackets add up right, but that encloses the keys() function inside the install() function, so it can't be accessed by other code.


    I hope that helps! See code fragment below.




    Here is my interstate.php file - Is it correct?


    Sorry I don't know how to copy the line numbers.





    $Id: Interstate.php


    if ($i == 5) {

    $default_states = 'MA, RI, NH, VT, ME, MN, SD, NE, TX, CO, NM';

    $default_rates = '1:15.30,2:18.10,3:20.80,4:23.60,5:26.40';


    if ($i == 6) {

    $default_states = 'ND, MT, WY, ID, UT, AZ, NV, CA, WA';

    $default_rates = '1:16.10,2:18.40,3:21.20,4:24.20,5:27.40';


    *_*_*_*_*_*_* NO CLOSE BRACKET !!!!!!!!! *_*_*_*_*_*_*_*_


    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." States', 'INTERSTATE_STATES_" . $i ."', '" . $default_states . "', 'Comma separated list of two character ISO State codes that are part of Zone " . $i . ".', '6', '0', now())");


    return $keys;



    } *_*_*_*_*_*_* DELETE ONE OF THESE THREE BRACKETS AT END OF FILE *_*_*_*_*_*_*_*_*

  10. Sean,

    I uploaded the original modules.php and still got the error.

    Here is line 152:


    $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'");


    The error appears when I try to install via admin.




    Hello Andy, sorry, I'm not a PHP programmer, so I should have read the code more carefully. The keys() function appears 4 lines higher in modules.php, where it is assigned to $module_keys. Maybe PHP does some sort of lazy assignment? I'll RTFM, that would be useful to know. Anyway, I think that the error must be caused by the keys() function being missing from your interstate module. In my original copy of the interstate.php file, that function's at line 144 (in includes/modules/shipping). It's the last thing in the file, so it should be easy to see whether it's there or not. Maybe it's worth trying the rename-and-copy-original test with that one.

  11. Fatal error: Call to undefined function: keys() in /home/serescom/public_html/admin/modules.php on line 152


    You could try renaming that file (to something like modules.php.old) and copying in a good version from the archive you originally downloaded from oscommerce.com


    Alternatively, you could post line 152 and we could have a go at repairing it - it might not be the only broken line though! Did you edit modules.php?

  12. Hi all, I was just checking the code - I had the 'Invalid region' problem (not sure I've got the error message right). It was caused by a region with a space in its name. In includes/modules/shipping/interstate.php, you use a split() function with a "[ ,]" split sequence. That's a regular expression that means split on 'either space or comma'. The square brackets mean 'any 1 of the characters inside'. Because the zones are contained in single strings, there's no way for the split function to know the difference between an in-zone-name space and a between-zone-names space, so my 'two parts' zone was being split into 'two' and 'parts'.


    The easy fix (I used) is to make sure that the list of zone names will be separated by a comma+space separator, and change the split statement to:

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


    An alternative would be to separate the list of zone names by comma only, and use:

    $state_zones = split(",", $state_table); //comma only


    Hope this helps. This module is exactly what I've been wasting the last few hours trying to bend the 'Zone shipping' into. I spotted a few more changes I'd like to make to it, if I ever get round to it, I'll post them here!


    Thanks for contributing!


  13. I just downloaded the contrib and at first it looked great, but then a couple of issues emerged.


    2. The breadcrumb trail is messed up, I get NAVBAR_TITLE


    Adding the NAVBAR title define() to includes/languages/english/news.php wasn't enough to fix this issue for me, I had to change the order of 2 lines in /news.php:


    /* swap order of lines...

    $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_NEWS, '', 'SSL'));



    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_NEWS);

    $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_NEWS, '', 'SSL'));



    And that did it.


    Anybody else find the 'Edit' button on the admin panel confusing? I changed it to 'Save'.