session_start();
$session = session_id();
require_once("../../includes/config.php");
require_once("../script/classes/shoppingcart.php");
require_once("../script/lookups.php");
require_once("../script/Excel/reader.php");
//-----------------------------------------------------------------------
// Initialize Shopping Cart
$cart = new Cart($db);
$contents = $cart->display_contents($session);
$numberOfItems = $cart->num_items($session);
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// USPS Configuration
$USPS_debug = false; // Display the XML response from USPS
$USPS_international = false; // Whether or not to support international shipping
$USPS_url = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
$USPS_username = "593THREA1827";
$USPS_password = "103XM40PO661";
$USPS_domestic_ZipOrigination = "85034";
$USPS_domestic_Service = "Priority";
$USPS_domestic_Container = "Flat Rate Envelope";
$USPS_domestic_Size = "REGULAR";
$USPS_intl_MailType = "Package";
// Calculate Weight
// 1 pound = 16 ounces
$USPS_shirt_ounces = 0;
$USPS_numberOfShirts = 0;
$USPS_numberOfPrints = 0;
$USPS_numberOfAll = 0;
for ($i=0; $i < $numberOfItems; $i++) {
if ($contents['style'][$i] != "NULL" && $contents['color'][$i] != "NULL" && $contents['size'][$i] != "NULL") {
//Item is NOT a print..
$USPS_shirt_ounces += ($contents['quantity'][$i] * ($lookUpWeights[$contents['size'][$i]]));
//Gather some stats
$USPS_numberOfShirts += 1;
$USPS_numberOfAll += 1;
} else {
//Gather some stats
$USPS_numberOfPrints += 1;
$USPS_numberOfAll += 1;
}
}
$USPS_shirt_pounds = floor($USPS_shirt_ounces / 16);
$USPS_shirt_ounces = $USPS_shirt_ounces % 16;
$city = "";
$state= "";
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// This section calculates the shipping information. Interfaces with
// the USPS site via XML.
$validShipping = false; // If this stays false, there will be a "Pending" price on the form, and
// the Checkout button will be unavailable. Instead the $zipError value
// will be displayed in it's place.
$USofA = true;
$zipError = "";
$displayZipCode = "style=\"display:\""; //This is used when a country is selected, it hides the zip code menu on load
$displayButton = "Submit Zip Code"; //This is used if a country is selected, it will be "zip code" with US, and "Country" with
//Every other country...
//Build out the Country selection box, defaulted to the US being selected.
$countryDropDown = "";
foreach($lookUpCountry as $key => $value) {
if ($key == "US") {
$countryDropDown .= "";
} else {
$countryDropDown .= "";
}
}
$sql = "SELECT * FROM accounting_zipcode WHERE session='" . $session . "'";
$zip_result = $db->getRow($sql);
if (is_object($zip_result)) {
// Either a zipcode, or a country is associated with this session..
$shipping_zip = "value='" . $zip_result->zipcode . "'";
if ($USPS_numberOfPrints < $USPS_numberOfAll) {
// A shirt exists in the cart... (not just prints)
if ($zip_result->country == "US") {
//If it's the US, interface with the USPS domestic shipping API using zipcodes
//$shipping_zip = "value='" . $zip_result->zipcode . "'";
//-------------------------------------------------------------------------------------------------------------------
// SHIPPING SECTION
//-------------------------------------------------------------------------------------------------------------------
$data_string = "API=RateV2&XML=";
$data_string .= "";
$data_string .= "" . $USPS_domestic_Service . "";
$data_string .= "" . $USPS_domestic_ZipOrigination . "";
$data_string .= "" . $zip_result->zipcode . "";
$data_string .= "" . $USPS_shirt_pounds . "";
$data_string .= "" . $USPS_shirt_ounces . "";
$data_string .= "" . $USPS_domestic_Container . "";
$data_string .= "" . $USPS_domestic_Size . "";
$data_string .= "";
$data_string .= "";
// Get a CURL handle
$curl_handle = curl_init ();
// Tell CURL the URL of the recipient script
curl_setopt ($curl_handle, CURLOPT_URL, $USPS_url);
// This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
// Perform the POST and get the data returned by the server.
$result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error");
// Close the CURL handle
curl_close ($curl_handle);
if ($USPS_debug) echo "" . htmlentities($result) . "";
if (!ereg("Error", $result)) {
//If there was no error, display the shipping rate.
$split = split("", $result);
$result = split("", $split[1]);
$Shipping_price = $result[0];
$validShipping = true;
} else {
//If an error was encountered, get the error description from the USPS
$split = split("", $result);
$result = split("", $split[1]);
$zipError = "USPS Response: " . $result[0];
$Shipping_price = 0;
}
//-------------------------------------------------------------------------------------------------------------------
// TAX SECTION
//-------------------------------------------------------------------------------------------------------------------
// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('CP1251');
$data->read('../script/taxrates.xls');
error_reporting(E_ALL ^ E_NOTICE);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
$tempData[trim($data->sheets[0]['cells'][$i][2])] = trim($data->sheets[0]['cells'][$i][8]);
}
//print_r($zipLookup);
foreach ($tempData as $zips=>$rate) {
$ziplist = explode(",", $zips);
foreach ($ziplist as $key) {
$zipLookup[trim($key)] = trim($rate);
}
}
/*
print "";
print_r($zipLookup);
print "
";
print "Matching zipcode " . $zip_result->zipcode . " with rate: " . $zipLookup[$zip_result->zipcode] . " ";
print "";
*/
$taxRate = $zipLookup[$zip_result->zipcode];
} else {
//Country was NOT the United States, so interface with the International Shipping
// API from the USPS
$displayZipCode = "style=\"display:none;\"";
$displayButton = "Submit Country";
$USofA = false;
$data_string = "API=IntlRate&XML=";
$data_string .= "";
$data_string .= "" . $USPS_shirt_pounds . "";
$data_string .= "" . $USPS_shirt_ounces . "";
$data_string .= "" . $USPS_intl_MailType . "";
$data_string .= "" . $lookUpCountry[$zip_result->country] . "";
$data_string .= "";
$data_string .= "";
// Get a CURL handle
$curl_handle = curl_init ();
// Tell CURL the URL of the recipient script
curl_setopt ($curl_handle, CURLOPT_URL, $USPS_url);
// This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
// Perform the POST and get the data returned by the server.
$result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error");
// Close the CURL handle
curl_close ($curl_handle);
if ($USPS_debug) echo "" . htmlentities($result) . "";
if (!ereg("Error", $result)) {
//If there was no error, display the shipping rate.
$split = split("", $result);
$result_price = split("", $split[1]);
$Shipping_price = $result_price[0];
$validShipping = true;
} else {
//If an error was encountered, get the error description from the USPS
$split = split("", $result);
$result = split("", $split[1]);
$zipError = "USPS Response: " . $result[0];
$Shipping_price = 0;
}
// Build out the country dropdown, overwrites the default US dropdown..
$countryDropDown = "";
foreach($lookUpCountry as $key => $value) {
if ($key == $zip_result->country) {
$countryDropDown .= "";
} else {
$countryDropDown .= "";
}
}
}
} else {
//The Only items in the cart are prints..
$validShipping = true;
$Shipping_price = 0;
}
} else {
$Shipping_price = 0;
}
//-----------------------------------------------------------------------
?>
Free online source of motorcycle videos, pictures, insurance, and Forums.The Dodge intrepid is a large four-door, full-size, front-wheel drive sedan car model that was produced for model years 1993 to 2004 .The Mazda 323 name appeared for the first time on export models 323f.Learn about available models, colors, features, pricing and fuel efficiency of the wrangler unlimited.The official website of American suzuki cars.Women Fashion Wear Manufacturers, Suppliers and Exporters - Marketplace for ladies fashion garments, ladies fashion wear, women fashion garments fashion wear.New Cars and Used Cars; Direct Ford new fords.Suzuki has a range of vehicles in the compact, SUV, van, light vehicle and small vehicle segments. The Suzuki range includes the Grand suzuki vitara.View the Healthcare finance group company profile on LinkedIn. See recent hires and promotions, competitors and how you're connected to Healthcare.bmw 6 series refers to two generations of automobile from BMW, both being based on their contemporary 5 Series sedans.Read expert reviews of the nissan van.Read reviews of the Mazda protege5.Locate the nearest Chevrolet Car chevy dealerships.Top Searches: • nissan for sale buy nissan.Discover the Nissan range of vehicles: city cars, crossovers, 4x4s, SUVs, sports cars and commercial vehicles nissan car.GadgetMadness is your Review Guide for the Latest new gadget.Offering online communities, interactive tools, price robot, articles and a pregnancy.Time to draw the winner of the Timex iron man health.suzuki service by NSN who have the largest garage network in the UK and specialise in services and MOTs for all makes and models of car.Site of Mercury Cars and SUV's. Build and Price your 2009 Mercury Vehicle. See Special Offers and Incentives mercurys cars.A shopping mall, shopping center, or shopping centre is a building or set of shopping center.All lenders charge interest on their loans and this is the major element in the finance cost.The Web site for toyota center in houston tx.New 2009, 2010 subarus.Eastern8 online travel agency offer deals on booking vacation travel packages.Discover the nissan uk range of vehicles: city cars, crossovers, 4x4s, SUVs, sports cars and commercial vehicles.Welcome to Grand Cherokee UnLimited's zj.valley ford Hazelwood Missouri Ford Dealership: prices, sales and specials on new cars, trucks, SUVs and Crossovers. Pre-owned used cars and trucks.Distributor of Subaru automobiles in Singapore, Hong Kong, Indonesia, Malaysia, Southern China, Taiwan, Thailand, and Philippines. impreza wrx sti.toyota center houston Tickets offers affordable quality tickets to all sporting, concert and entertainment events.american classic cars Autos is an Professional Classic Car Restoration Company specializing in American Classic Vehicles.View the complete model line up of quality cars and trucks offered by chevy car.Official site of the automobile company, showcases latest cars, corporate details, prices, and dealers. hyundai motor.Research Kia cars and all new models at Automotive.com; get free new kia.The 2009 all new nissan Cube Mobile Device is here. Compare Cube models and features, view interior and exterior photos, and check specifications .Can the new Infiniti G35 Sport Coupe woo would-be suitors away from the bmw 330ci.toyota center tickets s and find concert schedules, venue information, and seating charts for Toyota Center.Electronics and gadgets are two words that fit very well together. The electronic gadget.Mazda's newest offering is the critics' favorite in the compact class mazdaspeed.Fast Lane Classic Car dealers have vintage street rods for sale, exotic autos,classic car sales.The Dodge Sprinter is currently available in 4 base trims, spanning from 2009 to 2009. The Dodge sprinter msrp.Welcome to masda global website .The kia carnival is a minivan produced by Kia Motors.Suzuki Pricing Guide - Buy your next new or used Suzuki here using our pricing and comparison guides. suzuki reviews.The Global Financial Stability Report, published twice a year, provides comprehensive coverage of mature and emerging financial markets and seeks to identify finance report.Companies for honda 250cc, Search EC21.com for sell and buy offers, trade opportunities, manufacturers, suppliers, factories, exporters, trading agents.Complete information on 2009 bmw m3 coupe.vintage cars is commonly defined as a car built between the start of 1919 and the end of 1930lot experiment bottom
that beliefs could Export your travel map to any Web page travel map.Find and buy used Dodge srt 4 dealers.2008 Chevrolet TrailBlazer Video chevy truck.Ford F150 need to replace ring & pinion 98 4x4 4.6 xlt.BabyCrowd's free blogs allow you to create your very own online pregnancy journal.Mom and son makeout for Tickets to Nascar race mom son.Office Gadgets on Coolest Gadgets a href=http://gadgettoolls.com/hardware-round-up-hottest-gadgets-of-2008.html rel=dofollow>office gadgets.Offer inbound travel tour.Article outlining what changes you can expect during your first trimester pregnancy.Suzuki's website for ATVs, dealers and newssuzuki.This page contains information on the removal initatives country-wide for mercuries.Used 2005 Dodge Neon srt 4 dealership.Ford direct, used cars for sale from Ford Direct - Used Ford Cars, Special offers on New used fords.The official site of the Harley-Davidson Motor Company. View Harley-Davidson motorcyclesbouya recipe