1

如果尚未计算运费,我想在总计框中的行下方显示一条文字(要添加的额外运费)。'Subtotal'

这只是为了通知客户还有额外的运费,这将在后期(结帐)阶段添加到他们的订单中。

如果IF..ELSE尚未计算运费,是否可以显示此文本,如果已计算运费说明,则显示运费说明。

任何想法我可以修改哪些模板/核心文件来做到这一点?

提前致谢

编辑:总计框位于该行的 checkout/cart.phtml 中

   <?php echo $this->getChildHtml('totals'); ?>

检查 totals.phtml 我得到以下信息,

    <table id="shopping-cart-totals-table">
    <col />
    <col width="1" />
    <tfoot>
        <?php echo $this->renderTotals('footer'); ?>
    </tfoot>
    <tbody>
        <?php echo $this->renderTotals(); ?>
    </tbody>
    </table>

我检查了显示 SubTotal、Shipping (计算时)和 GrandTotal 的核心文件

app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php

  public function fetch(Mage_Sales_Model_Quote_Address $address)
  {
    $address->addTotal(array(
        'code'  => $this->getCode(),
        'title' => Mage::helper('sales')->__('Subtotal'),
        'value' => $address->getSubtotal()
    ));
    return $this;
  }

app/code/core/Mage/Sales/Modle/Quote/Address/Total/Shipping.php

  public function fetch(Mage_Sales_Model_Quote_Address $address)
  {
    $amount = $address->getShippingAmount();
    if ($amount != 0 || $address->getShippingDescription()) {
        $title = Mage::helper('sales')->__('Shipping & Handling');
        if ($address->getShippingDescription()) {
            $title .= ' (' . $address->getShippingDescription() . ')';
        }
        $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => $title,
            'value' => $address->getShippingAmount()
        ));
    }
    return $this;
  }

但我不确定这些文件是否需要编辑或其他文件。在此之后我无法继续,因此需要从这里获得外部帮助。

4

1 回答 1

0

使用 Subtotal.php 文件,我添加了另一个 IF 条件并更改了如下代码:

 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
    $amount = $address->getShippingAmount();
    /* MY MODIFIED CODE */
    if($amount == 0)
    {

            $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => Mage::helper('sales')->__('Subtotal <br/><span style="font-size:12px;color:#A4A5A7;">(Additional Shipping cost to be added)</span>'),
            'value' => $address->getSubtotal()
        ));
    }
    /* --------------- */
    else {
        $title = Mage::helper('sales')->__('Subtotal');
        $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => $title,
            'value' => $address->getSubtotal()
        ));
    }
    return $this;
 }

这在小计行之后添加了一行“要添加的额外运费”,非常好。

于 2012-06-15T17:05:10.127 回答