Back to Mal's forms page
<<< Clicking on this logo will return you to my Mal's Forms home page.


View the page source!

close

External shipping calculator.

Please read ALL of this page to get a complete understanding of how we read the URL sent from Mal's and bring that information into a javascript then into a form to calcualte the shipping. If you have any questions, please contact me.

As with all of my forms, you will need to change the return URL, server number and id to yours.

With this eaxmple, you can have as many different postcodes in your external scripts as you need, you can have as many shipping options/forms as you need, you can have as many units or price breaks as you need.

If you need a specific external shipping calculator building, please get in touch.


Japanese Kikkoman Soy £4.95 qty:  

Checkout


Standard Delivery Option
Express Delivery Option


First, you need to use as the shipping, option 8, I've used as the URL:
To calculate the shipping for your order, please <a href="http://www.malsforms.com/external-shipping-calculator.html?{x}">click here<a>.
DO NOT use a # (anchor) in the URL as using one will break Mal's URL coding.

In each internal script, the first thing we need to do is read the information from the URL that is passed from Mal's to our page:
http://www.malsforms.com/external-shipping-calculator.html?units=50&value=49.50&return=no&lg=14&sd=
We do this using the first part of each inbuilt script. As you can see, the units value is 50, this is because I have passed a units value of 5 to Mal's with the product that I have ordered 10 of, hence 'units=50&value=49.50' in the URL. We could have each script read the URL and use EITHER the 'units' or the 'value' (total cart value) to calculate the shipping.

To do this, we use the first part of the script and change this line to suit:
var totalprice = queryString('value');
this reads the total price value, or use:
var totalprice = queryString('units');
this reads the units number value.

If you look at the line below that one, you will see where we are converting the number collected from the URL, and transferring it to the form:
var totalprice = queryString('value');
document.form1.totalunit.value=totalprice;

Now look at a form and you will see where the form is collecting this information in the input 'totalunit' by using the script to pass the total price value from Mal's and using it in the form:
<input type="hidden" name="totalunit">

So, we have now read either the total units or the total value in $'s / £'s of the URL sent from Mal's. Next, in this example, we need to read the zip/postcode of the order to calculate the correct shipping based on the zip / postcode and the value of the order.


The form captures the zip / postcode and shows the viewer what they have entered, this value is shown in the order email sent to you as a confirmation of their typed zip / postcode (in case it differs from the postcode used at Mal's).

With this example, the business ONLY delivers to a restricted list of postcodes:

Postcodes that ARE charged the additional £3.00 shipping:

BR2 BR7 CR0 CR7 CR9 E1 E13 E14 E16 E2 E3 E5 EC1A EC1M EC1N EC1P EC1R EC1V EC1Y EC2A EC2M EC2N EC2P EC2R EC2V EC2Y EC3A EC3M EC3N EC3P EC3R EC3V EC4A EC4M EC4N EC4P EC4R EC4V EC4Y N1 N10 N13 N15 N16 N17 N18 N19 N2 N22 N4 N5 N6 N7 N8 N9 NW1 NW11 NW2 NW3 NW5 NW6 NW8 SE9 SW1 SW10 SW11 SW12 SW15 SW16 SW17 SW18 SW19 SW2 SW20 SW3 SW4 SW5 SW6 SW7 SW8 W1 W10 W11 W12 W14 W2 W6 W8 W9 WC1A WC1B WC1E WC1H WC1N WC1R WC1V WC1X WC2A WC2B WC2E WC2H WC2N WC2R

Postcodes that are NOT charged the additional £3.00 shipping:

BR1 BR3 BR4 SE1 SE10 SE11 SE12 SE13 SE14 SE15 SE16 SE17 SE19 SE20 SE21 SE22 SE23 SE24 SE25 SE26 SE27 SE3 SE4 SE5 SE6 SE7 SE8 SW9

Any other postcode other than those listed above is charged £100.00 shipping, this should put the buyer off from placing an order.

Viewing the inbuilt script for each form, you can see where the calculation is done. For example, the first calculation is:
if ((document.form1.ship.value>=14) && (document.form1.totalunit.value<=45)) {
document.form1.shipping.value=7.99;
}
The external script passes the ship value based on the postcode entered, if the value is more than 14, and the total unit or total price is less than £45.00 from the cart, then shipping is calculated at £7.99 for the 'standard' delivery.


Postcode that matches the additional £3.00 shipping
Customer spend less than £45.00
Standard delivery £7.99
Express delivery £12.99

Postcode that matches the additional £3.00 shipping
Customer spend over £45.00 but less than £75.00
Standard delivery £3.00
Express delivery £3.00

Postcode that matches the additional £3.00 shipping
Customer spend over £75.00
Standard delivery £0.00
Express delivery £0.00

Postcode that DOES NOT match the additional £3.00 shipping
Customer spend less than £45.00
Standard delivery £4.99
Express delivery £9.99

Postcode that DOES NOT match the additional £3.00 shipping
Customer spend over £45.00
Standard delivery £0.00
Express delivery £0.00


To keep the page content area small for you, I've hidden each selection below so they are only shown on your page as needed. There is a small script in the head area of this page that controls the hidden divs. If you want to remove the checkbox options permanently on your page, simply remove the two checkboxes below and remove the two divs: <div class="row" id="div1" style="display:none"> and the line holding id="div2" plus each close of the div1 or div2 and of course, remove the script from the head area.

There are two external scripts that read the entered postcode, standard.js and express.js, each script is called by either the 'standard' form or the 'express' form. Postcodes can easily be added or removed or moved from a no extra charge zone into the extra charge zone in both scripts. You need to download and save to your PC these two shipping scripts: standard.js and express.js you will then link to these external scripts as I have done below each form, in each hidden div.