Canadian Instructions for Jayk
This allows for the 6 character Canadian Postal Codes in format (xxxxxx).
This also enables shipping from US to Canada in X-Cart.
Note: I only have UPS Standard to Canada enabled with this, although you should be able to apply the same technique for all Canadian methods....
Once again, this is for 4.1.8 using fast lane checkout.
HERE WE GO!
In cart.php After:
Code:
x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("anonymous_checkout");
x_session_register("payment_cc_fields");
x_session_register("current_carrier","UPS");
Insert:
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 = substr_count($zipcode_estimate,"0") + substr_count($zipcode_estimate,"1") + substr_count($zipcode_estimate,"2") + substr_count($zipcode_estimate,"3") + substr_count($zipcode_estimate,"4") + substr_count($zipcode_estimate,"5") + substr_count($zipcode_estimate,"6") + substr_count($zipcode_estimate,"7") + substr_count($zipcode_estimate,"8") + substr_count($zipcode_estimate,"9");
$count = strlen($zipcode_estimate);
if($count < 4){ //checking for 5 digits
$zipcode_estimate = "";}
func_header_location("cart.php");
}
if($zipcode_estimate != ""){
$count = strlen($zipcode_estimate);
if($count == 5) {
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
} else {
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_country"] = "CA";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$userinfo["s_country"] = "CA";
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}
}
# prelogin calculator end
Copy the entire contents of skin1/customer/main/cart_totals.tpl
Highlight the entire contents of skin1/modules/Fast_Lane_Checkout/cart_subtotal.tpl and paste the contents of cart_totals.tpl over it.
(The contents of cart_subtotal.tpl is merely a stripped out version of cart_totals.tpl taking out the very thing we all want)
Now in the newly completely changed skin1/modules/Fast_Lane_Checkout/cart_subtotal.tpl place:
Code:
{* BCSE Begin *}
{if $login}
{else}
{if $estimate ne "NO"}
<br><b>Enter your zip code below to calculate shipping charges. </b><p><b>Enter Zip Code </b>
<input type=TEXT name='zip_estimate' size=6 maxlength=6>
{include file="buttons/button.tpl" button_title="Click Here To Calculate Shipping" href="javascript: document.cartform.submit()" js_to_href="Y"}
{else} <p><a href="cart.php?zip_estimate=clear">Click here to change your zip code</a> ({$userinfo.s_zipcode})
{/if}
<BR><BR>
{/if}
{* BCSE End *}
Just before:
Code:
{if $not_logged_message eq "1"}
{$lng.txt_order_total_msg}{/if}
In modules/UPS_OnLine_Tools/config.php
On line 83 change:
Code:
"11" => array("US" => 14, "EU" => 14, "CA" => 14, "PL" => 14),
To:
Code:
"11" => array("US" => 11, "EU" => 14, "CA" => 14, "PL" => 14),
In shipping mod_UPS.php
Starting at line 519
Find Code:
Code:
if ($sv["service_code"] == $ups_services[$mod_UPS_service][$origin_code]) {
if ($sv["service_code"] == "14" && $origin_code == "US" && $dest_code == "CA")
$subcode = 110; // UPS Standard to Canada
Replace with code:
Code:
if ($sv["service_code"] == $ups_services[$mod_UPS_service][$origin_code]) {
if ($sv["service_code"] == "11" && $origin_code == "US" && $dest_code == "CA")
$subcode = 110; // UPS Standard to Canada
Using phpMyAdmin:
Open your X-Cart database
Open xcart_shipping
Click Browse
Find shipping ID 110
Click the pencil to edit
Change service_code from 100 to 11
Finally, in languages, make a label "lbl_calc_title". It should say something like this "Order - Shipping Calculator"
In skin1/modules/Fast_Lane_Checkout/cart_subtotal.tpl find all occurences (3) of {$lng.lbl_delivery} and replace them with {$lng.lbl_calc_title}
If customer is logged in, Taxes will show on the cart/calculator page and this mod appears to not affect the checkout process at all.
YOUR DONE!!!!