The question:
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 !
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
Please replace
->setMethodTitle($rate->getMethodTitle())
with
->setMethodTitle(Mage::helper('shipping')->__($rate->getMethodTitle()))
And add appropriate translations into the Mage_Shipping.csv
file.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0