Created
November 12, 2012 23:49
-
-
Save Denham/4062864 to your computer and use it in GitHub Desktop.
Base template for Auspost shipping costs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Custom Store Shipping plugin | |
* | |
* Built based on AusPost costs for shipping wines. | |
* The actual rates change based on where the wines are being sent from, but you can use the zone stuff. | |
* The costs in this example are for shipping from Adelaide. | |
*/ | |
class Store_shipping_aus_post_wines extends Store_shipping_driver | |
{ | |
public function calculate_shipping($order) | |
{ | |
$weight = $order['order_shipping_weight_kg']; | |
$pcode = $order['shipping_postcode']; | |
if ( | |
// ! Zone = N1 | |
$pcode>=1000 && $pcode<=2249 || | |
$pcode>=2555 && $pcode<=2574 || | |
$pcode>=2740 && $pcode<=2786 || | |
$pcode==2890 | |
){ | |
$total = 9.40+($weight*0.52); | |
return $total; | |
} elseif ( | |
// ! Zone = GF | |
$pcode>=2250 && $pcode<=2263 | |
){ | |
$total = 9.68+($weight*0.65); | |
return $total; | |
} elseif ( | |
// ! Zone = WG | |
$pcode>=2500 && $pcode<=2506 || | |
$pcode>=2515 && $pcode<=2530 | |
){ | |
$total = 9.68+($weight*0.65); | |
return $total; | |
} elseif ( | |
// ! Zone = NC | |
$pcode>=2282 && $pcode<=2310 | |
){ | |
$total = 9.68+($weight*0.67); | |
return $total; | |
} elseif ( | |
// ! Zone = CB | |
$pcode>=0200 && $pcode<=0299 || | |
$pcode>=2600 && $pcode<=2620 || | |
$pcode>=2900 && $pcode<=2920 | |
){ | |
$total = 9.40+($weight*0.65); | |
return $total; | |
} elseif ( | |
// ! Zone = N2 | |
$pcode>=2264 && $pcode<=2281 || | |
$pcode>=2311 && $pcode<=2499 || | |
$pcode>=2507 && $pcode<=2514 || | |
$pcode>=2531 && $pcode<=2554 || | |
$pcode>=2575 && $pcode<=2599 || | |
$pcode>=2621 && $pcode<=2647 || | |
$pcode>=2649 && $pcode<=2714 || | |
$pcode==2716 || | |
$pcode>=2720 && $pcode<=2730 || | |
$pcode>=2787 && $pcode<=2789 || | |
$pcode>=2881 && $pcode<=2889 || | |
$pcode>=2891 && $pcode<=2898 | |
){ | |
$total = 10.24+($weight*1.01); | |
return $total; | |
} elseif ( | |
// ! Zone = V1 | |
$pcode>=3000 && $pcode<=3210 || | |
$pcode>=3335 && $pcode<=3341 || | |
$pcode>=3425 && $pcode<=3443 || | |
$pcode>=3750 && $pcode<=3811 || | |
$pcode>=3910 && $pcode<=3920 || | |
$pcode>=3926 && $pcode<=3944 || | |
$pcode>=3972 && $pcode<=3978 || | |
$pcode>=3980 && $pcode<=3983 || | |
$pcode>=8000 && $pcode<=8999 | |
){ | |
$total = 9.40+($weight*0.43); | |
return $total; | |
} elseif ( | |
// ! Zone = GL | |
$pcode>=3211 && $pcode<=3220 | |
){ | |
$total = 9.40+($weight*0.47); | |
return $total; | |
} elseif ( | |
// ! Zone = BR | |
$pcode==3350 || | |
$pcode>=3353 && $pcode<=3356 | |
){ | |
$total = 10.24+($weight*0.67); | |
return $total; | |
} elseif ( | |
// ! Zone = V2 | |
$pcode==2648 || | |
$pcode==2715 || | |
$pcode>=2717 && $pcode<=2719 || | |
$pcode>=2731 && $pcode<=2739 || | |
$pcode>=3221 && $pcode<=3334 || | |
$pcode>=3342 && $pcode<=3349 || | |
$pcode>=3351 && $pcode<=3352 || | |
$pcode>=3357 && $pcode<=3424 || | |
$pcode>=3444 && $pcode<=3749 || | |
$pcode>=3812 && $pcode<=3909 || | |
$pcode>=3921 && $pcode<=3925 || | |
$pcode>=3945 && $pcode<=3971 || | |
$pcode==3979 || | |
$pcode>=3984 && $pcode<=3999 | |
){ | |
$total = 10.24+($weight*0.69); | |
return $total; | |
} elseif ( | |
// ! Zone = Q1 | |
$pcode>=4000 && $pcode<=4209 || | |
$pcode>=4230 && $pcode<=4299 || | |
$pcode>=4500 && $pcode<=4549 || | |
$pcode>=4900 && $pcode<=4999 || | |
$pcode>=9000 && $pcode<=9799 | |
){ | |
$total = 9.40+($weight*0.75); | |
return $total; | |
} elseif ( | |
// ! Zone = GC | |
$pcode>=4210 && $pcode<=4229 | |
){ | |
$total = 9.68+($weight*0.78); | |
return $total; | |
} elseif ( | |
// ! Zone = SC | |
$pcode>=4550 && $pcode<=4575 | |
){ | |
$total = 10.24+($weight*0.86); | |
return $total; | |
} elseif ( | |
// ! Zone = IP | |
$pcode>=4300 && $pcode<=4307 | |
){ | |
$total = 10.24+($weight*0.87); | |
return $total; | |
} elseif ( | |
// ! Zone = Q2 | |
$pcode>=4308 && $pcode<=4499 || | |
$pcode>=4576 && $pcode<=4689 || | |
$pcode>=9597 && $pcode<=9699 || | |
$pcode>=9880 && $pcode<=9919 | |
){ | |
$total = 10.24+($weight*1.57); | |
return $total; | |
} elseif ( | |
// ! Zone = Q3 | |
$pcode>=4690 && $pcode<=4805 || | |
$pcode>=9920 && $pcode<=9959 | |
){ | |
$total = 10.24+($weight*1.74); | |
return $total; | |
} elseif ( | |
// ! Zone = Q4 | |
$pcode>=4806 && $pcode<=4899 || | |
$pcode>=9960 && $pcode<=9999 | |
){ | |
$total = 10.24+($weight*1.90); | |
return $total; | |
} elseif ( | |
// ! Zone = S1 | |
$pcode>=5000 && $pcode<=5199 || | |
$pcode>=5800 && $pcode<=5999 | |
){ | |
$total = 8.56+($weight*0.19); | |
return $total; | |
} elseif ( | |
// ! Zone = S2 | |
$pcode==2880 || | |
$pcode>=5200 && $pcode<=5749 | |
){ | |
$total = 9.62+($weight*0.50); | |
return $total; | |
} elseif ( | |
// ! Zone = W1 | |
$pcode>=6000 && $pcode<=6214 || | |
$pcode>=6800 && $pcode<=6999 | |
){ | |
$total = 9.40+($weight*1.09); | |
return $total; | |
} elseif ( | |
// ! Zone = W2 | |
$pcode>=6215 && $pcode<=6699 | |
){ | |
$total = 10.24+($weight*1.79); | |
return $total; | |
} elseif ( | |
// ! Zone = W3 | |
$pcode>=6700 && $pcode<=6796 | |
){ | |
$total = 10.24+($weight*2.18); | |
return $total; | |
} elseif ( | |
// ! Zone = CC1 | |
$pcode>=6798 && $pcode<=6799 | |
){ | |
$total = 10.69+($weight*2.18); | |
return $total; | |
} elseif ( | |
// ! Zone = T1 | |
$pcode>=7000 && $pcode<=7150 || | |
$pcode>=7152 && $pcode<=7999 | |
){ | |
$total = 10.24+($weight*1.66); | |
return $total; | |
} elseif ( | |
// ! Zone = NT1 | |
$pcode>=0800 && $pcode<=0821 || | |
$pcode>=0828 && $pcode<=0851 || | |
$pcode==0853 || | |
$pcode>=0860 && $pcode<=0861 || | |
$pcode>=0870 && $pcode<=0871 || | |
$pcode>=0887 && $pcode<=0999 | |
){ | |
$total =10.24+($weight*1.34); | |
return $total; | |
} elseif ( | |
// ! Zone = NT2 | |
$pcode>=0822 && $pcode<=0827 || | |
$pcode==0852 || | |
$pcode>=0854 && $pcode<=0859 || | |
$pcode>=0862 && $pcode<=0869 || | |
$pcode>=0872 && $pcode<=0886 | |
){ | |
$total = 10.24+($weight*2.46); | |
return $total; | |
} elseif ( | |
// ! Zone = NF | |
$pcode==2899 | |
){ | |
$total = 10.69+($weight*2.18); | |
return $total; | |
} elseif ( | |
// ! Zone = AAT | |
$pcode==7151 | |
){ | |
$total = 10.69+($weight*2.35); | |
return $total; | |
}else{ | |
// ! fallback | |
$total = 10.50+($weight*2.35); | |
return $total; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment