1

我有以下问题:我必须主要运输方式。第一个对 200 美元以下的订单收取 10 美元的运费。第二种方法是默认免费送货,适用于 200 美元以上的订单。

应用免费送货时,运输和处理小计显示 0.00,我不希望此行既不显示在结帐中,也不显示在发票中。

使用免费送货时,有什么方法可以完全移除运输和装卸线?

提前感谢您的任何想法。

4

2 回答 2

2

I dislike filtering things like this by code. So I came up with a solution overriding Mage_Sales_Model_Quote_Address_Total_Shipping::fetch(Mage_Sales_Model_Quote_Address $address)

app/code/local/Me/MyModule/Model/Sales/Quote/Address/Total/Shipping.php:

<?php
class Me_MyModule_Model_Sales_Quote_Address_Total_Shipping
  extends Mage_Sales_Model_Quote_Address_Total_Shipping
{
    /**
     * Add shipping totals information to address object
     *
     * @param   Mage_Sales_Model_Quote_Address $address
     * @return  Mage_Sales_Model_Quote_Address_Total_Shipping
     */
    public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
        if ($address->getShippingAmount() == 0) {
            return $this;
        }

        return parent::fetch($address);
    }
}

app/code/local/Me/MyModule/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Me_MyModule>
      <version>0.0.1</version>
    </Me_MyModule>
  </modules>
  <global>
    <models>
      <me_mymodule>
        <class>Me_MyModule_Model</class>
      </me_mymodule>
      <sales>
        <rewrite>
          <quote_address_total_shipping>Me_MyModule_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
        </rewrite>
      </sales>
    </models>
  </global>
</config>

app/etc/modules/Me_MyModule.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Me_MyModule>
            <active>true</active>
            <codePool>local</codePool>
        </Me_MyModule>
    </modules>
</config>
于 2014-03-24T00:36:35.110 回答
1

从购物车和结帐中删除运输线,您可以覆盖此方法 Mage_Checkout_Block_Cart_Totals::renderTotal()

public function renderTotal($total, $area = null, $colspan = 1)
{
    $code = $total->getCode();
    if ($total->getAs()) {
        $code = $total->getAs();
    }
   if ($code == 'shipping' && $total->getValue() == 0) {
       return '';
   }
    return $this->_getTotalRenderer($code)
        ->setTotal($total)
        ->setColspan($colspan)
        ->setRenderingArea(is_null($area) ? -1 : $area)
        ->toHtml();
}

有关更多参考,请查看此链接http://www.magentocommerce.com/boards/viewthread/295412/#t410854

于 2013-03-21T08:24:49.163 回答