View Single Post
  #279  
Old 05-23-2008, 10:33 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Pre-Login Shipping Calculator

I wasn't sure if I should post this here or start a new thread but here it is. Moderators please move if necessary. I have this solution to show rates for FedEx on the prelogin calculator. As far as I can tell it works. Attached is a sql file to create and populated a table with the zip codes for USA. Please note that the info in this file is 4-5 years old but for the purpose of getting zip code and appropriate state works fine. Also here is the code for the shipping calculator that goes into cart.php

PHP Code:
# prelogin calculator start
# modified by cart-lab.com to allow US and CA zipcodes
x_session_register("zipcode_estimate"); 
$trusted_post_variables = array("zip_estimate");
require 
$xcart_dir."/include/states.php";
if(
$HTTP_GET_VARS['zip_estimate'] == "clear"){ 
$zipcode_estimate ""
func_header_location("cart.php"); 

 
if(!empty(
$zip_estimate)){ 
$zipcode_estimate $zip_estimate
$count strlen($zipcode_estimate);
if(
$count 4){ //checking length 
$zipcode_estimate "";

func_header_location("cart.php"); 

if(
$zipcode_estimate != ""){ 
$customer_temp_state func_query_first_cell("SELECT state_abbr FROM `zip_codes` WHERE zip_code='$zipcode_estimate'");
$count strlen($zipcode_estimate);
if(
$count == 5) { 
$config["General"]["default_country"] = "US";
$config["General"]["default_state"] = $customer_temp_state;
$config["General"]["default_zipcode"] = $zipcode_estimate
$config["General"]["apply_default_country"] = "Y";
$userinfo["s_country"] = "US";
$userinfo["s_state"] = $customer_temp_state;
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO"); 
} else {
$config["General"]["apply_default_country"] = "Y"
$config["General"]["default_country"] = "CA";
$config["General"]["apply_default_state"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate
$userinfo["s_country"] = "CA";
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO"); 
}

# prelogin calculator end 

This is for USA only as I do not ship to Canada so I was not looking for a solution for Canada.
Turns out I can attached only 512K so I split the file.
Attached Files
File Type: zip zip_codes_1.zip (322.8 KB, 152 views)
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote