Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php question - postcode ranges

Options
  • 28-09-2006 9:23am
    #1
    Registered Users Posts: 648 ✭✭✭


    Hi
    im creating a little shopping app in php mysql where the user enters thier postcode and the price is calculated depending on this. (search the poscode table which is linked to the shipping zone table where i find the cost)

    in the backend the admin will be able to specify the shipping zones and several ranges of postal code for these zones..
    i was thinking of having a postcode table and letting the admin use a multiple select box to select ranges for that zone.... but there are soo many of them 9000+

    therefore my question.. if i allow the admin to specify ranges in the backend eg
    2500-4000,5800-7000
    then how would the search work on the front end? for example if the user enters a postcode of 2598 what sort of logic would i use to find what zone that is in?

    any help appreciated!
    Tnx


Comments

  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Best shipping is calculated by product weight. This way you can go wrong using courier or standard Post Office.
    I was in the same position few month back, and by weight and also volume weight was the easiest and best option.


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    louie wrote:
    Best shipping is calculated by product weight. This way you can go wrong using courier or standard Post Office.
    I was in the same position few month back, and by weight and also volume weight was the easiest and best option.

    Hi louie

    what happens when you gotta send the same package to england and australia??

    i see where your comming from but YES i am calculating by weight also but different geographic area have different prices per Kilo!!


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Hi louie

    what happens when you gotta send the same package to england and australia??

    i see where your comming from but YES i am calculating by weight also but different geographic area have different prices per Kilo!!

    Would setting up some more general zones be easier?

    e.g.
    Zone 1: Ireland
    Zone 2: UK
    Zone 3: Rest of Europe
    Zone 4: US
    .....
    Zone 10: Asia

    etc


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    eoin_s wrote:
    Would setting up some more general zones be easier?

    e.g.
    Zone 1: Ireland
    Zone 2: UK
    Zone 3: Rest of Europe
    Zone 4: US
    .....
    Zone 10: Asia

    etc


    Hi
    thing is its only for one country Australia

    and the zones will be within Australia

    eg
    SYDNEY (2500-2750,4000-6200)
    BRISBANE (0200-1250,1666-1950)
    etc etc

    the postal code are given in brackets after


    what i need to do is get the zone (eg SYDNEY) when the user inputs a postal code (eg 2600).

    ANy ideas?

    TNX


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    The way I have it myself is based on the customer input.
    On the shopping cart I am asking him to select a region is from, Ireland, UK, ... you get the drift.

    In the database I have all those fileds like this:

    Location: Ireland
    MinWeight: 0
    MaxWeight: 5
    ShipCost: 4.99
    ::::::::::
    then next
    ::::::::::
    Location: Ireland
    MinWeight: 5.01
    MaxWeight: 10
    ShipCost: 9.99
    :::::::::::::::
    Based on the customer selection i get the shipping cost from the database which have to match all the 3 fields required.
    Location from the select menu, weight from the shopping cart settings based on the products that the buyer has.

    You can also do this after the customer register.


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    What about the above solution replacing the Ireland or Uk to your post codes?


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    louie wrote:
    What about the above solution replacing the Ireland or Uk to your post codes?


    BUT THERE ARE 9000+ POST CODES :eek:

    your solution is a simple solution to a simple problem.. mine is a little more complex



    what i want to do is have a db table like this (where user can specify PC ranges for each zone)

    ZONE RANGES COST PER KILO
    Sydney 2500-2600,3000-3500 0.44
    Brisbane 3500-4600,5000-5500 0.55



    the on the front end the user inputs 2551 for example.... so how do i get the cost per kilo (in php)?

    Tnx


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    You can change the location like this:

    locationFrom: 1000
    LocationTo: 2000
    MinWeight: 0
    MaxWeight: 5
    Cost: 0.99

    then have a field asking to enter the post code
    <input type="text" name="postcode" />

    on submit comapre the value from that to the database and get the cost

    sSql = "select * from shipping_tbl where LocationFrom <= postcode and LocationTo >= postcode and MinWeight <= cart_weigth and MaxWeight >= cart_weight"


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    your solution is a simple solution to a simple problem.. mine is a little more complex

    I don't think so. It appears that you are just over-complicating the problem for yourself. An Post aren't going to charge you based on the postcode in Australia. They simply have four zones and a rate for each zone.


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    Serbian wrote:
    I don't think so. It appears that you are just over-complicating the problem for yourself. An Post aren't going to charge you based on the postcode in Australia. They simply have four zones and a rate for each zone.


    Hi, who said i was talking about An Post?

    I'm talking about sending parcels internally within australia .. nothing what so ever to do with ireland and an post.

    Tnx


  • Advertisement
  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Hi, who said i was talking about An Post?

    I'm talking about sending parcels internally within australia .. nothing what so ever to do with ireland and an post.

    Tnx

    Rightly or wrongly, people may assume that it is an Irish based operation given that this is an Irish site.

    I am not sure I see what the problem is. There is a spreadsheet that you can download with all the Australian Post codes, and their associated regions. I presume you have the prices for each range of post codes, so you have all the information you need for the database.

    Your table will have the start range and end range, so all you have to do is run an SQL query that will return a row where the inputted postal code is greater than the start range, and less than the end range?


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    Hi, who said i was talking about An Post?

    Fair enough, though you didn't mention anything to do with Australia in your original post. Do you really need to go right down to the postcode level however? Can you not group post codes by state and set postage costs that way?


  • Closed Accounts Posts: 119 ✭✭frodo_dcu


    louie wrote:
    You can change the location like this:

    locationFrom: 1000
    LocationTo: 2000
    MinWeight: 0
    MaxWeight: 5
    Cost: 0.99

    then have a field asking to enter the post code
    <input type="text" name="postcode" />

    on submit comapre the value from that to the database and get the cost

    sSql = "select * from shipping_tbl where LocationFrom <= postcode and LocationTo >= postcode and MinWeight <= cart_weigth and MaxWeight >= cart_weight"

    This should be your exact soloution if not i think you still haven't given us all the details on you probem


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    Serbian wrote:
    Fair enough, though you didn't mention anything to do with Australia in your original post. Do you really need to go right down to the postcode level however? Can you not group post codes by state and set postage costs that way?

    Hi
    i did mention syndey and brisbane .. sorry should have made more explicit.

    What i was looking for initially was a way the client could enter thier postcode ranges into one field of the zone(or state) table like i said above (2500-2750,4000-6200) . however my problem was how would those be searched from the frontend.

    however after you guys feedback i think the best way is to create another postcoderange table where we can specify min and max values (and these be tied to the zone(or state) table
    (seems like best and only way to do this)

    Thanks all


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Hi
    i did mention syndey and brisbane .. sorry should have made more explicit.

    What i was looking for initially was a way the client could enter thier postcode ranges into one field of the zone(or state) table like i said above (2500-2750,4000-6200) . however my problem was how would those be searched from the frontend.

    however after you guys feedback i think the best way is to create another postcoderange table where we can specify min and max values (and these be tied to the zone(or state) table
    (seems like best and only way to do this)

    Thanks all

    Ah, so you wanted to display a shipping price before the form was submitted?

    AJAX is probably as close as you'll get to that.


Advertisement