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
  #81  
Old 09-26-2004, 12:54 PM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default

In skin1/main/customer/cart_totals.tpl look for this code:

Code:
<TD nowrap align="right"><FONT class="ProductPriceSmall">{if $login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0}{include file="currency.tpl" value=$shipping_cost}</FONT></TD> <TD nowrap align="right">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$shipping_cost}{else}n/a{assign var="not_logged_message" value="1"}</FONT></TD><TD>{/if}</TD> </TR> {/if}

There you will see the n/a that shows up. You can change that to what ever you like. OR you can take out the:

Code:
or $cart.shipping_cost gt 0

In the if, since you are having this problem with free shipping. It actually may be a bug and you may want to report it to X-cart via your help desk. Seems to me like shipping should show up as Zero if it's free, instead of n/a.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #82  
Old 09-27-2004, 07:23 AM
 
inksticks inksticks is offline
 

Advanced Member
  
Join Date: Aug 2004
Posts: 34
 

Default

In skin1/main/customer/cart_totals.tpl I located this code:

Code:
<TD nowrap align="right"><FONT class="ProductPriceSmall">{if $login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0}{include file="currency.tpl" value=$shipping_cost}</FONT></TD> <TD nowrap align="right">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$shipping_cost}{else}n/a{assign var="not_logged_message" value="1"}</FONT></TD><TD>{/if}</TD> </TR> {/if}

I added
Code:
or $cart.shipping_cost eq 0
after
Code:
or $cart.shipping_cost gt 0

This fixed the n/a problem and now 0.00 is being shown instead of n/a but in the Delivery method: drop down list the prices of all methods still disappear when when free shipping is selected. This problem does not occur when a customer is logged in so I don't think it is a bug. There must be another place in the tpl that is causing this to happen. Any ideas?
__________________
X-Cart 4.0.5
http://www.inksticks.com/
Reply With Quote
  #83  
Old 09-28-2004, 07:03 AM
 
doersam@hotmail.com doersam@hotmail.com is offline
 

Senior Member
  
Join Date: Jul 2004
Location: Snohomish, WA
Posts: 153
 

Default

I finally managed to get this mod working clean in a 3.5.10 site. Here is what I did:

1). Uncheck the option "When a customer isn't logged in, it is presumed that he is from a default country." in General.

2). Create calculate.gif and place it in /skin1/images (you could just use the supplied go.gif).

3). Modified cart.php:
Old Code:
x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");

New Code:
if(!$login){
$smarty->assign("not_logged_message","1");
}
else{
$smarty->assign("not_logged_message","0");
}

x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("zipcode_estimate");


if($HTTP_GET_VARS['zip_estimate'] == "clear"){
$zipcode_estimate = "";
func_header_location("cart.php");
}

if(!empty($HTTP_POST_VARS['zip_estimate'])){
$zipcode_estimate = $_POST['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");

if($count != 5){ //checking for 5 digits
$zipcode_estimate = "";}

func_header_location("cart.php");
}
if($zipcode_estimate != ""){
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}

4). Modified top.inc.php
Old Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val")))

New Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val","_GET","_POST","_SERVER ")))

5). Modified cart_totals.tpl
Added this code to the bottom of the file:
<div align=right>
{if $not_logged_message eq "1"}
{if $estimate ne "NO"}

Please enter your zip code to

calculate shipping charges.


<input type=TEXT name='zip_estimate' size=5 maxlength=5>
<input type=image alt="Calculate Shipping" src="../skin1/images/calculate.gif" border=0 align=middle name=btnCalculate >
{else}

Click here to change your shipping zip code.
{/if}
{/if}




If you use this method, make sure you back things up first! I am not a programmer, just a hacker.
__________________
Thanks,
Phil

X-Cart Gold
Version 4.4.5
Reply With Quote
  #84  
Old 10-27-2004, 08:15 AM
 
Darren Darren is offline
 

Member
  
Join Date: Dec 2002
Posts: 19
 

Default

Phil,

your solution works great. Thanks for the work!!





Quote:
Originally Posted by doersam@hotmail.com
I finally managed to get this mod working clean in a 3.5.10 site. Here is what I did:

1). Uncheck the option "When a customer isn't logged in, it is presumed that he is from a default country." in General.

2). Create calculate.gif and place it in /skin1/images (you could just use the supplied go.gif).

3). Modified cart.php:
Old Code:
x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");

New Code:
if(!$login){
$smarty->assign("not_logged_message","1");
}
else{
$smarty->assign("not_logged_message","0");
}

x_session_register("cart");


x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("zipcode_estimate");


if($HTTP_GET_VARS['zip_estimate'] == "clear"){
$zipcode_estimate = "";
func_header_location("cart.php");
}

if(!empty($HTTP_POST_VARS['zip_estimate'])){
$zipcode_estimate = $_POST['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");

if($count != 5){ //checking for 5 digits
$zipcode_estimate = "";}

func_header_location("cart.php");
}
if($zipcode_estimate != ""){
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}

4). Modified top.inc.php
Old Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val")))

New Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val","_GET","_POST","_SERVER ")))

5). Modified cart_totals.tpl
Added this code to the bottom of the file:
<div align=right>
{if $not_logged_message eq "1"}
{if $estimate ne "NO"}

Please enter your zip code to

calculate shipping charges.


<input type=TEXT name='zip_estimate' size=5 maxlength=5>
<input type=image alt="Calculate Shipping" src="../skin1/images/calculate.gif" border=0 align=middle name=btnCalculate >
{else}

Click here to change your shipping zip code.
{/if}
{/if}




If you use this method, make sure you back things up first! I am not a programmer, just a hacker.
__________________
Using Version 3.5.4
Reply With Quote
  #85  
Old 12-08-2004, 03:21 PM
 
sportruck sportruck is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 70
 

Default

I have this working in 4.0.8, and want to have it display the ZIP code that the customer entered. Any ideas?
Reply With Quote
  #86  
Old 12-08-2004, 03:54 PM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default

Quote:
Originally Posted by sportruck
I have this working in 4.0.8, but I would like to have it display the ZIP code that the customer entered. I tried using the variables, but it does not seem to work. Anyone have any ideas?

To display any php variable in smarty, you first have to tell php to make it available for smarty. So you would need

$smarty->assign("zipcode_estimate",$zipcode_estimate);

in cart.php (usually near the end of the file with the rest of the smarty assigns).

That makes {$zipcode_estimate} available in the templates.

HTH!

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #87  
Old 12-08-2004, 04:10 PM
 
sportruck sportruck is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 70
 

Default

Thank you. I had firgued out the session variables and was editing my original post before I saw your reply.

I also made it calculate tax based on ZIP code, but I hard coded it for CA tax. I'm sure there is a better way to do this, but this is my quick hack:

Code:
if($zipcode_estimate >= 90001 && $zipcode_estimate <= 96162){ $config["General"]["default_state"] = "CA"; }
Reply With Quote
  #88  
Old 12-08-2004, 05:30 PM
 
chilll33 chilll33 is offline
 

Senior Member
  
Join Date: Oct 2003
Location: Miami, FL
Posts: 100
 

Default

Quote:
Originally Posted by sportruck

I also made it calculate tax based on ZIP code, but I hard coded it for CA tax. I'm sure there is a better way to do this, but this is my quick hack:

Code:
if($zipcode_estimate >= 90001 && $zipcode_estimate <= 96162){ $config["General"]["default_state"] = "CA"; }

I did the same for pre-login shipping and tax for florida, it works great
__________________
Core version:
5.3.2.7

PHP:
5.6.29
MySQL server:
5.5.5-10.0.27-MariaDB-cll-lve  (InnoDB engine support enabled)
Web server:
Apache
Operating system:
Linux
XML parser:
found
GDLib:
found (0)
Translation driver:
Database
Curl version:
7.29.0
Reply With Quote
  #89  
Old 12-14-2004, 03:12 PM
 
halestorm halestorm is offline
 

Advanced Member
  
Join Date: Oct 2004
Posts: 44
 

Default

I'm using 4.08. There is so much code on all these pages, I'm not sure where to begin. If anybody could just PM me from start to finish I would really appreciate it.

Thaks!

Daniel
__________________
...
x-cart-4.0.11

http://www.thegamegeek.net
Reply With Quote
  #90  
Old 12-20-2004, 05:11 PM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default

I would hope they would post it here for all of us.

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
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 12:19 PM.

   

 
X-Cart forums © 2001-2020