了解 osCommerce 中 Expedited 和 Super Rush 运输成本的差异

发布于 2024-11-16 20:07:56 字数 4832 浏览 3 评论 0原文

我很难理解 osCommerce 如何计算加急和超级加急运输模块的运输成本。

我正在寻找如何计算这些费用的英文解释。我得到了两个处理此问题的文件,但我很难理解发生了什么。

加急

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

I'm having a hard time understanding how osCommerce calculates shipping cost for the Expedited and Super Rush shipping modules.

I'm looking for an English explanation of how these costs are calculated. I was given two files that handle this but I have a hard time understanding what's going on.

Expedited

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟酒忠诚 2024-11-23 20:07:56

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

要了解报价的运输成本为何不同,请比较每个运输选项的管理/数据库中保存的值。

要真正了解这些值的来源,您最好在身边放一张纸,其中包含这些值,因为它们存储在该模块的配置中,并在您查看时记下这些值和数学。

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

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

Both files calculate the shipping cost in the same manner. It's the same method. The only differences are the variable names and the saved values per shipping module.

To see why the quoted shipping costs are different, compare the values as saved in the admin/database for each of those shipping options.

To really understand where the values are coming from, you're better off having a piece of paper beside you with the values as they're stored in the configuration for this module and write down the values and math as you go through.

Here's a translation of what's happening in the method to calculate the cost:

  1. Check if the percentage cost of cart total is over specified threshold
  2. If percentage cost (step 1) is below final value adjustment, make percentage cost equal to adjustment value
  3. Calculate order total based either on total cost or total weight of cart
  4. Breakdown and iterate through costs table
  5. If the total cart cost/weight is less than or equal to a limit in the costs table (step 4), apply as the shipping cost
  6. If calculating by weight, multiply shipping cost by quantity of boxes needed
  7. Add the handling fee (if any) to the shipping cost
  8. Markup the cost to the value mentioned in the configuration. Add extra adjustment value to this cost
  9. Add the cost with percentage cost (step 2)
  10. If shipping weight is zero, shipping cost is zero (0) (Ignores previous nine steps)
  11. If total cart weight is zero, charge cost for a cart that weighs nothing (gift card cost)
  12. Shipping cost = shipping cost (steps 1-11) * quantity of items in cart
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文