View Single Post
  #306  
Old 11-29-2010, 09:16 AM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Default Re: Pre-Login Shipping Calculator

I have been using the BCSE pre-login shipping calculator with Xcart 4.1.8 for over 3 years. As far as I know, it has always worked correctly. I have never noticed a miscalculation myself or had a customer complain that final shipping charges were higher than those initially estimated.

I did change the estimator to allow for shipping calculations for both logged in and not logged in customers. When logged in, the shipping charges are displayed based on the customer's profile info.

Recently, I made a change to include/func/func.cart.php to allow for a percent shipping discount. I added a parameter called disc_p to the shipping_rates table and added to the shipping calculation in func.cart.php to allow disc_p/100 * shipping cost to be subtracted from the shipping cost. This was several weeks ago and I didn't notice any problems with the shipping estimator at the time. However, last night, I noticed the estimator was giving lower-than-actual rates when the customer is not logged in. For instance, when an item of 3 lbs was in the cart, the initial rates returned were for 1 lb. Refreshing the cart.php page returned the correct rates, and the correct rates showed when logged in.

I have attached the original and modified xcart/skin1/customer/main/shipping_estimator.tpl in case anyone sees an error I have made that could be causing this problem. I have also attached include/shipping_estimator.php, which shows the small bit of code I commented out.

For the disc_p addition, I changed the calculations in func.cart.php to [lines 997-1004]:
Code:
if ($shipping && $total_ship_items > 0) { $shipping_cost = $shipping[0]["rate"] + ($total_weight_shipping * $shipping[0]["weight_rate"]) + ($total_ship_items * $shipping[0]["item_rate"]) + ($total_shipping * $shipping[0]["rate_p"] / 100); $shipping_cost -= ($shipping_cost * ($shipping[0]["disc_p"] / 100)); }

AND [lines 1007-1018]:
Code:
# Get realtime shipping rates # $result = func_query_first ("SELECT * FROM $sql_tbl[shipping] WHERE shippingid='$shipping_id' AND code!=''"); if ($config["Shipping"]["realtime_shipping"]=="Y" && $result && $total_ship_items>0) { $shipping_cost = func_real_shipping($shipping_id); $customer_zone = func_get_customer_zone_ship($customer_info, $provider,"R"); $shipping_rt = func_query("SELECT * FROM $sql_tbl[shipping_rates] WHERE shippingid='$shipping_id' $provider_condition AND zoneid='$customer_zone' AND mintotal<='$total_shipping' AND maxtotal>='$total_shipping' AND minweight<='$total_weight_shipping' AND maxweight>='$total_weight_shipping' AND type='R' ORDER BY maxtotal, maxweight"); # Added percent shipping discount to formula if ($shipping_rt && $shipping_cost > 0) $shipping_cost += $shipping_rt[0]["rate"]+$total_weight_shipping*$shipping_rt[0]["weight_rate"]+$total_ship_items*$shipping_rt[0]["item_rate"]+$total_shipping*$shipping_rt[0]["rate_p"]/100; $shipping_cost -= ($shipping_cost*($shipping_rt[0]["disc_p"]/100)); }

I also use real-time shipping (USPS only) and the BCSE shipping-per-product mod. The disc_p value is 0 for all subtotals below $50. Then it is 100 for USPS Media Mail (so MM orders of $50+ ship free anywhere), and 10 to 70 for other methods and destinations.

I have been staring at this too long and hop that a fresh look by someone may reveal an answer. One solution would seem to be to get the cart.php page to refresh on its own. Is there a good way to do that? Any other suggestions would be appreciated. I like online stores that allow me to preview shipping costs so I would like to continue offering this feature in my store.

I don't like to leave my site link here, but if anyone wants to try the shipping calculator in my store and report his/her results, PM me for the link.

Thanks,
Jill

PS
I did try emptying the shipping_cache table and that didn't help.
Attached Files
File Type: tpl shipping_estimatorOrig.tpl (2.2 KB, 165 views)
File Type: tpl shipping_estimator.tpl (7.3 KB, 185 views)
File Type: php shipping_estimator.php (914 Bytes, 165 views)
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
Reply With Quote