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)

jillsybte 09-25-2007 07:18 PM

Re: Pre-Login Shipping Calculator
 
Does anyone have the BCS Eng. Pre-Login Shipping Calculator working correctly with the BCS Eng. Shipping Methods Per Product mod?

I have 4.1.8 and just installed both of these mods. This problem isn't huge and I realize the shipping calculator is free so I'm not complaining. I'm just wondering if anyone has this combo of mods working properly and can offer me some advice.

I installed the calculator first and it worked properly. Then I installed the Shipping per Product mod. When I try to estimate shipping before logging in/checking out and have products that don't have all available shipping methods in common, the methods not common to all items are shown anyway. The name of the method isn't shown, but a radio button is shown and the cost is displayed as $0.00. The Shipping Per Product mod does work properly in later checkout steps.

I will likely contact BCS in the morning as well. I just thought some X-Cart forum users might have had this same experience. If so, I'd be grateful for any helpful info.

Thanks,
Jill

jillsybte 09-26-2007 09:15 AM

Re: Pre-Login Shipping Calculator
 
I was looking over the source code of the full cart.php page after the shipping calculator has been utilized. I noticed that the value for the radio button corresponding to the shipping methods not common to all cart items was given a value of "". So I went to the shipping_estimator.tpl and placed the following line:

Quote:

{if $shipping[ship_num].shippingid ne ""}

right after the line:

Quote:

{section name=ship_num loop=$shipping}

Then I entered the closing {/if} tag just before the {sectionelse} tag.

That way, the invalid shipping methods don't even show up. I tested and it works.

Also, this is just my personal preference, but I moved the include shipping_estimator.tpl line in skin1/customer/main/cart.tpl. I placed it after the Fast_Lane_Checkout/cart_subtotal.tpl line instead of before as was stated in the shipping calculator readme file. I was afraid that customers would think the displayed subtotal includes the shipping charges displayed when it really doesn't. Having the subtotal displayed first with the calculated shipping charges below should lessen the chance for confusion.

I hope this helps others having the same problem as I was. Thanks to BCS for making these great mods.

Jill

chris.barber 10-05-2007 08:11 AM

Re: Pre-Login Shipping Calculator
 
Hi

Can this mod be changed to cater for UK Postcodes, I updated the text to say Postcode etc and made it accept up to 8 characters and it looked good, but it wouldn't calculate a shipping cost because it didn't seem to be picking up the postcode, the problem with UK codes is that they can be 7 characters (including spaces) i.e. PE6 7QP, or 8 characters (including spaces) i.e. NW12 7AQ, or even 6 i.e. N1 1AA.

I would really appreciate some help.

2coolbaby 10-12-2007 06:31 PM

Re: Pre-Login Shipping Calculator
 
I was wondering if their was a version that works internationally. I use UPS Real Time Rates and we ship a lot to UK, Ireland, Canada and misc countries. I just updated to 4.1.8 and am looking to add this. I had it on my 4.0.18 store and I could get Worldwide rates for other countries from that one. They weren't exact, but close.

I think I remember adding the Canada code. Maybe it is giving Canada shipping rates and that is why they are a little off!

chris.barber 10-25-2007 03:45 AM

Re: Pre-Login Shipping Calculator
 
Hi all, I have managed to change this mod so that it now works with the UK postcode systems and it is great, I have one small problem and that is I have 3 different shipping methods, Free Local Delivery, which is constrained to a set of specific postcodes, Small Packet, which is up to 2kgs and then UK Standard which is everything else.

If the item is more than 2kgs then only the UK Standard and Free Local Delivery are shown, what I could do with help on is stopping the Free Local Delivery coming up regardless of the entered postcode, does anyone have any idea, I'm not a PHP programmer but I was hoping that maybe I could do a if shipping value is not equal to 0 then hide Free shipping, otherwise show it.

Just to clarify, the Free Local Shipping is always displayed even if I enter a postcode that is not entitled to Free shipping, ofcourse I know that this will be changed when the customer finsihes placing the order, but I don't want arguments with peple who claim, "your system said I could select free shipping then you want to charge me"

Any help greatfully appreciated, once I have it 100% I will share the code back here for any UK shop owners who would like to benefit.

Chris

jillsybte 10-25-2007 05:26 AM

Re: Pre-Login Shipping Calculator
 
Dear Chris,

Is the entire line for Local Delivery showing (i.e., name and cost)? I was having a similar problem using this calculator along with the Shipping per Product Mod, where all methods were being listed even if they weren't valid for the combination of products in the cart. In my case, only the value was showing (as $0.00) and not the shipping method name.

Anyway, in case it helps, read my post above (#242) for the code I used in shipping_estimator.tpl to keep invalid methods from showing up. The only drawback is that when all existing shipping methods don't get listed, the top method that does get listed doesn't get highlighted with gray and isn't automatically selected. I personally don't care about that anyway. The customer will have a chance to choose shipping later during checkout.

I also modified my calculator to allow shipping calculation for logged in users as well (it uses their profile shipping country and zip and displays a message that the shipping costs are based on those). Then I modified it to just display "FREE SHIPPING" and no link, etc. for calculating when a free shipping coupon has been applied to the cart.

I hope this helps you. Good luck.

Jill

chris.barber 10-25-2007 08:37 AM

Re: Pre-Login Shipping Calculator
 
Hi Jill the entire line is showing but obviously it just puts FREE Local Delivery (£0.00), unless it is actually valid in which case it doens't have the value.

However I looked at your post and it didn't really make sense to me as the approach I used from this thread doesn't use a shipping_estimator.tpl, any suggestions where I could put this code to acheive the same result?

jillsybte 10-25-2007 09:02 AM

Re: Pre-Login Shipping Calculator
 
Chris,

I'm using the free estimator that I downladed from BCS. There is a loop in shipping_estimator.tpl that goes through the existing shipping methods in your store:

Quote:

{section name=ship_num loop=$shipping}
<tr>
<td width="5"{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}
{sectionelse}
...


I placed the if statement

Quote:

{if $shipping[ship_num].shippingid ne ""}


below the first line. I then closed the if statement before the {sectionelse} line.

So if there's some sort of loop, foreach statement, etc. that goes through your shipping methods, you can place some sort of if statement just inside the loop to suppress the methods that aren't valid in certain situations. In your case, it sounds like a value is appearing when the shipping method is NOT valid. So maybe an if statement that says if the name is FREE local delivery (or the ID is the ID for it) and the value eq "", include in the loop, otherwise don't.

I don't know if that will work or not. I can say that you should be able to solve the problem in a .tpl file and be able to avoid messing with PHP code.

I wish I could be of more help. Hopefully someone here will have an answer, especially since you'll be willing to share with other UK users if you get it working properly.

Jill

chris.barber 10-27-2007 03:44 PM

Re: Pre-Login Shipping Calculator
 
Hi Jill

I got the download from BCSE and installed that after updating my system to 4.1.9 (don't even get me started on that one :D )

I then followed your approach but adapted it based on your advice, I then identified the shippingid and hid that, all works brill, if the Free Local Delivery applies the two other options are shown with £0.00, which is fine, however I thought it would be better to hide any that had a rate of £0.00 so changed it to look at the rate 0.00, that worked great also, but when Free Local Delivery is valid, because it is £0.00 it remains hidden.

Do you or anyone else have any idea how I might change the code below to hide the Free Local Delivery when the other 2 rates actually aren't £0.00, but show just the Free local Delivery when all 3 = £0.00, hope those ramblings make sense.

Here's the code

{section name=ship_num loop=$shipping}
{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}

Cheers

Chris

chris.barber 10-29-2007 05:02 AM

Re: Pre-Login Shipping Calculator
 
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.

minorgod 02-04-2008 07:09 PM

Making it work with DHL/Airborne + Taxes
 
I just downloaded the official "FastLane" version of this mod from BCSE and installed it in Xcart 4.1.8 Gold. It seems to work well for U.S. addresses, but I'm still having a couple of issues...
  1. It doesn't seem to be working with international rates and DHL/Airborne, even though it looks like it should work with DHL/Airborne.
  2. Has anyone got a clue how to make this work so that it also calculates taxes prior to login? It looks like the right tweaks to the func_get_customer_zones_avail() or func_get_customer_zone_ship() inside /include/func/func.cart.php might do the trick, but I can't seem to get my head around it at the moment.

balinor 02-04-2008 07:25 PM

Re: Pre-Login Shipping Calculator
 
There was some discussion in this thread about taxes and non-US postal codes. Another glitch is still the fact that it does not seem to want to pull real-time rates for FedEx when you are using their new integrated method. Rates show fine when logged in, but the shipping calculator won't pull them.

minorgod 02-05-2008 08:58 AM

Re: Pre-Login Shipping Calculator
 
I've managed to get the Free X-cart Shipping Estimator for Fastlane Checkout mod to calculate taxes on US orders for a specific state. Simply open /include/shipping_calculator.php

FIND:
Code:

$config["General"]["default_zipcode"] = $zipcode_estimate; 
AFTER ADD:
Code:

  $config["General"]["default_state"] = "NY"; 

Presumably, at least for the time being, US stores only need to calculate tax on orders shipped to the state where the business is physically located, so if your store is in NY, the you simply need to set the default_state variable to "NY" and any zipcodes that are in your NY zone will get taxed, but zipcodes that are outside NY will not calculate taxes. Apparently, the zipcode is not enough to get x-cart to calculate taxes...it actually needs the state too. This will probably cause no end of frustration to international store owners.

Also, you might want to add this to your /skin1/mods/Fast_Lane_Checkout/cart_subtotal.tpl file:
Code:

{* normally this would only display if we have $config.Taxes.display_taxed_order_totals checked, but this totally screws up tax calculations on discounted products because it causes taxes to be applied before discounts rather than after discounts, so I'm just showing taxes here even if that setting is turned off *}
{* if $cart.taxes and $config.Taxes.display_taxed_order_totals eq "Y" *}
{if $cart.taxes}
    {foreach key=tax_name item=tax from=$cart.taxes}
    <tr class="TableSubHead">
        <td nowrap="nowrap" align="right">{$tax.tax_display_name}:</td>
        <td><img src="{$ImagesDir}/null.gif" width="5" height="1" alt="" /><br /></td>
        <td nowrap="nowrap" align="right">{include file="currency.tpl" value=$tax.tax_cost}</td>
        <td nowrap="nowrap" align="right">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$tax.tax_cost}</td>
    </tr>
    {/foreach}
{/if}


I'm still working on a solution to getting this working with international shipping. If anyone out there has a working solution to DHL/Airborne that will let my users choose just their country and zipcode and get a realtime rate, I will pay a reasonable fee for the code. Meanwhile, I'll be living in my debugger and will update this thread if I find a solution.


UPDATE: I was able to get international shipping estimates working with USPS and UPS. DHL is another story since you must supply a valid address to get a rate back from DHL. For anyone that is trying to get this working with DHL, here's some comments I just got from their XMLAPI support that might help:
Quote:

The elements <State> and <PostalCode> are required for Canada and Puerto Rico.
They are optional for other Countries.
If you do not know the PostalCode, you can use a default because RateIT
uses the Country to return a rate.

The State and Country elements must be two characters in length.


I have also discovered that if you enable UPS realtime rates with this mod, it totally messes up the returned rates for USPS and other shippers -- they show up as blank. To fix this problem, I did the following, though I'm not sure if there's any implications on performance or functionality of the UPS realtime rates, but it seems to work for me so far.....

OPEN: /xcart/shipping/shipping.php
FIND:
Code:

        if ($config["Shipping"]["realtime_shipping"] == "Y" && $current_carrier == "UPS") {
            $ups_condition .= " AND $sql_tbl[shipping].code='UPS' AND $sql_tbl[shipping].service_code!=''";
        }


and change to
Code:


        if ($config["Shipping"]["realtime_shipping"] == "Y" && $current_carrier == "UPS") {
            //$ups_condition .= " AND $sql_tbl[shipping].code='UPS' AND $sql_tbl[shipping].service_code!=''";
        }


If you don't comment that out, a bit of invalid SQL is added to queries for non-UPS shipping rates that keeps it from finding non-UPS rates when ithe /shipping/shipping.php file builds the actual $shipping array further down where it says:
Code:

$query =  "SELECT *, '$intershipper_rate[rate]' AS rate, '$intershipper_rate[warning]' AS warning, $ship_time_column FROM $sql_tbl[shipping] WHERE subcode='$intershipper_rate[methodid]' AND active='Y' $weight_condition ORDER BY orderby";
               
                $result = func_query_first($query);


If anyone understands the implications of my tweaks on the UPS mod, please post info here.

ValhallaComics 02-11-2008 12:29 PM

Re: Pre-Login Shipping Calculator
 
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

imimin 02-26-2008 11:41 AM

Re: Pre-Login Shipping Calculator
 
Does someone know how I can take the code:

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}


and make the entry box come up in a pop-up box intead?

minorgod 02-26-2008 02:17 PM

Re: Pre-Login Shipping Calculator
 
Quote:

Originally Posted by imimin
Does someone know how I can take the code:

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}


and make the entry box come up in a pop-up box intead?


Check out the shipping calculator on http://www.bonobospants.com/store/ . I used the Highslide JS library to do it. You can probably view the source and the Highslide JS documentation and figure it out. If not, feel free to contact me and I will give you a quote to do it for you.

shippersplus 03-13-2008 09:19 AM

Re: Pre-Login Shipping Calculator
 
i can not seem to get this mod to work on 4.1.9 anyone able to?
the mod has no errors, but i do not see the click for zip code

samz724 03-13-2008 12:09 PM

Re: Pre-Login Shipping Calculator
 
This mod is excellent. Exactly what I needed, thanks! :mrgreen:

deltron3030 03-22-2008 11:20 AM

Re: Pre-Login Shipping Calculator
 
This mod works fine for me in 4.1.9, Balinor you can get fedex rates my adding this twice below

just under $ship_mods[] = "DHL";

add
if ($fedex_mod == 'FEDEX_direct')
$ship_mods[] = $fedex_mod;



in the myshipper.php file

deltron3030 03-22-2008 11:22 AM

Re: Pre-Login Shipping Calculator
 
Something funny i noticed is that for logged in customers they do not get the shipping estimate if they decide to update their cart with more products. Although anonymous customers do not have this problem.

Weird

chris.barber 03-23-2008 01:02 AM

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 03-23-2008 03:31 AM

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.


deltron3030 03-23-2008 08:41 AM

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

chrisinoz 04-10-2008 08:23 PM

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

cflsystems 04-17-2008 04:42 AM

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?

balinor 04-17-2008 04:43 AM

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.

cflsystems 04-17-2008 05:26 AM

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.

cflsystems 04-17-2008 08:38 AM

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.

ReadytoCover 05-02-2008 09:37 AM

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.

exsecror 05-02-2008 04:37 PM

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.

swamp-industries 05-03-2008 05:28 PM

Re: Pre-Login Shipping Calculator
 
I had a similar edition made to my site, so customers can enter a postcode or select a country to receive a quote for all items in the shopping cart, before checking out.

The developer I used was excellent, here is a link to his site.
http://xcartmod.com/cart/home.php

2coolbaby 05-07-2008 12:18 PM

Re: Pre-Login Shipping Calculator
 
Yesterday I was adding the BCS Pre-login shipping calculator to my store. I suddenly started getting the No available shipping methods message for orders. I went back and tried to remove it, but found that the ownership had been removed on cart.php and I could not edit or replace it.

I did an xcartdump.sql and saved the file on my computer. I then restored my website from a daily backup done by my plesk server, through the plesk interface.

Everything seemed to be okay, until I tried to place a test order and I kept getting this message:

Your order is being placed. Please wait...
INVALID SQL: 1062 : Duplicate entry '0' for key 1
SQL QUERY FAILURE:INSERT INTO xcart_orders (`login`, `membershipid`, `membership`, `total`, `giftcert_discount`, `giftcert_ids`, `subtotal`, `shipping_cost`, `shippingid`, `tax`, `taxes_applied`, `discount`, `coupon`, `coupon_discount`, `date`, `status`, `payment_method`, `paymentid`, `payment_surcharge`, `flag`, `details`, `customer_notes`, `clickid`, `language`, `extra`, `title`, `firstname`, `lastname`, `phone`, `fax`, `email`, `url`, `company`, `tax_number`, `tax_exempt`, `b_title`, `b_firstname`, `b_lastname`, `b_address`, `b_city`, `b_county`, `b_state`, `b_country`, `b_zipcode`, `s_title`, `s_firstname`, `s_lastname`, `s_address`, `s_city`, `s_county`, `s_state`, `s_country`, `s_zipcode`) VALUES ('anonymous-0', '0', '', '1.00', '0', '', '1.00', '0.00', '0', '0.00', 'N;', '0.00', '', '0.00', '1210194300', 'Q', 'Purchase Order', '2', '0', 'N', 'B-996124656afcff0fc6c91a2a8f389982fbf9716b6bd587dcce 19c205f2070b31038a1ff1928010306d4a71f158329791d1ca 191f5510dea59c71f18746266cf792244565c050f232517d00 ddc354171e25b23370a67ee46f9e77c91a6697855d44115772 684444d0', '', '', 'US', 'a:2:{s:17:\"additional_fields\";a:1:{i:0;a:4:{s:7 :\"fieldid\";s:1:\"3\";s:7:\"section\";s:1:\"S\";s :5:\"value\";s:0:\"\";s:5:\"title\";s:7:\"Company\ ";}}s:8:\"tax_info\";a:5:{s:26:\"display_taxed_ord er_totals\";s:1:\"N\";s:31:\"display_cart_products _tax_rates\";b:0;s:14:\"taxed_subtotal\";s:4:\"1.0 0\";s:25:\"taxed_discounted_subtotal\";s:4:\"1.00\ ";s:14:\"taxed_shipping\";s:4:\"0.00\";}}', '', 'Jenny', 'Fine', '', '', 'ml@dinnerandamurder.com', '', '', '', 'N', '', 'Jenny', 'Fine', 'AMCTt ', 'MH', '', 'CA', 'US', '60626', '', 'Jenny', 'Fine', 'AMCT ', 'MH', '', 'CA', 'US', '60626')
INVALID SQL: 1062 : Duplicate entry '0-ip' for key 1
SQL QUERY FAILURE:INSERT INTO xcart_order_extras (orderid, khash, value) VALUES ('', 'ip', '68.119.107.238')
INVALID SQL: 1062 : Duplicate entry '0' for key 1
SQL QUERY FAILURE:INSERT INTO xcart_order_details (`orderid`, `productid`, `product`, `product_options`, `amount`, `price`, `provider`, `extra_data`, `productcode`) VALUES ('', '16183', 'Nothing', '', '1', '1.00', 'coolbaby2', 'a:3:{s:15:\"product_options\";N;s:5:\"taxes\";a:0 :{}s:7:\"display\";a:3:{s:5:\"price\";s:4:\"1.00\" ;s:16:\"discounted_price\";s:4:\"1.00\";s:8:\"subt otal\";s:4:\"1.00\";}}', 'SKU16183')

(I replaced personal info. No email, name, or address had been used before. No username was provided)

Access denied !

You are not allowed to access that resource!

Error ID: 59

First n order with Order ID# 0 is actually placed, in spite of the message and queued. I am at about Order ID# 11778 now, not 0. The second time it was not placed. It appears to me as if it keeps assigning an order ID of 0 to new orders and that is the reason for the Duplicates.

I have tried to restore the xcartdump.sql from within x-cart and it acts like it does so, but the missing orders from the xcartdump.sql are not there and no one can purchase anything. I have restored my site from 2 different backups I have on the server, twice each, and the store still will not work. Customers cannot buy anything.

I also went in and tried to clean the logs and received this following error:

Not enough permissions to delete the following files:
xxxxxxxx/store/var/log/x-errors_env-070807.php

I am beginning to suspect that some type of serious permission thing is going on here. I don't know if it is the store or the server, but since it is only in the store, I have to think it is something going on in there.

I have tried deleting xcart_sessions xcart_users_online, optimizing the tables. Nothing is working. Please help! I would be happy to pay someone to help me with this, if they know. I have an Urgent Ticket into x-cart, but 6 hours with no reply yet, so I am hoping someone can help me here, as I know xcart can take a week or more now to handle things.

I have also found that when I start a new topic in the forum here, the post does not go to the Search: New Posts, so no one views it. I have posted twice with not one view. I am hoping this post makes it into the New Posts, which actually get read quickly.

2coolbaby 05-07-2008 01:50 PM

Re: Pre-Login Shipping Calculator
 
ALMOST SOLVED: I discovered that when the backup restored it took out the Auto Increment Settings in the Orders, Order_Details and the Order_Extras. Selecting Auto Increment in the Extra Field in Phpmyadmin for the Order ID in these 3 tables. I am still getting the error message for the User name, I think. Anonomous-0 is how this is coming up in the order, so I am not sure which field in what table I need to Auto Increment. Anyone have any ideas???

ReadytoCover 05-08-2008 10:59 AM

Re: Pre-Login Shipping Calculator
 
I'm getting the Sorry, no shipping methods with the BCES Shipping Calculator as well...using UPS Real Time only...anyone else run into and fix this problem?

My one page checkout page still computes and displays shipping without a problem, its just the pre-login calculator that doesn't work.

Unfortunately I don't know enough about your issue to assit Mary Lee...I'd probably just make it worse! I hope it gets resolved soon

2coolbaby 05-08-2008 11:17 AM

Re: Pre-Login Shipping Calculator
 
I ended up re-installing from a VPS backup after I exported my data as INSERT so I could add in the new orders since the last VPS backup a couple days ago. Another reason I am so glad I have a VPS.

I too would really like to resolve the No Shipping Methods Available, as I don't really want to spend another 2 days like I just went through. Heads up to everyone. The original problem came in when I did a restore from backup for the domain using Plesk. Apparently this is an issue with some versions of Plesk. They do not restore the Auto Increment settings in a database. That is just nuts!

ReadytoCover 05-09-2008 02:53 PM

Re: Pre-Login Shipping Calculator
 
Well, I figured out the Sorry, No shipping problem (at least for me). It didn't work with the Default Location unchecked in General Settings, but I noticed it DID work if I checked that box AND entered the same zipcode. Once I removed the zipcode in the Default Location it worked for that entire state. However, since you cannot de-select a state it wouldn't work for anyone who was outside of the state.

So I went into cart.php around line 415 and commented out:

Code:

$userinfo["b_state"] = $userinfo["s_state"] = $config["General"]["default_state"];


Now it works. (Make sure you have the assume default location box CHECKED in General Settings)

I'm not a code guru by any sorts so back up your file before attempting this.

Hope it helps.

MBA 05-15-2008 07:53 PM

Re: Pre-Login Shipping Calculator
 
Well, so..., geese... ok, not to rebirth this thread or anything but... 4.1.10... It works with a vanilla install of 4.1.10 sort of. The odd thing is I'm getting both radial buttons and a drop down menu. I've enable all FEDEX, UPS, USPS and DHL options just for fun. All real-time rates. The odd thing is only the drop down menu will change the shipping rate. You can click the radial buttons and the page refreshes but the shipping rate doesn't change.

Will look more closely at this. It should convert to something usable without much time commitment but for those of you patching to 4.1.10, it won't work directly from the patch.

Say Carrie, how about saving me the headache and updating your mod for 4.1.10 and charging a pence for it?! :-)

chris.barber 05-16-2008 12:31 AM

Re: Pre-Login Shipping Calculator
 
MBA thanks for that it helps my decision about moving from 4.1.9 to .10, I'll wait as my store is pretty modded right now with some nice stuff from the support guys, Eugene has been fantastic, but this mod is one that took me a while to get working and I'd prefer it to stay this way.

Thanks for the info.

cflsystems 05-23-2008 10:33 AM

Re: Pre-Login Shipping Calculator
 
1 Attachment(s)
I wasn't sure if I should post this here or start a new thread but here it is. Moderators please move if necessary. I have this solution to show rates for FedEx on the prelogin calculator. As far as I can tell it works. Attached is a sql file to create and populated a table with the zip codes for USA. Please note that the info in this file is 4-5 years old but for the purpose of getting zip code and appropriate state works fine. Also here is the code for the shipping calculator that goes into cart.php

PHP 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 strlen($zipcode_estimate);
if(
$count 4){ //checking length 
$zipcode_estimate "";

func_header_location("cart.php"); 

if(
$zipcode_estimate != ""){ 
$customer_temp_state func_query_first_cell("SELECT state_abbr FROM `zip_codes` WHERE zip_code='$zipcode_estimate'");
$count strlen($zipcode_estimate);
if(
$count == 5) { 
$config["General"]["default_country"] = "US";
$config["General"]["default_state"] = $customer_temp_state;
$config["General"]["default_zipcode"] = $zipcode_estimate
$config["General"]["apply_default_country"] = "Y";
$userinfo["s_country"] = "US";
$userinfo["s_state"] = $customer_temp_state;
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO"); 
} else {
$config["General"]["apply_default_country"] = "Y"
$config["General"]["default_country"] = "CA";
$config["General"]["apply_default_state"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate
$userinfo["s_country"] = "CA";
$userinfo["s_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO"); 
}

# prelogin calculator end 


This is for USA only as I do not ship to Canada so I was not looking for a solution for Canada.
Turns out I can attached only 512K so I split the file.

cflsystems 05-23-2008 10:34 AM

Re: Pre-Login Shipping Calculator
 
1 Attachment(s)
Second part of the above


All times are GMT -8. The time now is 03:14 AM.

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