// class methods
function quote($method = ‘‘) {
global $order,$shipping_weight,$shipping_num_boxes,$db,$currencies;
$total_weight = $shipping_weight * $shipping_num_boxes;
if($total_weight > (int)MODULE_SHIPPING_CHINA_POST_MAX_WEIGHT){
return false;
}
//package weight
$total_weight += (int)MODULE_SHIPPING_CHINA_POST_PACKAGE_WEIGHT;
$cost = $db->Execute("select gz.geo_zone_name, gz.cost, ztgz.zone_id from geo_zones gz, zones_to_geo_zones ztgz where gz.geo_zone_id = ztgz.geo_zone_id and ztgz.zone_country_id = ".(int)$order->delivery[‘country‘][‘id‘]." and ztgz.zone_id = 0 and gz.geo_zone_name like ‘ChinaPost_%‘");
if($cost->RecordCount() > 0){
$first = round((float)MODULE_SHIPPING_CHINA_POST_COST,2);
$continue = round($cost->fields[‘cost‘],2);
$rate = (float)$currencies->currencies[‘CNY‘][‘value‘];
if($rate <= 0){
$rate = 1;
}
$disc = (float)MODULE_SHIPPING_CHINA_POST_RATE;
if($disc <= 0){
$disc = 1;
}
$ttl = round($disc*($first+$continue*ceil($total_weight/10)/100)/$rate,2);
$this->quotes = array(‘id‘ => $this->code,
‘module‘ => MODULE_SHIPPING_CHINA_POST_TEXT_TITLE,
‘methods‘ => array(array(‘id‘ => $this->code,
‘title‘ => MODULE_SHIPPING_CHINA_POST_TEXT_WAY,
‘cost‘ => $ttl)));
}else{
return false;
}
if ($this->tax_class > 0) {
$this->quotes[‘tax‘] = zen_get_tax_rate($this->tax_class, $order->delivery[‘country‘][‘id‘], $order->delivery[‘zone_id‘]);
}
if (zen_not_null($this->icon)) $this->quotes[‘icon‘] = zen_image($this->icon, $this->title);
return $this->quotes;
}