Update! Turns out that the global product var that I used to get the cart subtotal is not calculated first if the user updates the quantity. This script is not accurate if the user changes quantity and hits "update". The user will have to refresh the cart one more time to get it to work properly.
So, I adjusted the code to recalculate on its own. Here's the new code:
Code:
<?
// Custom shipping methods
//
// Edit the amount valid for free shipping below.
$freeOverAmount=200;
if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }
global $products, $cart, $userinfo, $current_area, $login;
// Make sure this shipping method is available
foreach ($allowed_shipping_methods as $key=>$value)
if ($value["code"] == "FREEOVERX")
$FREEOVERX_FOUND = true;
if ($FREEOVERX_FOUND)
{
$tempcart = func_calculate($cart, $products, $login, $current_area);
$row = func_query_first("SELECT shippingid, subcode FROM $sql_tbl[shipping] WHERE code='FREEOVERX' AND active='Y'");
if ($row && ($tempcart["subtotal"]>= $freeOverAmount))
{
$rate = 0;
$intershipper_rates[] = array("methodid" => $row['subcode'], "rate" => $rate);
}
}
// Use if national shipping is not working right:
// if ($userinfo["s_country"]=="US" && is_numeric($zp3))
// ...
?>
Have fun!