This is an old revision of the document!
Remove days timeframe from USPS rates
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
Add the following to the “custom footer” field of the “Add custom header and footer code to your templates” section in your store's FoxyCart administration, in TEMPLATES » configuration:
{% if context == 'cart' or context == 'checkout' %}
<script type="text/javascript">
function customUSPSLabelFilter(params) {
var addresses = FC.json.has_multiship ? FC.json.multiship_data : [FC.json.shipping_address];
if (typeof(params) == "object" && params.hasOwnProperty("address")) {
addresses = [params.address];
}
$.each(addresses, function(i, address) {
for (var i = 0; i < address.shipping_results.length; i++) {
var reg = /\d-day/i;
var service = address.shipping_results[i].service_name;
if (reg.test(service)) {
address.shipping_results[i].service_name = service.replace(reg, "").trim();
}
var saved_service = address.shipping_service_description;
if (reg.test(saved_service)) {
address.shipping_service_description = saved_service.replace(reg, "").trim();
}
};
FC.Template(FC.json.context).clearOutput();
FC.cart.recalculateCartTotals();
FC[FC.json.context].renderShippingRates(address);
});
}
FC.client.on('cart-shipping-options-update.done', customUSPSLabelFilter );
FC.client.on('checkout-shipping-options-update.done', customUSPSLabelFilter );
FC.client.on('customer-login.done', customUSPSLabelFilter );
{% if cart_is_fullpage or context == 'checkout' %}FC.client.on("ready.done",customUSPSLabelFilter);{% else %}customUSPSLabelFilter();{% endif %}
</script>
{% endif %}
Alternatively you can also add this code right at the end of the cart include template (not the cart or checkout templates, the cart include template will include it there for you).