了解osCommerce中加急和超急运费的差异

时间:2011-06-24 01:40:20

标签: php oscommerce

我很难理解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;
}

Super Rush

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;
}

1 个答案:

答案 0 :(得分:2)

两个文件都以相同的方式计算运费。这是同样的方法。唯一的区别是变量名称和每个出货模块的保存值。

要查看报价运费不同的原因,请比较每个运送选项中admin / database中保存的值。

要真正理解这些值的来源,最好在你旁边拿一张纸,然后将这些值存储在此模块的配置中,并在记录时记下值和数学

以下是计算成本的方法中正在发生的事情的翻译:

  1. 检查购物车总额的百分比成本是否超过指定的阈值
  2. 如果百分比成本(步骤1)低于最终值调整,则使百分比成本等于调整值
  3. 根据总成本或购物车总重量计算订单总数
  4. 细分和迭代费用表
  5. 如果购物车总成本/重量小于或等于费用表中的限额(步骤4),则应用作运费
  6. 如果按重量计算,则需要将运输成本乘以所需的箱数
  7. 将手续费(如有)添加到运费
  8. 将成本标记为配置中提到的值。为此费用添加额外的调整值
  9. 使用百分比成本添加费用(第2步)
  10. 如果运输重量为零,运费为零(0)(忽略前九个步骤)
  11. 如果购物车总重量为零,那么购物车的重量成本(礼品卡费用)
  12. 运费<运费(步骤1-11)*购物车中的商品数量