Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
snippets:shipping:remove_day_timeframe_from_usps_rates [2013/08/07 02:51] adamsnippets:shipping:remove_day_timeframe_from_usps_rates [2017/04/26 07:02] (current) – external edit 127.0.0.1
Line 13: Line 13:
  
 ====== Remove days timeframe from USPS rates ====== ====== Remove days timeframe from USPS rates ======
 +
 +<WRAP center round important 80%>
 +**Using version 2.0?** There is a new snippet available for our latest version, [[v:2.0:snippets:remove_usps_day_timeframe_label|available from here]].
 +</WRAP>
  
 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, [[https://www.usps.com/making-priority-mail-better.htm|see their website]]. 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, [[https://www.usps.com/making-priority-mail-better.htm|see their website]].
Line 24: Line 28:
 <script type="text/javascript" charset="utf-8" > <script type="text/javascript" charset="utf-8" >
 jQuery(document).ready(function() { jQuery(document).ready(function() {
- jQuery(document).ajaxComplete(function(event, request, settings) { +    jQuery(document).ajaxComplete(function(event, request, settings) { 
- if (settings.url.indexOf('GetShippingCost') != -1) { +        if (settings.url.indexOf('GetShippingCost') != -1) { 
- jQuery(".fc_shipping_service").each(function() { +            UpdateUSPSRates(); 
- var reg = /\d-day/i+        } 
- var service = jQuery(this).html(); +    }); 
- if (reg.test(service)) { +         
- jQuery(this).html(service.replace(reg, "").trim()); +    // 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> </script>
 </code> </code>

Site Tools