1

I try to change the shipping total title in the checkout review table. I have found where the label text is constructed,Mage_Sales_Model_Quote_Address_Total_Shipping::fetch() method is where I want to override the text, the method looks like this:

public function fetch(Mage_Sales_Model_Quote_Address $address)
{
    $amount = $address->getShippingAmount();
    if ($amount != 0 || $address->getShippingDescription()) {
        $title = Mage::helper('sales')->__('Shipping & Handling');

        /** the following if block is what I want to remove as I don't want
         *  extra text in the parenthesis
         */
        if ($address->getShippingDescription()) {
            $title .= ' (' . $address->getShippingDescription() . ')';
        }

        $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => $title,
            'value' => $address->getShippingAmount()
        ));
    }
    return $this;
}

Please notice my comment in above code, I try to do it by overriding the class in my local directory, I have done it many times to other model classes, never had a problem, but I am stuck at this one...

My module config.xml (app/code/local/MyCompany/Sales/etc/config.xml)

<?xml version="1.0"?>
<config>
  <modules>
    <MyCompany_Sales>
      <version>0.1</version>
    </MyCompany_Sales>
  </modules>
  <global>
    <models>
      <sales>
        <rewrite>
           <quote_address_total_shipping>MyCompany_Sales_Model_Quote_Address_Total_Shipping</quote_address_total_shipping>
        </rewrite>
      </sales>
    </models>
  </global>
</config>

app/etc/modules/MyCompany_Sales.xml

<?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_Sales>
            <active>true</active>
            <codepool>local</codepool>
        </MyCompany_Sales>
    </modules>
</config>

My own model class file: (app/code/local/MyCompany/Sales/Model/Quote/Address/Total/Shipping.php)

class MyCompany_Sales_Model_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Shipping
{
  /**
   * Override to get rid of text between parenthesis
   */
  public function fetch(Mage_Sales_Model_Quote_Address $address)
  {
      $amount = $address->getShippingAmount();
      if ($amount != 0 || $address->getShippingDescription()) {
          $title = Mage::helper('sales')->__('Shipping & Handling');

          $address->addTotal(array(
              'code' => $this->getCode(),
              'title' => $title,
              'value' => $address->getShippingAmount()
          ));
      }
      return $this;
  }
}

Please help! I am running out of ideas. I reaaaly don't want to make changes to core files.

Many thanks!

2 Answers 2

1

you also need to define two part in you config.xml

 <global>
  ...
    <models>
        <mycompany_sale>
            <class>MyCompany_Sale_Model</class>
        </mycompany_sale>
    </models>

    <helpers>
        <mycompany_sale>
            <class>MyCompany_Sale_Helper</class>
        </mycompany_sale>
    </helpers>
   ...
  </global>  

then it should be working on rewrite part.

1

It appears that your file app/etc/modules/MyCompany_Sales.xml has a common error in it.

It has codepool but it should be codePool with a capital P otherwise the whole extension will not be loaded.

You can check if an extension really is loaded by checking in the admin system config under advanced to see if your extension is in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.