How to add delivery days to USPS in main shopping cart page

General ShopSite user discussion

How to add delivery days to USPS in main shopping cart page

Postby jsherk » Wed Nov 11, 2009 6:12 pm

One feature that I believe is lacking, is the display of how many days each method of delivery will take. I only use USPS, so I am not sure how the other carriers display there information, but that particular info is not displayed when the different USPS methods are displayed.

So here is some JavaScript that will add the info to the page.

You will need to modify your theme shopping cart .sst template file, and in the [-- DEFINE ShoppingCart --] section, look for this line:
Code: Select all
[-- SC_JAVASCRIPT extras --]

And add this include line right after it:
Code: Select all
[-- INCLUDE myCustom.js --]

Then look for these lines:
Code: Select all
<body
[-- IF STORE.SC_BackgroundImage --]
  background="[-- STORE.SC_BackgroundImage --]"
[-- END_IF --]

And modify it like this with an onLoad:
Code: Select all
<body onLoad="myOnLoad();"
[-- IF STORE.SC_BackgroundImage --]
  background="[-- STORE.SC_BackgroundImage --]"
[-- END_IF --]

Now here is the myCustom.js file that you need to include:
Code: Select all
function myOnLoad () {

////////Add delivery time/days to Shipping Options
      var _allnames = document.getElementsByName('shipping'); //Find everything with the name shipping
      var _len = _allnames.length; //How many items are there?
      if (_len >= 1) { //Make sure there is at least 1 item
        for (_j=0; _j<_len; _j++) { //Loop thru each item
          var _nodetype = _allnames[_j].nodeType; //Get the node type
          var _name = 0;
          if (_allnames[_j].attributes.getNamedItem('name')) {
            _name = _allnames[_j].attributes.getNamedItem('name').value;
          }
          var _type = 0;
          if (_allnames[_j].attributes.getNamedItem('type')) {
            _type = _allnames[_j].attributes.getNamedItem('type').value;
          }
          if (_nodetype == 1) {
            if ( (_name == 'shipping') && (_type == 'radio')  ) { //Look for these specific things to get the correct node (INPUT tag in this case)
              var _text_node = _allnames[_j]; //This is the node we were looking for
              var _old_text = _text_node.nextSibling.nodeValue; //Get the text from the node beside it
              if (_old_text.substr(0,14) == ' Media Mail® (' ) { //Ends with a ( so it's US only
                _new_text = _old_text +' 2-8 business days';
              } else if (_old_text.substr(0,15) == ' Parcel Post® (' ) { //Ends with a ( so it's US only
                _new_text = _old_text +' 2-8 business days';
              } else if (_old_text.substr(0,17) == ' Priority Mail® (' ) { //Ends with a ( so it's US only
                _new_text = _old_text +' 1-3 business days';
              } else if (_old_text.substr(0,16) == ' Express Mail® (' ) { //Ends with a ( so it's US only
                _new_text = _old_text +' 1-2 business days';
              } else if (_old_text.substr(0,20) == ' First Class Mail® I' ) { //Ends with an I so it's International
                _new_text = _old_text +' Delivery times vary';
              } else if (_old_text.substr(0,17) == ' Priority Mail® I' ) { //Ends with an I so it's International
                _new_text = _old_text +' 6-10 business days';
              } else if (_old_text.substr(0,16) == ' Express Mail® I' ) { //Ends with an I so it's International
                _new_text = _old_text +' 3-5 business days';
              } else if (_old_text.substr(0,27) == ' Global Express Guaranteed®' ) { //Global Express is always International
                _new_text = _old_text +' 1-3 business days';
              } else {
                _new_text = _old_text;
              }
              _text_node.nextSibling.nodeValue = _new_text;
            }
          }
        }
      }
//////// END Add delivery time/days to Shipping Options

} // end myOnLoad
jsherk
 
Posts: 41
Joined: Sun Oct 11, 2009 3:19 pm
Location: USA

Postby jsherk » Thu Nov 12, 2009 10:05 am

Just an additional note about the above mod...

- I tested it in ShopSite v10 Pro only.

- It assumes you are using the Radio Buttons for choosing a shipping option, not the drop down selection menu.

Hope this is useful to somebody.
jsherk
 
Posts: 41
Joined: Sun Oct 11, 2009 3:19 pm
Location: USA


Return to User Forum

Who is online

Users browsing this forum: No registered users and 125 guests