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)

rackit 03-30-2004 03:39 PM

Pre-Login Shipping Calculator
 
It would great if users could fill in their zip code and receive an estimate on their shipping cost based on the items currently in their cart. I know that some customers don't want to fill in all their contact information to find out the shipping charge. Does anyone else think this would be a good addition?

Edit: Here's my solution..

This works using a lot of methods already built into X-Cart. All that was required was manipulating them to do what I wanted. There's an option in General Settings that allows you to presume a customer is from a default country when not logged in. When this option is enabled, shipping charges are calculated automatically as items are added to the cart. What this modification does is enable this option when a user enters his/her zip code and changes the default zip code to what was entered.

To start off, the option "When a customer isn't logged in, it is presumed that he is from a default country." must be UNCHECKED (disabled). Secondly, replace this code in cart.php:

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


with this code:

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



The last thing to do is add the the input box in a template. cart_total.tpl seems like an obvious place for me. This is the code I put in my template:

Code:

{if $not_logged_message eq "1"}
 
{if $estimate ne "NO"}
   
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 zip code

  {/if}
{/if}


You can check it out in action at www.rack-it.com. A quick warning, if you add any product made by Yakima on my site that is over $50, the shipping will be free and this mod won't do anything.

adpboss 03-30-2004 05:25 PM

Tried to get something like this built, but the developer came up short.

Would be a handy item to have, but first we need shipping by Postal Code up here in CANADA. X-Cart are you listening?

jeeya 03-30-2004 09:26 PM

all I wish for is to offer free shipping based on certain states or countries.

adpboss 03-30-2004 10:02 PM

Raxitpatel,

You can already so this. I checked your site and the rates look like you are not using the USPS realtime shipping. All of your shipping is manual.

Just put the states or countries you want to have free shipping in their own individual zones. Then create new "Free Shipping" methods and link them to the zones in the Shipping charges page.

I hope this makes sense. I am really tired. I'll check back tomorrow.

rackit 04-02-2004 04:51 PM

Ok, I figured out a way to do this, but I need a little bit of help. If anyone knows how to set up session variables, it would great if you could help me out. It works the way I have it right now, but I would like the shopping cart to remember the person's zip code through the first step of checkout or if the person goes to shop around a bit more and then goes back to the cart.

edit: Nevermind!

I figured out the session variable thing. I'll try to have it done and posted in an hour or so, but it's friday night and I have better things to do. (oddly :))

rackit 04-04-2004 09:54 PM

It's up and running now. Check it out www.rack-it.com

My code is sloppy right now so I'm cleaning it up. I'll post it when it's nice and neat.

adpboss 04-06-2004 07:16 AM

Rackit,

Please post that, it's awesome.

rackit 04-06-2004 07:16 PM

Edit: moved the code to the first post.

GM 05-27-2004 11:52 AM

Looks good.... just one problem, I'm from Canada and I buy most of my big ticket items on the web. My postal code is P0H 1A0... doesn't work.
I'm more of an American at heart really, I've travelled through the U.S. more than I have Canada and I buy a lot from the States. I know every single person we've had running our country has been an idiot who can't speak right or has some wierd 8O deformation but the rest of us up here are really o.k. (and we're better at hockey and your beer is for little girls :roll: ), so you Southern Boys are gonna' have to allow for Canadian purchases. I don't blame you for wanting to shut us out because of the people running this place but give the rest of us a break. :D

[UPDATE] I guess I have to eat my words regarding hockey :oops: but at least I can wash them down with real beer :lol:

adpboss 05-27-2004 08:07 PM

Most shipping calculators that are built into sites do not allow for international postal code lookup.

I will test integration of this into the Canada Post Sell Online module built into 3.5.x and report back if I can get lookup for Canadian business to Canadian addresses working.

All you need to do is add a note under the text box for postal code, indicating that non US customers click HERE for a pop up rate box.


All times are GMT -8. The time now is 08:10 PM.

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