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 - Changing the home country

The easiest way to do this is to simply modify your pay.html template (whichever one you use) and change the 3rd country listed to your own. First you will want to clone your checkout template. Next, open it up in a text editor and look for the following lines of code:

    <option value="--">- Click to choose >>
    <option value="-- - ------------------">------------------------
    <option value="US">United States
    <option value="CA">Canada
    <option value="-- - ------------------">------------------------

If you are doing business from The U.K. you would want to change the 3rd line above to read:

    <option value="GB">United Kingdom

Now this block of code will look like this:

    <option value="--">- Click to choose >>
    <option value="-- - ------------------">------------------------
    <option value="GB">United Kingdom
    <option value="CA">Canada
    <option value="-- - ------------------">------------------------

In Australia? Change it to:

    <option value="--">- Click to choose >>
    <option value="-- - ------------------">------------------------
    <option value="AU">Australia
    <option value="CA">Canada
    <option value="-- - ------------------">------------------------

Changing other aspects of the code

The key elements of this modification are the home country definition. (We recommend placing it at the top, where United States first appears in our example)

    // Here is where the index value gets set:
    var nIdx = eval(document.pay.country.selectedIndex);

Here is where it determines if the home country is selected:

    if(nIdx != 2) // Home Country NOT selected
    {

Here is where it determines if anything is selected for the Country:

      if(nIdx == 0) // Country NOT selected - return
      {

If a country is selected and it is not the home country the following takes place:

        if((i == 0) || (i == 1))
        {

The above code determines if a domestic shipping method is chosen. In our example only the first and second shipping methods are domestic so the if statement tests to see if shipping is the first method (0) or the second method (1). If domestic shipping is chosen and the country chosen is not your home country then RealCart change the current shipping method to the 3rd (2) shipping method as well as alert the shopper with a pop up dialog. This all happens with the following lines of code:

          nIndex = 2; // 3rd ship option
          document.pay.shipCombo.selectedIndex = 2;
          alert("International Shipping Selected.");

You could just as easily have RealCart choose the 4th option (3) like this:

          nIndex = 3; // 4th ship option
          document.pay.shipCombo.selectedIndex = 3;
          alert("International Shipping Selected.");

Feel free to experiment with this function. You can try changing anything and everything to make it work the way you want it to. You can always start over by re-cloning the original jsship.snp and starting over.

The next page shows how to make sure the country reference in the new code we are adding is the appropriate one for the checkout method you are using.

<<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