3

Shipping quote from USPS display something like:

Priority Mail 1-Day $6.60

What's the proper way to change that so it only displays as "Priority Mail"?

4

We were having the same issue with USPS so we made a module that overrides the _filterServiceName() function. This allows us to get rid of any "number of days" type info, with the ability to change it per-store from the Admin, and no need to manually add each "translation" like the other answer suggests.

app/code/local/YourNamespace/Usps/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <YourNamespace_Usps>
            <version>0.0.1</version>
        </YourNamespace_Usps>
    </modules>
    <global>
        <models>
            <usa>
                <rewrite>
                    <shipping_carrier_usps>YourNamespace_Usps_Model_Usa_Shipping_Carrier_Usps</shipping_carrier_usps>
                </rewrite>
            </usa>
        </models>
    </global>
</config>

app/code/local/YourNamespace/Usps/Model/Usa/Shipping/Carrier/Usps.php

<?php
class YourNamespace_Usps_Model_Usa_Shipping_Carrier_Usps extends Mage_Usa_Model_Shipping_Carrier_Usps {
    function _filterServiceName($name) {
        $name = parent::_filterServiceName($name);


        if( !Mage::getStoreConfig('carriers/usps/show_number_of_days') )
            $name = preg_replace('/\s+?\d+-day/i', '', $name); // Trim out the number of days, and an optional leading space.

        return $name;
    }
}

app/code/local/YourNamespace/Usps/etc/system.xml

<config>
    <sections>
        <carriers>
            <groups>
                <usps>
                    <fields>
                        <show_number_of_days translate="label">
                            <label>Show Number of Days</label>
                            <comment>If set to "No", "Priority Mail 3-Day", "Priority Mail 2-Day" and "Priority Mail 4-Day" will all show up as "Priority Mail".</comment>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>129</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </show_number_of_days>
                    </fields>
                </usps>
            </groups>
        </carriers>
    </sections>
</config>

app/etc/modules/YourNamespace_Usps.xml

<?xml version="1.0"?>
<config>
    <modules>
        <YourNamespace_Usps>
            <active>true</active>
            <codePool>local</codePool>
        </YourNamespace_Usps>
    </modules>
</config>

Config Section

Config Section

Before:

Before

After:

After

1

The answer is in: override USPS shipping method name.

make a copy of app/code/core/Mage/Sales/Model/Quote/Address/Rate.php to app/code/community/Mage/Sales/Model/Quote/Address/Rate.php

then replace

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

with

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

And add appropriate translations into the Mage_Shipping.csv file.

H/T Amasty for the answer.

note that I couldn't get this to work in 1.6.2, but it works fine in 1.9.0.1

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.