magento 自定义评论页面总计文本(运费和手续费(统一费率-固定))

flvlnr44  于 2023-01-17  发布在  其他
关注(0)|答案(1)|浏览(114)

在Magento的onepage checkout中的查看订单页面上,我想缩短“Shipping & Handling(Flat Rate - Fixed)”文本(参见http://d.pr/AAlb)。我想让它只显示“Shipping & Handling”,并删除括号中的承运人/交货类型
我该怎么做呢?它是用$this->renderTotals(null, $_colspan);渲染的,它给了我运费+小计。我不知道从哪里开始。

wn9m85ua

wn9m85ua1#

这是我做过的一个实现,这是一个标准的重写(http://inchoo.net/ecommerce/magento/how_to_override_magento_model_classes/),我这样做是为了不太深入重写系统。

class Your_Company_Model_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Shipping
{

    /**
     * Collect totals information about shipping
     *
     * @param   Mage_Sales_Model_Quote_Address $address
     * @return  Mage_Sales_Model_Quote_Address_Total_Shipping
     */
    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        parent::collect($address);

        $method = $address->getShippingMethod();

        if ($method) {
            foreach ($address->getAllShippingRates() as $rate) {
                if ($rate->getCode()==$method) {
                    $shippingDescription = $rate->getMethodTitle();
                    if (stripos($shippingDescription, ",") > -1)
                        $shippingDescription = substr($shippingDescription, 0, stripos($shippingDescription, ","));
                    $address->setShippingDescription(trim($shippingDescription, ' -'));
                    break;
                }
            }
        }

        return $this;
    }
}

相关问题