|
<<prev |
1 |
2 |
3 |
4 |
5 |
next>>
Smart Shipping Based on Country - The Basics
RealCart was designed to be infinitely customizable. Nowhere does this promise hold more true than in the JavaScript functions of RealCart. Although you do not need to know any JavaScript to customize RealCart or to participate in this course and subsequently modify your RealCart shipping routines, it wouldnt hurt to read a book entitled JavaScript for the World Wide Web from Peachpit Press. It is only 195 pages long but it contains everything you need to become a weekend warrior JavaScript coder. Never-the-less, having zero JavaScript knowledge is just fine for the purpose of attending this course.
RealCart was designed to allow multiple shipping options, however RealCart was not originally programmed to restrict domestic shipping to only those customers that buy from you in your own country. Since there is no limit on the amount of shipping options you can enter into RealCart it is only natural for some of our users to define domestic shipping options as well as international shipping options. If you are a merchant that sometimes sells outside your home country you may be interested in doing this very easy modification to force RealCart to restrict shipping methods based on the country where the shopper resides.
For example. Until recently shop.RealCart.com had only two shipping methods defined:
- Priority Mail
- Federal Express
Since neither of these methods was created with the idea of international shipping in mind RealCart.com clearly needed to add a third or fourth method that focuses only on international shipping. So they added:
- Global Priority
- FedEx World Wide
The problem is that a shopper that lives in the UK can currently come into your store and purchase a product from your store in the USA and select domestic shipping (a USA shipping charge) instead of being forced to select an international shipping charge. This can result in a somewhat awkward position if an international customer chooses USPS Priority Mail as his or her choice of shipping.
For the purpose of this course we are going to focus on forcing RealCart to charge international shipping charges ONLY when someone from outside your home country is buying from your store. This course, although fairly short, will completely explain how to get RealCart to allow the shopper to choose only international shipping on international orders. Domestic shipping methods wont take anymore when someone outside your home country tries to order from you. If domestic shipping is attempted on an international order RealCart alerts your shopper that they must choose a different shipping method.
Clone jsship.snp
Clone the file jsship.snp and then open the cloned copy in your current theme folder in a text editor. Locate the following block of code. It should appear somewhere around the 60th to 65th line of the snippit file. You are looking for:
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;
// Remove any shipping that was added the the cart from
// a previous selection.
parent.app.document.cart.RemoveShipping();
// alert("ship index = " + i);
var strLabel = shipOption[nIndex].Label;
var strTotalShipCharge = nTotalShipCharge.toString();
// Finally, update the cart with the shipping charge.
This is the section of code we are going to modify to achieve our goal of international shipping only on all international orders. First lets take a look at the shipping options you have defined. In the case of RealCart.com we have:
- Priority Mail
- Federal Express
- Global Priority
- FedEx World Wide
These are numbered starting at zero (0) and are therefore identified as follows:
- Method 0 = Priority Mail (domestic)
- Method 1 = Federal Express (domestic)
- Method 2 = Global Priority (international)
- Method 3 = FedEx World Wide (international)
Keep in mind that JavaScript always numbers multiple objects starting at zero. This will be important later on in this course. With this numbering system the two domestic shipping methods are #0 and #1 while the two international methods are #2 and #3.
<<prev |
1 |
2 |
3 |
4 |
5 |
next>>
|