Log in

View Full Version : Help with courier company delivery cost estimate



liam_ie
12-23-2011, 10:05 PM
Ok, first time posting here and could do with some pointers please.

looking for a script that will help potential customers get a price estimate on a courier company website. what im thinking of is something the lines of:

if i choose
Zone 1 to Zone 1 = 4.00
Zone 1 to Zone 2 = 6.00
Zone 5 to Zone 2 = 10.00
Zone 2 to Zone 5 = 10.00
Zone 2 to Zone 1 = 6.00

and so on....so what ever combination of zones are chosen it gives a price for delivering from and to the chosen zones. hope this is straight forword and someone can help or point me in the right direction.

thanks.

djr33
12-23-2011, 10:49 PM
Are you looking for the math behind it? Or are you looking for how you could display this? How do you want it to interact with the user?
Will this be using Javascript, or would you like it to be a serverside language (like PHP) with a database?

Also, you can do something like this, probably, but it will be very difficult to make it completely accurate. If this is JUST an estimate, that's fine. But if this is a final price, you should be very careful or you might sometimes get the wrong amount, if the math is at all complicated.

liam_ie
12-24-2011, 11:06 PM
Hey djr33, thanks for the reply.

when it come to this sort of thing im a complete novice, bacically im looking for something similar to the "Quick Quote" on http://www.onceoffdeliveries.ie but a simplefied version.

Where i can set the price of a delivery from say, zone 1 to zone 2, when the customer selects these zones they get a price for the delivery.

as a novice is this something that can be easily done?

djr33
12-24-2011, 11:57 PM
I think I understand what you're looking for, but please answer the specific questions I asked above. That will help me/us understand enough to give you some suggestions.

From what you've said, it sounds like your prices are fixed between zones? There isn't any more complicated math than that? It's just "Zone x to Zone y = $50" without exceptions? If that's the case, the math is easier. Then the question is how you want the script to work, whether you just are looking for Javascript that will display information or PHP (or another serverside language) that's a little more complicated but can interact with a database and store information on the server about the order.


As a complete guess (let me know if this is wrong), all you might need is a Javascript script that will display a number value when two items are selected from dropdowns. This will JUST be a preview, but it will relate to the charges applied later. That should not be too hard, but it's probably something you'd want to hire someone for unless you want to learn how to do it. It's not very difficult, but it does involve understanding some not-so-basic aspects of Javascript. We can point you in the right direction if you want to do that, though.

liam_ie
12-26-2011, 12:54 AM
hi djr33,

You have hit the nail on the head, fixed pricing between zones but with the option of parcel size(small, medium, large). Yes a javascript is really all that i need i think. Im sorry if i was explaining it backwards. if you could point me in the right direction i wouldn't mind learning and giving it a go.

Happy Christmas
Liam

djr33
12-26-2011, 05:19 AM
Here are some things to look into. Once you understand how the pieces work, you'll just need to put them together.

element.value will give you the current value of a form input. For example:
document.getElementById('fromzone').value
<select id="fromzone" name="fromzone">..........</select>

<element onchange="Javascript Here;"> will execute Javascript when the value is changed.

So, I recommend adding an onchange event to each dropdown menu (you're not sure which they will set first, or you might be able to just do it on the second). Then get the value of both dropdowns (see .value above), using document.getElementById and this.value

Then once you have those two, you can put them in a function.


<script type="text/javascript">
function getcost(zone1,zone2) {
if (zone1==1&&zone2==2) { return 10; }
....
if (zone1==5&&zone2==6) { return 50; }
}

Of course there are many ways to setup a function like that. One way would be to use an array. But using lots of "ifs" will work and it's probably the easiest.