| tero.co.uk | |||||
|
Quick links:
|
Shopable - ShippingBelow the language settings in settings.html is the shipping and tax information. The shipping and tax policies are loosely based around the UK, but can be easily amended for other countries. In summary, Shopable computes tax for every order, on a per item basis (as different items can have different tax rates). The country table specifies to which countries this tax should be charged (based on tax regions). The shipping function computes shipping based on the country, weight and subtotal.
Shipping and Handling
Tax As a quick example, if you sell all your products with 5% tax, you could include the line s.tax.standard = 5. If you do not charge tax on shipping then include the line s.tax.exempt = 0 and in the above section set s.shippingTax = "exempt". The next section declares in which regions of the world tax is charged. This ties in with the country table. The line s.chargetax.eu = true; charges the taxes set above to Europe. Note that this only turns taxing on or off for individual regions, if there was no tax to begin with, this won't add any.
Shipping Function For example, the following function implements free shipping, but with a limit of 10 kilograms. function computeShipping (shippingregion, weight, subtotal) {
if (weight > 10) {return -1;} //if this order is just too heavy, return -1
return 0; //return 0 for free
}
The next example charges £5 if the subtotal is less than £50, and free if not. function computeShipping (shippingregion, weight, subtotal) {
if (weight > 10) {return -1;} //if this order is just too heavy, return -1
if (subtotal < 50) {return 5;} else {return 0;}
}
This one uses the shipping region and charges by the kilogram. The shipping region comes from the country table. function computeShipping (shippingregion, weight, subtotal) {
if (weight > 10) {return -1;} //if this order is just too heavy, return -1
if (shippingregion == "uk") {return weight * 3;} //£3 per kilogram in the uk
if (shippingregion == "eu") {return weight * 10;} //£10 per kilogram in europe
return weight * 20; //£20 per kilogram everywhere else
}
This one is free to Europe, with a maximum weight of 10kg, and 15% of the subtotal to everywhere else, with a maximum weight of 5kg. function computeShipping (shippingregion, weight, subtotal) {
if (shippingregion == "eu") { //for Europe
if (weight > 10) {return -1;} //too heavy for Europe
else {return 0;} //or else shipping is free
}
else { //for anywhere else
if (weight > 5) {return -1;} //too heavy for anywhere
else {return subtotal * 0.15;} //or else 15% of the subtotal
}
}
Country Table
Example Your basic settings might look like this. s.showTotals = true; s.showHandling = true; s.handlingCharge = 2; s.shippingTax = "standard"; //the type of tax to charge on the shipping s.showTax = true; //charge tax and show it in the basket Then you would need to define the tax bands. This will charge 8.25% sales tax within California. s.tax.standard = 8.25; The next line says that any order from a "country" with a tax region of california will be charged tax. All others won't. s.chargetax.california = true; Our shipping function charges based on the subtotal and shipping region. function computeShipping (shippingregion, weight, subtotal) {
if (weight > 10) {return -1;} //if this order is just too heavy, return -1
if (subtotal < 200) { //for orders with a subtotal less than $200
if (shippingregion == "us") {return 5;} //$5 within the US
else {return 10;} //$10 elsewhere
}
else {return 0;} //free shipping on large orders
}
Finally we set up the country listings. Here we will use the country table to differentiate states as well. Note how the tax and shipping regions correspond to chargeTax and computeShipping above. cC ("Canada", 0, 0); //cC is short for createCountry
cC ("Mexico", 0, 0); //no special tax or shipping region
cC ("United States (California only)", "california", "us"); //california tax region
cC ("United States (except California)", 0, "us"); //us shipping region
|
||||