internal_name = "weightrate";
$this->name="Weight Rate";
$this->is_external=false;
return true;
}
function getId() {
// return $this->usps_id;
}
function setId($id) {
// $usps_id = $id;
// return true;
}
function getName() {
return $this->name;
}
function getInternalName() {
return $this->internal_name;
}
function getForm() {
// $output ="
";
return $output;
}
function submit_form() {
$layers = (array)$_POST['weight_layer'];
$shippings = (array)$_POST['weight_shipping'];
if ($shippings != ''){
foreach($shippings as $key => $price) {
if ($price == '') {
unset($shippings[$key]);
unset($layers[$key]);
} else {
$new_layer[$layers[$key]] = $price;
}
}
}
if ($_POST['checkpage'] == 'weight') {
update_option('weight_rate_layers',$new_layer);
}
return true;
}
function getQuote() {
global $wpdb;
$weight = wpsc_cart_weight_total();
$layers = get_option('weight_rate_layers');
if ($layers != '') {
krsort($layers);
foreach ($layers as $key => $shipping) {
if ($weight >= (float)$key) {
return array("Weight Rate"=>$shipping);
}
}
return array("Weight Rate"=>array_shift($layers));
}
}
function get_item_shipping($unit_price, $quantity, $weight, $product_id) {
return 0;
}
function get_cart_shipping($total_price, $weight) {
$layers = get_option('weight_rate_layers');
if ($layers != '') {
krsort($layers);
foreach ($layers as $key => $shipping) {
if ($weight >= (float)$key) {
$output = $shipping;
}
}
}
return $output;
}
}
$weightrate = new weightrate();
$wpsc_shipping_modules[$weightrate->getInternalName()] = $weightrate;