type:
snippet
category:
shipping
name:
Remove days timeframe from USPS rates
description:
USPS added "1-Day" to their priority rates, this removes them.
versions:
0.6.0, 0.7.0, 0.7.1, 0.7.2, 1.0, 1.1
tags:
snippets, advance
date:
2013-08-07

Remove days timeframe from USPS rates

Using version 2.0? There is a new snippet available for our latest version, available from here.

Recently USPS reworked their priority rates to make it clearer how long a given rate will take in transit. This can be confusing for customers, especially if the products you sell don't ship straight away. This snippet removes the “1-Day”, “2-Day” etc from the rate names. For details on the changes USPS made, see their website.

Step 1: Add Javascript

Paste the following code right before the closing </head> tag of your checkout template:

<script type="text/javascript" charset="utf-8" >
jQuery(document).ready(function() {
    jQuery(document).ajaxComplete(function(event, request, settings) {
        if (settings.url.indexOf('GetShippingCost') != -1) {
            UpdateUSPSRates();
        }
    });
 
    // Run on page load in case rates already exist
    UpdateUSPSRates();
});
 
function UpdateUSPSRates() {
    jQuery(".fc_shipping_service").each(function() {
        var reg = /\d-day/i;
        var service = jQuery(this).html();
        if (reg.test(service)) {
            jQuery(this).html(service.replace(reg, "").trim());
        }
        var saved_service = jQuery("#shipping_service_description").val();
        if (reg.test(saved_service)) {
            jQuery("#shipping_service_description").val(saved_service.replace(reg, "").trim());
        }
    });
}
</script>

Site Tools