Version: 1.0
Type: Function
Category: Shopping Carts
License: BSD License
Description: Simple program that will calculate a UPS shipping rate for any of UPS’s shipping types.
function getUPSprice ($shipType,$sendZipcode,$recieveZipcode,$recieveCountry,$weight) { $tmp = "AppVersion=1.2&AcceptUPSLicenseAgreement=yes&ResponseType=application/x-ups-rss&ActionCode=3". "&RateChart=Regular+Daily+Pickup&DCISInd=0&SNDestinationInd1=0&SNDestinationInd2=0&ResidentialInd=0&PackagingType=00". "&ServiceLevelCode=$shipType&ShipperPostalCode=".substr($sendZipcode, 0, 5)."&ConsigneePostalCode=". substr($recieveZipcode, 0, 5). "&ConsigneeCountry=$recieveCountry&PackageActualWeight=$weight&DeclaredValueInsurance=0nr"; $request = "POST /using/services/rave/qcost_dss.cgi HTTP/1.0nContent-type: application/x-www-form-urlencodednContent-length: " . strlen($tmp) . "nn" . $tmp; $this->socket = fsockopen("www.ups.com", 80); fputs($this->socket, $request); strtok(fread ($this->socket, 4096), "%"); for ($i = 0; $i < 12 ;$i++) $price = strtok("%"); fclose($this->socket); return($price); }