RealCart UNIVERSITY
Courses [Home]  [Search]  [Index]  [Help]  [Help]

Higher Learning for the Internet’s most effective shopping cart - Attend On-line.

<<prev | 1 | 2 | 3 | 4 | 5 | next>>

Smart Shipping Based on Country - Modifying jsship.snp

Now we need to modify jsship.snp. Open it in a text editor like notepad or editpad. Locate the following block of code (should be close to the top around lines 13-18.)

// Shipping type constants. Javascript doesn't support (...)
// I've just declared them as variables with upper case notation.
var WEIGHT = 1;
var QUANTITY = 2;
var PRICE = 3;
var FLATRATE = 4;

After var FLATRATE = 4; we are going to add the following 2 lines.

// Added by "Smart Shipping" RealCartU
var nIdx = 0;

The entire block of code now looks like this: (new code in bright blue, existing code in dark blue.)

// Shipping type constants. Javascript doesn't support (...)
// I've just declared them as variables with upper case notation.
var WEIGHT = 1;
var QUANTITY = 2;
var PRICE = 3;
var FLATRATE = 4;
// Added by "Smart Shipping" RealCartU
var nIdx = 0;

NOTE: There is a trick in JavaScript that allows you to see what the value of a particular variable is by displaying it in an alert box. This trick will be used throughout this course (and subsequent courses) to assist you in debugging your customization.

Next we are going to enable an existing alert box in the jsship.snp snippit file by locating the following two lines in jsship.snp:

    // alert("ship index = " + i);
    var strLabel = shipOption[nIndex].Label;

Remove the two slashes before the word “alert” so that alert is the first thing to occur on this line:

    alert("ship index = " + i);
    var strLabel = shipOption[nIndex].Label;

NOTE: Anytime you see double slashes (//) in JavaScript this would indicate that everything following (to the right of) the slashes is a comment. HTML code has comments too but they are preceded by <!-- and followed by -->.

We are now going to add another line of code to jsship.snp just after the alert statement where you removed the two slashes. The line of code we are going to add is as follows:

    alert("ship index = " + i);
    alert("country index = " + nIdx);
    var strLabel = shipOption[nIndex].Label;

We will want to comment these back out by placing double slashes // just before both of the words alert on these two lines after we are done testing our new snippit file (see page 5). Next go up a few lines to this point in the file:

function UpdateShipping(i)
{
  // make a copy so value doesn't change in calling function.
  var nIndex = i;

  if(isFramed)
  {

    var nHandlingFee = shipOption[nIndex].HandlingFee;
    var nShipCharge = GetShippingCharge(nIndex);
    var nTotalShipCharge = nShipCharge + nHandlingFee;

Next we are going to paste 30+ lines of code between:

  if(isFramed)
  {

and

    var nHandlingFee = shipOption[nIndex].HandlingFee;
    var nShipCharge = GetShippingCharge(nIndex);
    var nTotalShipCharge = nShipCharge + nHandlingFee;

<<prev | 1 | 2 | 3 | 4 | 5 | next>>


About RealCart U | Courses | Admissions | Administration | Alumni | Directories | Case Studies | Help

Contact the Webmaster staff
Copyright information
Privacy statement

Copyright © 1995-2002, RealCartUniversity.com