Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Pre-Login Shipping Calculator

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #261  
Old 03-23-2008, 01:02 AM
 
chris.barber chris.barber is offline
 

Advanced Member
  
Join Date: Sep 2007
Posts: 74
 

Default Re: Pre-Login Shipping Calculator

I'm sure others will correct me if I am wrong but this will be to do with the fact that it is written as a pre login shipping calculator, anonymous users aren't logged in so the test

{if $not_logged_message eq "1"}

{if $estimate ne "NO"}

is still valid but a customer who logs in makes this invalid and I assume turns the calculator off.
__________________
Chris Barber
Version 4.1.9
MOD - BCSE Shipping Estimator
MOD - Shopzilla Feed
MOD - Price Match with Captcha
MOD - Links Manager 2008
MOD - One Page Checkout
MOD - Sitemap
Reply With Quote
  #262  
Old 03-23-2008, 03:31 AM
 
chris.barber chris.barber is offline
 

Advanced Member
  
Join Date: Sep 2007
Posts: 74
 

Default Re: Pre-Login Shipping Calculator

OK, I recently installed the excellent one page checkout from Bill and this problem recurred in this mod, I asked Bill to help me as I couldn't work out how to make the same changes I made below to acheive the same result in this new mod.

Well Bill was bit confused and asked me why I wasn't using seperate zones ect, which I am, but in trying to resolve the situation myself and with a couple of quizical probes from Bill, I resolved it, and I suspect this situation as well such that no mods are needed to hide non-applicable shipping options.

Here's the issue, under General Settings/Shipping Options there is an option labelled 'Enable all shipping methods even if a customer is not logged in:', uncheck this and all is well...

Wish I knew this before would have saved a hell of a time trying to code a workaround, although I suspect someone will now tell me it says that on page 16 of this thread , but you live and learn, so make sure this option is unchecked whenever you install this mod as well as the ones indicated in the original post.

Quote:
Originally Posted by chris.barber
OK, I have sorted it for UK Postcodes, I have also managed to hide my ё0.00 options when they are not valid.

Here's the code

{if not $login}
{if $estimate ne "NO"}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="right">
{$lng.txt_enter_zipcode}<br /><br />
<select name='country_estimate'>
{section name=country_idx loop=$countries}
<option value="{$countries[country_idx].country_code}"{if $config.General.default_country eq $countries[country_idx].country_code} selected="selected"{/if}>{$countries[country_idx].country|amp}</option>
{/section}
</select>
<input type="text" name='zip_estimate' size="8" maxlength="8" />
{include file="buttons/button.tpl" button_title=$lng.lbl_calculate_shipping href="javascript: document.cartform.submit()" js_to_href="Y"}
</td></tr>
</table>
{else}
{*<input id="sc" type="hidden" name="selected_carrier" value="" />*}
<table cellpadding="1" cellspacing="0" align="right">
{if $shipping[ship_num].rate eq "0.00" && $shipping[ship_num].shippingid eq "161" }
<tr><td><font class="SmallText">{$lng.lbl_Free_Local_Delivery_te xt}</font></td></tr>
{/if}
{section name=ship_num loop=$shipping}
{if $shipping[ship_num].rate eq "0.00" && $shipping[ship_num].shippingid eq "160" }
<tr><td><font class="Text">{$lng.lbl_Free_Local_Delivery_text}</font></td></tr>
{/if}
{if $shipping[ship_num].rate ne "0.00"}
<tr>
<td width="8"{if $shipping[ship_num].shippingid eq $cart.shippingid} class="TableHead"{/if}>
<input type="radio" name="shippingid" value="{$shipping[ship_num].shippingid}" {if $shipping[ship_num].shippingid eq $cart.shippingid}checked="checked"{else}onclick="j avascript:{*if $shipping[ship_num].code eq "UPS"} document.getElementById('sc').value = 'UPS';{/if*} this.form.submit();"{/if} />
</td>
<td{if $shipping[ship_num].shippingid eq $cart.shippingid} class="TableHead"{/if} align="left">
{$shipping[ship_num].shipping|trademark:$insert_trademark}
{if $shipping[ship_num].shipping_time ne ""} - {$shipping[ship_num].shipping_time}{/if}
{if $config.Appearance.display_shipping_cost eq "Y" && ($login ne "" || $config.General.apply_default_country eq "Y" || $cart.shipping_cost gt 0)} ({include file="currency.tpl" value=$shipping[ship_num].rate}){/if}
</td>
</tr>
{if $shipping[ship_num].warning ne ''}
<tr>
<td>&nbsp;</td>
<td class="SmallText">{$shipping[ship_num].warning}</td>
</tr>
{/if}
{/if}
{sectionelse}
<tr><td><font class="ErrorMessage">{$lng.lbl_no_shipping_for_loc ation}</font></td></tr>
{/section}
</table>
<br style="clear:both;" />
<div style="align:right;text-align:right;width:100%;padding-top:10px;"><a href="cart.php?zip_estimate=clear">{$lng.txt_click _change_zip}</a></div>
{/if}
<hr size="1" noshade="noshade" width="100%"/>
{/if}

You need to create a label called lbl_Free_Local_Delivery_text and amend your shippingid to match your setup, but this now works great, you can check it out at my store which is live so please no test orders, use PE1 1AA as your Free Delivery postcode and EC1a 1AA as your chargeable postcode, it's http://www.4furryfeet.com.

You don't need this part
{if $shipping[ship_num].rate eq "0.00" && $shipping[ship_num].shippingid eq "160" }
<tr><td><font class="Text">{$lng.lbl_Free_Local_Delivery_text}</font></td></tr>
{/if}

If you don't have a delivery zone that offers free shipping.

I am not a programmer as I have said before so I hope this jibberish makes sense, thanks.
__________________
Chris Barber
Version 4.1.9
MOD - BCSE Shipping Estimator
MOD - Shopzilla Feed
MOD - Price Match with Captcha
MOD - Links Manager 2008
MOD - One Page Checkout
MOD - Sitemap
Reply With Quote
  #263  
Old 03-23-2008, 08:41 AM
 
deltron3030 deltron3030 is offline
 

Advanced Member
  
Join Date: Feb 2008
Posts: 32
 

Default Re: Pre-Login Shipping Calculator

Hi chris, thanks for looking into it. I unchecked it but still my logged in user does not get the rates
__________________
xcart 4.2
Reply With Quote
  #264  
Old 04-10-2008, 08:23 PM
 
chrisinoz chrisinoz is offline
 

eXpert
  
Join Date: Aug 2004
Location: Australia
Posts: 248
 

Default Re: Pre-Login Shipping Calculator

Hi

I resorted to an xcart customisatioin for my clients working with Australian Postcodes.

Works very nicely.

Shows estimate for ALL delivery methods available.

NOTE THE BELOW IS A LIVE SITE.

http://www.awomanscharm.com.au/

Add a handbag to your cart and then you'll see the Freight estimator link there.

Put in a postcode like 3000

Cheers
Chris
__________________
Chris G
Humble web designer
Version 4.07 - 4.45
Reply With Quote
  #265  
Old 04-17-2008, 04:42 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Pre-Login Shipping Calculator

Anyone have a solution for FedEx? The mode doesnt work with FedEx Direct. FedEx require "State" and "Zip" and they have to match otherwise an error is returned and rates not calculated. The code below is from the request for FedEx rates. This will return rates but if I use the calculator and change only the zip code to one outside Colorado an error is returned.

<DestinationAddress>
<StateOrProvinceCode>CO</StateOrProvinceCode>
<PostalCode>80012</PostalCode>
<CountryCode>US</CountryCode>
</DestinationAddress>

and this is the error

[17-Apr-2008 08:33:03] (shop: 17-Apr-2008 08:33:03) SHIPPING warning:
FedEx module error: [61468] Recipient postal code does not match recipient state/province code.
Request URI: /cart.php
Backtrace:
shipping/mod_FEDEX_direct.php:219
shipping/myshipper.php:113
shipping/shipping.php:97
cart.php:449

Anyone know how to fix this?
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #266  
Old 04-17-2008, 04:43 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Pre-Login Shipping Calculator

Ahhh...that explains why it doesn't work for Fedex...sounds like we'd need to add a 'state' field in there, or somehow map the zip to the state.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #267  
Old 04-17-2008, 05:26 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Pre-Login Shipping Calculator

Actually there was a field for State which I turned off when I installed the mode. I don;t know if it will work but I will check this.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #268  
Old 04-17-2008, 08:38 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Pre-Login Shipping Calculator

I think I figured it out, seems to work. Needs more testing though. Please report back so we can get this work the best way possible. Changes are in red. X-Cart 4.1.8 without fast lane checkout.

1. in your cart.php

# 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";
$trusted_post_variables = array("state_estimate");

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 length
$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_country"] = "US";
$config["General"]["apply_default_state"] = "Y";
$config["General"]["default_state"] = $state_estimate;
$config["General"]["default_zipcode"] = $zipcode_estimate;
$userinfo["s_country"] = "US";
$userinfo["s_state"] = $state_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_state"] = $state_estimate;
$config["General"]["default_zipcode"] = $zipcode_estimate;
$userinfo["s_country"] = "CA";
$userinfo["s_state"] = $state_estimate;
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}

}
# prelogin calculator end

2. in your cart_totals.tpl

{* BEGIN Shipping Estimate *}
{if $login eq ""}
{if $estimate ne "NO"}
<table width="100%">
<tr>
<td>
{$lng.lbl_shipping_estimate}:
</td>
<td>
<input type="text" name="zip_estimate" size="8" maxlength="6" />
{include file="main/states.tpl" states=$states name="state_estimate" default=$userinfo.s_state default_country=$userinfo.s_country}
</td>
<td>
{include file="buttons/submit.tpl" button_title="Estimate" style="button" href="javascript: document.cartform.submit();"}
</td>
</tr>
</table>
{else}

<p style="margin-top: 5px; font-size: 10px;">
{$lng.txt_estimate_shipping_charge}<br />
{$lng.lbl_shipping_change}: <a href="cart.php?zip_estimate=clear">{$userinfo.s_zi pcode}</a>
</p>
{/if}
{else}
<p style="margin-top: 5px; font-size: 10px;">
{$lng.txt_logged_shipping_charge}
</p>
{/if}
{* END Shipping Estimate *}

I didn't bother to fix the interface so the boxes might not line up. And one glitch I see - nothing prevents customer from inserting for instance zip code for FL and state NE which will probably end up returning wrong rates.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #269  
Old 05-02-2008, 09:37 AM
 
ReadytoCover ReadytoCover is offline
 

Senior Member
  
Join Date: Apr 2008
Posts: 124
 

Default Re: Pre-Login Shipping Calculator

Quote:
Originally Posted by ValhallaComics
Hello,

I'm using 4.1.8 Gold (UNIX), and I have installed this mod, here:
http://forum.x-cart.com/showpost.php?p=174133&postcount=197

I was wondering, however, if I could get this to work as a pop-up box that will list the available shipping options/prices to the customer, instead of only having this available on the checkout/view cart page. Do any of you have a solution for this?

Here's a link to my site, where the calculator is in the category listing:

http://www.valhallacomics.com/home.php

Hey man small world, I live in Centreville as well.
__________________
x-cart 4.1.9
Reply With Quote
  #270  
Old 05-02-2008, 04:37 PM
 
exsecror exsecror is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,284
 

Default Re: Pre-Login Shipping Calculator

Quote:
Originally Posted by ReadytoCover
Hey man small world, I live in Centreville as well.

Make that an even smaller world :P lol

We use the same modification ourselves though I modified ours to read off an SQL table that has postal codes for both the US and Canada (with a multi-city selector) for more zone sensitive quotes.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:15 AM.

   

 
X-Cart forums © 2001-2020