X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Pre-Login Shipping Calculator (https://forum.x-cart.com/showthread.php?t=6927)

BCSE 09-26-2004 12:54 PM

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

inksticks 09-27-2004 07:23 AM

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?

doersam@hotmail.com 09-28-2004 07:03 AM

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.

Darren 10-27-2004 08:15 AM

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.


sportruck 12-08-2004 03:21 PM

I have this working in 4.0.8, and want to have it display the ZIP code that the customer entered. Any ideas?

BCSE 12-08-2004 03:54 PM

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

sportruck 12-08-2004 04:10 PM

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";
      }


chilll33 12-08-2004 05:30 PM

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

halestorm 12-14-2004 03:12 PM

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

dalmuti 12-20-2004 05:11 PM

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

Louise


All times are GMT -8. The time now is 11:39 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.