alrightey, the "geoshipping module" is almost ready (as far as i can tell). only two problems:
1. i cannot figure out how to extend it to include per-product shipping definitions. anyone know where i can find the taxes dev version?
2. i cannot for the life of me get "orders over X amount ship for free" working! i can get the maximum amount into the database and it displays with the shipping rules on my site, but i can't get it back out to make the calculation!
here's the code - can anyone see what's wrong?
function uc_geoshipping_calculate($order){
// all this stuff is ripped from taxes module
if (is_numeric($order)){
$order = uc_order_load($order);
if (empty($order->delivery_postal_code)){
$order->delivery_postal_code = $order->billing_postal_code;
}
if (empty($order->delivery_zone)){
$order->delivery_zone = $order->billing_zone;
}
if (empty($order->delivery_country)){
$order->delivery_country = $order->billing_country;
}
}
if ($order === FALSE) {
return array();
}
$geoshippingrate_rules = uc_geoshipping_get_rates();
$subtotal = 0;
$geoshipping = array();
if (is_array($order->products)) {
foreach($order->products as $item){
$subtotal += $item->price * $item->qty;
}
}
$new_total = $subtotal;
foreach ($geoshippingrate_rules as $rule){
$max_amount = $rule->max_amount; <---- this is where i try to grab it
$conditions = $rule->conditions;
if (!$conditions){
$conditions = 'return true;';
}
else{
//watchdog('taxes', drupal_eval($conditions));
}
if (($rate = uc_geoshipping_match_area($rule, $order->delivery_postal_code, $order->delivery_zone,
$order->delivery_country)) && eval($conditions)){
$amount = $rate;
// this is where i make my fancy calculation that doesn't work
if (($max_amount > 0) && ($new_total > $max_amount)) {
$new_total = $new_total; // don't add shipping fees
} else {
$new_total += $amount;
}
$geoshipping[] = array('id' => $rule->id, 'name' => $rule->name, 'amount' => $amount);
}
}
return $geoshipping;
}


Joined: 08/08/2007