我很难理解osCommerce如何计算Expedited和Super Rush运输模块的运费。
我正在寻找有关如何计算这些成本的英文解释。我得到了两个处理此问题的文件,但我很难理解发生了什么。
function quote($method = '') {
global $order, $cart, $shipping_weight, $shipping_num_boxes, $total_count;
$porciento = ($cart->show_total() * MODULE_SHIPPING_TABLEEXPEDITE_PERCENTAGE) / 100 ;
if ($porciento < MODULE_SHIPPING_TABLEEXPEDITE_FORMULA3) {
$porciento = MODULE_SHIPPING_TABLEEXPEDITE_FORMULA3;
}
if (MODULE_SHIPPING_TABLEEXPEDITE_MODE == 'price') {
$order_total = $cart->show_total();
} else {
$order_total = $shipping_weight;
}
$EXPEDITE_cost = split("[:,]" , MODULE_SHIPPING_TABLEEXPEDITE_COST);
$size = sizeof($EXPEDITE_cost);
for ($i=0, $n=$size; $i<$n; $i+=2) {
if ($order_total <= $EXPEDITE_cost[$i]) {
$shipping = $EXPEDITE_cost[$i+1];
break;
}
}
if (MODULE_SHIPPING_TABLEEXPEDITE_MODE == 'weight') {
$shipping = $shipping * $shipping_num_boxes;
}
$prueba = MODULE_SHIPPING_TABLEEXPEDITE_HANDLING . ' ' . $total_count . ' ' . $shipping_weight;
$coste = (MODULE_SHIPPING_TABLEEXPEDITE_HANDLING) + ($shipping_weight);
$coste = ($coste * MODULE_SHIPPING_TABLEEXPEDITE_FORMULA1) + (MODULE_SHIPPING_TABLEEXPEDITE_FORMULA2);
$coste = $coste + $porciento;
if ($shipping_weight == 0) {
$coste = 0;
}
if ($cart->show_weight() == 0) {
$coste = MODULE_SHIPPING_TABLEEXPEDITE_GIFTCARD;
}
$coste = $coste * $total_count;
$duedate = strftime('%A, %B %d, %Y',calcduedate(time(),MODULE_SHIPPING_TABLEEXPEDITE_BUSINESS_DAYS));
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLEEXPEDITE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLEEXPEDITE_TEXT_WAY,
'porciento' => $porciento,
'ordertotal' => $cart->show_total(),
'duedate' => $duedate,
'cost' => $coste)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
return $this->quotes;
}
function quote($method = '') {
global $order, $cart, $shipping_weight, $shipping_num_boxes, $total_count;
$porciento = ($cart->show_total() * MODULE_SHIPPING_TABLESUPERRUSH_PERCENTAGE) / 100 ;
if ($porciento < MODULE_SHIPPING_TABLESUPERRUSH_FORMULA3) {
$porciento = MODULE_SHIPPING_TABLESUPERRUSH_FORMULA3;
}
if (MODULE_SHIPPING_TABLESUPERRUSH_MODE == 'price') {
$order_total = $cart->show_total();
} else {
$order_total = $shipping_weight;
}
$table_overnight_cost = split("[:,]" , MODULE_SHIPPING_TABLESUPERRUSH_COST);
$size = sizeof($table_overnight_cost);
for ($i=0, $n=$size; $i<$n; $i+=2) {
if ($order_total <= $table_overnight_cost[$i]) {
$shipping = $table_overnight_cost[$i+1];
break;
}
}
if (MODULE_SHIPPING_TABLESUPERRUSH_MODE == 'weight') {
$shipping = $shipping * $shipping_num_boxes;
}
$prueba = MODULE_SHIPPING_TABLESUPERRUSH_HANDLING . ' ' . $total_count . ' ' . $shipping_weight;
//echo $prueba;
$coste = (MODULE_SHIPPING_TABLESUPERRUSH_HANDLING) + ($shipping_weight);
$coste = ($coste * MODULE_SHIPPING_TABLESUPERRUSH_FORMULA1) + (MODULE_SHIPPING_TABLESUPERRUSH_FORMULA2);
$coste = $coste + $porciento;
if ($shipping_weight == 0) {
$coste = 0;
}
if ($cart->show_weight() == 0) {
$coste = MODULE_SHIPPING_TABLESUPERRUSH_GIFTCARD;
}
$coste = $coste * $total_count;
$duedate = strftime('%A, %B %d, %Y',calcduedate(time(),MODULE_SHIPPING_TABLESUPERRUSH_BUSINESS_DAYS));
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLESUPERRUSH_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLESUPERRUSH_TEXT_WAY,
'duedate' => $duedate,
'cost' => $coste)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
return $this->quotes;
}
答案 0 :(得分:2)
两个文件都以相同的方式计算运费。这是同样的方法。唯一的区别是变量名称和每个出货模块的保存值。
要查看报价运费不同的原因,请比较每个运送选项中admin / database中保存的值。
要真正理解这些值的来源,最好在你旁边拿一张纸,然后将这些值存储在此模块的配置中,并在记录时记下值和数学
以下是计算成本的方法中正在发生的事情的翻译: