2

This is a follow-up of sorts to : shipping method name alias.

The issues I found: 1) the translate.csv works like a charm for UPS shipping. it does NOT work for USPS 2) the change to escapeHtml($_rate->getMethodTitle()) ?>

works fine, but you have to do it in 14 different locations, thus making maintenance a nightmare. 3) the change suggested in the thread will only affect what is displayed on the screen, not what is in the DB, ergo, not what is emailed to the clients, or exported in reports, etc

what I really want to do is override the value upstream, after the response from USPS is received, before it gets consumed by the application and have that updated value in the database.

I'm wondering if the below, found in app/code/core/Mage/Sales/Model/Quote/Address/Rate.php would be a good place to do it.

public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
{
    if ($rate instanceof Mage_Shipping_Model_Rate_Result_Error) {
        $this
            ->setCode($rate->getCarrier().'_error')
            ->setCarrier($rate->getCarrier())
            ->setCarrierTitle($rate->getCarrierTitle())
            ->setErrorMessage($rate->getErrorMessage())
        ;
    } elseif ($rate instanceof Mage_Shipping_Model_Rate_Result_Method) {
        $this
            ->setCode($rate->getCarrier().'_'.$rate->getMethod())
            ->setCarrier($rate->getCarrier())
            ->setCarrierTitle($rate->getCarrierTitle())
            ->setMethod($rate->getMethod())
            ->setMethodTitle($rate->getMethodTitle())
            ->setMethodDescription($rate->getMethodDescription())
            ->setPrice($rate->getPrice())
        ;
    }
    return $this;
}

Also, I think that once I use a standardized text, then the translate.csv actually does become active, but that's secondary.

Thanks !

  • Have you tried the solution? Does it work? – Amasty Sep 26 '14 at 10:18
  • that's the thing, I'm not a developer.... I tried adding logic in the elsif, but it didn't seem to take effect, or do anyhting, for that matter, so I'm not even sure that this piece of code is used in the view cart page... – provence shop Sep 26 '14 at 14:06
  • OK, I commented out ->setMethodTitle($rate->getMethodTitle()) and it sorta did what I wanted by setting the method title to blank across the board. I just need someone to spoon-feed me how to add logic in this based on the value of $rate->getMethodTitle() . Yes, I'm clueless at this point – provence shop Sep 29 '14 at 19:37
  • if you change it to any not empty string, like "test", does it work? – Amasty Sep 29 '14 at 20:58
  • Amasty, yes. if I replace it with ->setMethodTitle("rate") then the string "rate" is displayed – provence shop Oct 1 '14 at 0:20
1

Please replace

->setMethodTitle($rate->getMethodTitle())

with

->setMethodTitle(Mage::helper('shipping')->__($rate->getMethodTitle()))

And add appropriate translations into the Mage_Shipping.csv file.

  • 1
    IT WORKED! I can't believe such a simple change is all it took. Thank you Amasty. I use a handful of your extensions already, but I'll be sure to go see what else is out there from you! – provence shop Oct 1 '14 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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