了解 osCommerce 中 Expedited 和 Super Rush 运输成本的差异
我很难理解 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个文件都以相同的方式计算运费。这是同样的方法。唯一的区别是变量名称和每个运输模块保存的值。
要了解报价的运输成本为何不同,请比较每个运输选项的管理/数据库中保存的值。
要真正了解这些值的来源,您最好在身边放一张纸,其中包含这些值,因为它们存储在该模块的配置中,并在您查看时记下这些值和数学。
以下是计算成本的方法中发生的情况的翻译:
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: