Page 1 of 1

need help adding shipping to total using a drop down menu

Posted: Fri Aug 13, 2004 11:43 am
by mikewooten
i am creating a checkout page and it needs to have the shipping information added to the total.
how do you add the shipping information to the total using a dropdown menu for the shipping information.
does anyone know how to do that? or maybe something similar to what amazon has.
site that i'm working on is:
http://www.wootenmedia.com/wootenmusic8
if you need any code, let me know
thanks

need help adding shipping to total using a drop down menu

Posted: Sat Aug 14, 2004 9:38 am
by mikewooten
does anyone know how to add the shipping information to the total using a dropdown menu

Posted: Sat Aug 14, 2004 10:03 am
by feyd

Code: Select all

var obj = document.formsї'your_form_name'].elementsї'your_dropdown_name'];
var value = obj.optionsїobj.selectedIndex].value
value would now contain the currently selected item's value from that dropdown... that is if you want to do it on that page.. that code should probably be part of a function that you run as an onchange event from the select. Or you can have the select submit, with an update request to the server.. then you just add the pricing information together and redisplay the page.

Posted: Sat Aug 14, 2004 10:45 am
by mikewooten
if i had the select submit, how would i get teh update request from the server.?
then if i just added the pricing and shipping information together. would it be something like this?

$c = $total + $shipping;

also would i have to use a database to store any shipping information to redisplay back on the page?

thanks

Posted: Sat Aug 14, 2004 10:53 am
by feyd
in the past, I've set a hidden form field to tell the server I want to update the shipping choice.. the server processes the new shipping information, and redisplays the page.

it's a good idea to store the pricing information on the server and use that as an authority for knowing the pricing, as someone may try to cheat and tell your script to send in a price that isn't the real one..

Posted: Sat Aug 14, 2004 11:30 am
by mikewooten
how would i store the pricing information on the server? would i have to store the information in a mysql database. would i have to store the pricing and the regions and type of shipping like fedex and ups or just pricing?
thanks

Posted: Sat Aug 14, 2004 11:34 am
by feyd
the best way to handle it is probably through their individual shipping cost calculators, however they do that. If you can get ahold of that information would be best. Otherwise, you'll need to store the relationship of pricing for each type of shipper and prices from wherever the stuff ships from, plus many other things like VAT, or tarrif taxes and customs charges.. all kinds of nonsense..

Posted: Sat Aug 14, 2004 11:45 am
by mikewooten
do you know if this is a good website for a shipping calculator?

http://www.usps.com/tools/calculatepost ... atepostage

if not, then where do you suggest that i go to get information about shipping cost calculators?
thanks

Posted: Sat Aug 14, 2004 11:54 am
by feyd
I'd write them, asking for permission to use their calculator in an automated fashion. Then use [php_man]curl[/php_man] to interact with their sites' calculation forms.. If you don't get permission, then you may have to figure some calculating tables.. for which I can't help.

Posted: Sun Aug 15, 2004 12:53 pm
by mikewooten
i've been researching and would i need any or all of these scripts that i have found or is there a much more simple way to do all of this?
these are shipping calculators and mail zone scripts i have found.
http://www.phpbuilder.com/snippet/down ... pet&id=576- ups shipping calculator
http://www.phpbuilder.com/snippet/down ... pet&id=578 - fedex shipping calculator
http://www.phpbuilder.com/snippet/deta ... pet&id=785- Calculate Priority Mail Shipping Cost
http://www.phpbuilder.com/snippet/down ... et&id=1206 - Get Priority Mail Zone from Zip Code


if i do need these scripts, how would i use them with what i have to do, and how would i get all of that to work with the total?
thanks
[/url]

Posted: Sun Aug 15, 2004 10:48 pm
by feyd
you can probably compact them into a single script. But that's something you should probably do on your own..