Fontis_Australia - Version 1.1

Version Notes

Currently active are modules for BPAY, direct deposit, Australia Post, the addition of regions and postcodes, and the addition of ABN and phone number to the general configuration values (although currently not in use).

Download this release

Release Info

Developer Magento Core Team
Extension Fontis_Australia
Version 1.1
Comparing to
See all releases


Code changes from version 1.0 to 1.1

app/code/community/Fontis/Australia/Model/Mysql4/Shipping/Carrier/Eparcel.php ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Originally based on Magento Tablerate Shipping code.
16
+ *
17
+ * @category Fontis
18
+ * @package Fontis_Australia
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+
24
+ /**
25
+ * Shipping table rates
26
+ *
27
+ * @category Mage
28
+ * @package Mage_Shipping
29
+ * @author Magento Core Team <core@magentocommerce.com>
30
+ */
31
+ class Fontis_Australia_Model_Mysql4_Shipping_Carrier_Eparcel extends Mage_Core_Model_Mysql4_Abstract
32
+ {
33
+ protected function _construct()
34
+ {
35
+ $this->_init('australia/eparcel', 'pk');
36
+ }
37
+
38
+ /*public function getRate(Mage_Shipping_Model_Rate_Request $request)
39
+ {
40
+ Mage::log(var_export($request->getConditionName(), true));
41
+
42
+ try
43
+ {
44
+
45
+ $read = $this->_getReadAdapter();
46
+ $write = $this->_getWriteAdapter();
47
+
48
+ $select = $read->select()->from($this->getMainTable());
49
+
50
+ $select->where(
51
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
52
+ $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()).
53
+ $read->quoteInto(" AND dest_zip=?) ", $request->getDestPostcode()).
54
+
55
+ $read->quoteInto(" OR (dest_country_id=? ", $request->getDestCountryId()).
56
+ $read->quoteInto(" AND dest_region_id=? AND dest_zip='') ", $request->getDestRegionId()).
57
+
58
+ $read->quoteInto(" OR (dest_country_id=? AND dest_region_id='0' AND dest_zip='') ", $request->getDestCountryId()).
59
+
60
+ $read->quoteInto(" OR (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()).
61
+ $read->quoteInto(" AND dest_zip=?) ", $request->getDestPostcode()).
62
+
63
+ " OR (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')"
64
+ );
65
+
66
+ if (is_array($request->getConditionName())) {
67
+ $i = 0;
68
+ foreach ($request->getConditionName() as $conditionName) {
69
+ if ($i == 0) {
70
+ $select->where('condition_name=?', $conditionName);
71
+ } else {
72
+ $select->orWhere('condition_name=?', $conditionName);
73
+ }
74
+ $select->where('condition_from_value<=?', $request->getData($conditionName));
75
+ $i++;
76
+ }
77
+ } else {
78
+ $select->where('condition_name=?', $request->getConditionName());
79
+ $select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
80
+ }
81
+ $select->where('website_id=?', $request->getWebsiteId());
82
+
83
+ $select->order('dest_country_id DESC');
84
+ $select->order('dest_region_id DESC');
85
+ $select->order('dest_zip DESC');
86
+ $select->order('condition_from_value DESC');
87
+ $select->limit(1);
88
+
89
+ // pdo has an issue. we cannot use bind
90
+ $row = $read->fetchRow($select);
91
+ Mage::log($row);
92
+
93
+ return $row;
94
+
95
+ }
96
+ catch(Exception $e)
97
+ {
98
+ Mage::log($e->getMessage());
99
+ }
100
+ }*/
101
+
102
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
103
+ {
104
+ $read = $this->_getReadAdapter();
105
+ $write = $this->_getWriteAdapter();
106
+
107
+ $postcode = $request->getDestPostcode();
108
+ //$table = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
109
+ $table = $this->getMainTable();
110
+
111
+ $insuranceStep = (float)Mage::getConfig()->getNode('default/carriers/eparcel/insurance_step');
112
+ $insuranceCostPerStep = (float)Mage::getConfig()->getNode('default/carriers/eparcel/insurance_cost_per_step');
113
+ $signatureRequired = Mage::getConfig()->getNode('default/carriers/eparcel/signature_required');
114
+ if($signatureRequired) {
115
+ $signatureCost = (float)Mage::getConfig()->getNode('default/carriers/eparcel/signature_cost');
116
+ } else {
117
+ $signatureCost = 0;
118
+ }
119
+
120
+ Mage::log($request->getDestCountryId());
121
+ Mage::log($request->getDestRegionId());
122
+ Mage::log($postcode);
123
+ Mage::log(var_export($request->getConditionName(), true));
124
+ //Mage::log();
125
+
126
+ for ($j=0;$j<5;$j++)
127
+ {
128
+
129
+ $select = $read->select()->from($table);
130
+
131
+
132
+ switch($j) {
133
+ case 0:
134
+ $select->where(
135
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
136
+ $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()).
137
+ $read->quoteInto(" AND dest_zip=?) ", $postcode)
138
+ );
139
+ break;
140
+ case 1:
141
+ $select->where(
142
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
143
+ $read->quoteInto(" AND dest_region_id=? AND dest_zip='') ", $request->getDestRegionId())
144
+ );
145
+ break;
146
+
147
+ case 2:
148
+ $select->where(
149
+ $read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_zip='') ", $request->getDestCountryId())
150
+ );
151
+ break;
152
+ case 3:
153
+ $select->where(
154
+ $read->quoteInto(" (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()).
155
+ $read->quoteInto(" AND dest_zip=?) ", $postcode)
156
+ );
157
+ break;
158
+ case 4:
159
+ $select->where(
160
+ " (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')"
161
+ );
162
+ break;
163
+ }
164
+
165
+
166
+ if (is_array($request->getConditionName())) {
167
+ $i = 0;
168
+ foreach ($request->getConditionName() as $conditionName) {
169
+ if ($i == 0) {
170
+ $select->where('condition_name=?', $conditionName);
171
+ } else {
172
+ $select->orWhere('condition_name=?', $conditionName);
173
+ }
174
+ $select->where('condition_from_value<=?', $request->getData($conditionName));
175
+ $select->where('condition_to_value>=?', $request->getData($conditionName));
176
+
177
+ $i++;
178
+ }
179
+ } else {
180
+ $select->where('condition_name=?', $request->getConditionName());
181
+ $select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
182
+ $select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
183
+ }
184
+ $select->where('website_id=?', $request->getWebsiteId());
185
+
186
+ $select->order('dest_country_id DESC');
187
+ $select->order('dest_region_id DESC');
188
+ $select->order('dest_zip DESC');
189
+ $select->order('condition_from_value DESC');
190
+
191
+ // pdo has an issue. we cannot use bind
192
+
193
+ //Mage::log(var_export($select, true));
194
+
195
+ $newdata=array();
196
+ Mage::log($select->__toString());
197
+ $row = $read->fetchAll($select);
198
+ if (!empty($row) && ($j<5))
199
+ {
200
+ // have found a result or found nothing and at end of list!
201
+ foreach ($row as $data) {
202
+ try {
203
+ $price = (float)($data['price']);
204
+
205
+ // add per-Kg cost
206
+ $conditionValue = (float)($request->getData($request->getConditionName()));
207
+ $price += (float)($data['price_per_kg']) * $conditionValue;
208
+
209
+ // add signature cost
210
+ $price += $signatureCost;
211
+
212
+ // add version without insurance
213
+ $data['price'] = (string)$price;
214
+ $newdata[]=$data;
215
+
216
+ // add version with insurance
217
+ // work out how many insurance 'steps' we have
218
+ $steps = ceil($request->getPackageValue() / $insuranceStep);
219
+ Mage::log("Insurance steps: $steps");
220
+ // add on number of 'steps' multiplied by the
221
+ // insurance cost per step
222
+ $insuranceCost = $insuranceCostPerStep * $steps;
223
+ Mage::log("Insurance cost: $insuranceCost");
224
+ $price += $insuranceCost;
225
+
226
+ $data['price'] = (string)$price;
227
+ $data['delivery_type'] .= " with TransitCover";
228
+ $newdata[]=$data;
229
+
230
+ } catch(Exception $e) {
231
+ Mage::log($e->getMessage());
232
+ }
233
+ }
234
+ break;
235
+ }
236
+ }
237
+ Mage::log(var_export($newdata, true));
238
+ return $newdata;
239
+ }
240
+
241
+ public function uploadAndImport(Varien_Object $object)
242
+ {
243
+ Mage::log('Eparcel uploadAndImport');
244
+ $csvFile = $_FILES["groups"]["tmp_name"]["eparcel"]["fields"]["import"]["value"];
245
+
246
+ if (!empty($csvFile)) {
247
+
248
+ $csv = trim(file_get_contents($csvFile));
249
+
250
+ $table = Mage::getSingleton('core/resource')->getTableName('australia/eparcel');
251
+
252
+ $websiteId = $object->getScopeId();
253
+ $websiteModel = Mage::app()->getWebsite($websiteId);
254
+ /*
255
+ getting condition name from post instead of the following commented logic
256
+ */
257
+
258
+ if (isset($_POST['groups']['eparcel']['fields']['condition_name']['inherit'])) {
259
+ $conditionName = (string)Mage::getConfig()->getNode('default/carriers/eparcel/condition_name');
260
+ } else {
261
+ $conditionName = $_POST['groups']['eparcel']['fields']['condition_name']['value'];
262
+ }
263
+
264
+ $conditionFullName = Mage::getModel('australia/shipping_carrier_eparcel')->getCode('condition_name_short', $conditionName);
265
+ if (!empty($csv)) {
266
+ $exceptions = array();
267
+ $csvLines = explode("\n", $csv);
268
+ $csvLine = array_shift($csvLines);
269
+ $csvLine = $this->_getCsvValues($csvLine);
270
+ if (count($csvLine) < 8) {
271
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Table Rates File Format');
272
+ }
273
+
274
+ $countryCodes = array();
275
+ $regionCodes = array();
276
+ foreach ($csvLines as $k=>$csvLine) {
277
+ $csvLine = $this->_getCsvValues($csvLine);
278
+ if (count($csvLine) > 0 && count($csvLine) < 8) {
279
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Table Rates File Format');
280
+ } else {
281
+ $countryCodes[] = $csvLine[0];
282
+ $regionCodes[] = $csvLine[1];
283
+ }
284
+ }
285
+
286
+ if (empty($exceptions)) {
287
+ $data = array();
288
+ $countryCodesToIds = array();
289
+ $regionCodesToIds = array();
290
+ $countryCodesIso2 = array();
291
+
292
+ $countryCollection = Mage::getResourceModel('directory/country_collection')->addCountryCodeFilter($countryCodes)->load();
293
+ foreach ($countryCollection->getItems() as $country) {
294
+ $countryCodesToIds[$country->getData('iso3_code')] = $country->getData('country_id');
295
+ $countryCodesToIds[$country->getData('iso2_code')] = $country->getData('country_id');
296
+ $countryCodesIso2[] = $country->getData('iso2_code');
297
+ }
298
+
299
+ $regionCollection = Mage::getResourceModel('directory/region_collection')
300
+ ->addRegionCodeFilter($regionCodes)
301
+ ->addCountryFilter($countryCodesIso2)
302
+ ->load();
303
+
304
+ //print("<pre>");
305
+ //print_r($regionCollection->getItems());
306
+ //print("</pre>");
307
+ //die;
308
+
309
+ /*foreach ($regionCollection->getItems() as $region) {
310
+ $regionCodesToIds[$countryCodesToIds[$region->getData('country_id')]][$region->getData('code')] = $region->getData('region_id');
311
+ }*/
312
+ foreach ($regionCollection->getItems() as $region) {
313
+ $regionCodesToIds[$region->getData('code')] = $region->getData('region_id');
314
+ }
315
+
316
+ //print("<pre>");
317
+ //print_r($regionCodesToIds);
318
+ //print("</pre>");
319
+ //die;
320
+
321
+ foreach ($csvLines as $k=>$csvLine) {
322
+ $csvLine = $this->_getCsvValues($csvLine);
323
+
324
+ if (empty($countryCodesToIds) || !array_key_exists($csvLine[0], $countryCodesToIds)) {
325
+ $countryId = '0';
326
+ if ($csvLine[0] != '*' && $csvLine[0] != '') {
327
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Country "%s" in the Row #%s', $csvLine[0], ($k+1));
328
+ }
329
+ } else {
330
+ $countryId = $countryCodesToIds[$csvLine[0]];
331
+ }
332
+
333
+ /*if (empty($regionCodesToIds[$countryCodesToIds[$csvLine[0]]])
334
+ || !array_key_exists($csvLine[1], $regionCodesToIds[$countryCodesToIds[$csvLine[0]]])) {
335
+ $regionId = '0';
336
+ if ($csvLine[1] != '*' && $csvLine[1] != '') {
337
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Region/State "%s" in the Row #%s', $csvLine[1], ($k+1));
338
+ }
339
+ } else {
340
+ $regionId = $regionCodesToIds[$countryCodesToIds[$csvLine[0]]][$csvLine[1]];
341
+ }*/
342
+
343
+ if (empty($regionCodesToIds) || !array_key_exists($csvLine[1], $regionCodesToIds)) {
344
+ $regionId = '0';
345
+ if ($csvLine[1] != '*' && $csvLine[1] != '') {
346
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Region/State "%s" in the Row #%s', $csvLine[1], ($k+1));
347
+ }
348
+ } else {
349
+ $regionId = $regionCodesToIds[$csvLine[1]];
350
+ }
351
+
352
+ if ($csvLine[2] == '*' || $csvLine[2] == '') {
353
+ $zip = '';
354
+ } else {
355
+ $zip = $csvLine[2];
356
+ }
357
+
358
+ if (!$this->_isPositiveDecimalNumber($csvLine[3]) || $csvLine[3] == '*' || $csvLine[3] == '') {
359
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s "%s" in the Row #%s', $conditionFullName, $csvLine[3], ($k+1));
360
+ } else {
361
+ $csvLine[3] = (float)$csvLine[3];
362
+ }
363
+
364
+ if (!$this->_isPositiveDecimalNumber($csvLine[4]) || $csvLine[4] == '*' || $csvLine[4] == '') {
365
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s "%s" in the Row #%s', $conditionFullName, $csvLine[4], ($k+1));
366
+ } else {
367
+ $csvLine[4] = (float)$csvLine[4];
368
+ }
369
+
370
+ if (!$this->_isPositiveDecimalNumber($csvLine[5])) {
371
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Shipping Price "%s" in the Row #%s', $csvLine[5], ($k+1));
372
+ } else {
373
+ $csvLine[5] = (float)$csvLine[5];
374
+ }
375
+
376
+ if (!$this->_isPositiveDecimalNumber($csvLine[6])) {
377
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Shipping Price per Kg "%s" in the Row #%s', $csvLine[6], ($k+1));
378
+ } else {
379
+ $csvLine[6] = (float)$csvLine[6];
380
+ }
381
+
382
+ $data[] = array('website_id'=>$websiteId, 'dest_country_id'=>$countryId, 'dest_region_id'=>$regionId, 'dest_zip'=>$zip, 'condition_name'=>$conditionName, 'condition_from_value'=>$csvLine[3],'condition_to_value'=>$csvLine[4], 'price'=>$csvLine[5], 'price_per_kg'=>$csvLine[6], 'delivery_type'=>$csvLine[7]);
383
+ $dataDetails[] = array('country'=>$csvLine[0], 'region'=>$csvLine[1]);
384
+ }
385
+ }
386
+
387
+ if (empty($exceptions)) {
388
+ $connection = $this->_getWriteAdapter();
389
+
390
+ $condition = array(
391
+ $connection->quoteInto('website_id = ?', $websiteId),
392
+ $connection->quoteInto('condition_name = ?', $conditionName),
393
+ );
394
+ $connection->delete($table, $condition);
395
+
396
+ Mage::log(count($data)." lines read from CSV");
397
+ foreach($data as $k=>$dataLine) {
398
+ try {
399
+ // convert comma-seperated postcode/postcode range
400
+ // string into an array
401
+ $postcodes = array();
402
+ foreach(explode(',', $dataLine['dest_zip']) as $postcodeEntry) {
403
+ $postcodeEntry = explode("-", trim($postcodeEntry));
404
+ if(count($postcodeEntry) == 1) {
405
+ Mage::log("Line $k, single postcode: ".$postcodeEntry[0]);
406
+ // if the postcode entry is length 1, it's
407
+ // just a single postcode
408
+ $postcodes[] = $postcodeEntry[0];
409
+ } else {
410
+ // otherwise it's a range, so convert that
411
+ // to a sequence of numbers
412
+ $pcode1 = (int)$postcodeEntry[0];
413
+ $pcode2 = (int)$postcodeEntry[1];
414
+ Mage::log("Line $k, postcode range: $pcode1-$pcode2");
415
+
416
+ $postcodes = array_merge($postcodes, range(min($pcode1, $pcode2), max($pcode1, $pcode2)));
417
+ }
418
+ }
419
+
420
+ Mage::log(var_export($postcodes, true));
421
+ foreach($postcodes as $postcode) {
422
+ $dataLine['dest_zip'] = str_pad($postcode, 4, "0", STR_PAD_LEFT);
423
+ $connection->insert($table, $dataLine);
424
+ }
425
+ } catch (Exception $e) {
426
+ //$exceptions[] = Mage::helper('shipping')->__('ERROR Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s")', ($k+1), $dataDetails[$k]['country'], $dataDetails[$k]['region'], $dataLine['dest_zip'], $dataLine['condition_value']);
427
+ Mage::log($e->getMessage());
428
+ $exceptionas[] = $e->getMessage();
429
+ }
430
+ }
431
+ }
432
+
433
+ if (!empty($exceptions)) {
434
+ throw new Exception( "\n" . implode("\n", $exceptions) );
435
+ }
436
+ }
437
+ }
438
+ }
439
+
440
+ protected function _getCsvValues($string, $separator=",")
441
+ {
442
+ $elements = explode($separator, trim($string));
443
+ for ($i = 0; $i < count($elements); $i++) {
444
+ $nquotes = substr_count($elements[$i], '"');
445
+ if ($nquotes %2 == 1) {
446
+ for ($j = $i+1; $j < count($elements); $j++) {
447
+ if (substr_count($elements[$j], '"') > 0) {
448
+ // Put the quoted string's pieces back together again
449
+ array_splice($elements, $i, $j-$i+1, implode($separator, array_slice($elements, $i, $j-$i+1)));
450
+ break;
451
+ }
452
+ }
453
+ }
454
+ if ($nquotes > 0) {
455
+ // Remove first and last quotes, then merge pairs of quotes
456
+ $qstr =& $elements[$i];
457
+ $qstr = substr_replace($qstr, '', strpos($qstr, '"'), 1);
458
+ $qstr = substr_replace($qstr, '', strrpos($qstr, '"'), 1);
459
+ $qstr = str_replace('""', '"', $qstr);
460
+ }
461
+ $elements[$i] = trim($elements[$i]);
462
+ }
463
+ return $elements;
464
+ }
465
+
466
+ protected function _isPositiveDecimalNumber($n)
467
+ {
468
+ return preg_match ("/^[0-9]+(\.[0-9]*)?$/", $n);
469
+ }
470
+
471
+ }
app/code/community/Fontis/Australia/Model/Mysql4/Shipping/Carrier/Eparcel/Collection.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Originally based on Magento Tablerate Shipping code.
16
+ *
17
+ * @category Fontis
18
+ * @package Fontis_Australia
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+
24
+ /**
25
+ * Australia Post eParcel shipping table rates collection
26
+ *
27
+ * @category Fontis
28
+ * @package Fontis_Australia
29
+ */
30
+ class Fontis_Australia_Model_Mysql4_Shipping_Carrier_Eparcel_Collection extends Varien_Data_Collection_Db
31
+ {
32
+ protected $_shipTable;
33
+ protected $_countryTable;
34
+ protected $_regionTable;
35
+
36
+ public function __construct()
37
+ {
38
+ parent::__construct(Mage::getSingleton('core/resource')->getConnection('australia_read'));
39
+ $this->_shipTable = Mage::getSingleton('core/resource')->getTableName('australia/eparcel');
40
+ $this->_countryTable = Mage::getSingleton('core/resource')->getTableName('directory/country');
41
+ $this->_regionTable = Mage::getSingleton('core/resource')->getTableName('directory/country_region');
42
+ $this->_select->from(array("s" => $this->_shipTable))
43
+ ->joinLeft(array("c" => $this->_countryTable), 'c.country_id = s.dest_country_id', 'iso3_code AS dest_country')
44
+ ->joinLeft(array("r" => $this->_regionTable), 'r.region_id = s.dest_region_id', 'code AS dest_region')
45
+ ->order(array("dest_country", "dest_region", "dest_zip"));
46
+ $this->_setIdFieldName('pk');
47
+ return $this;
48
+ }
49
+
50
+ public function setWebsiteFilter($websiteId)
51
+ {
52
+ $this->_select->where("website_id = ?", $websiteId);
53
+
54
+ return $this;
55
+ }
56
+
57
+ public function setConditionFilter($conditionName)
58
+ {
59
+ $this->_select->where("condition_name = ?", $conditionName);
60
+
61
+ return $this;
62
+ }
63
+
64
+ public function setCountryFilter($countryId)
65
+ {
66
+ $this->_select->where("dest_country_id = ?", $countryId);
67
+
68
+ return $this;
69
+ }
70
+ }
app/code/community/Fontis/Australia/Model/Shipping/Carrier/Australiapost.php CHANGED
@@ -78,63 +78,228 @@ class Fontis_Australia_Model_Shipping_Carrier_Australiapost
78
  // on destination country.
79
  if($destCountry == "AU")
80
  {
81
- $shipping_methods = array("STANDARD", "EXPRESS");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
  else
84
  {
85
- $shipping_methods = array("SEA", "AIR");
86
- }
87
-
88
- foreach($shipping_methods as $shipping_method)
89
- {
90
- // Construct the appropriate URL and send all the information
91
- // to the Australia Post DRC.
92
- $url = "http://drc.edeliver.com.au/ratecalc.asp?" .
93
- "Pickup_Postcode=" . $frompcode .
94
- "&Destination_Postcode=" . $topcode .
95
- "&Country=" . $destCountry .
96
- "&Weight=" . $sweight .
97
- "&Service_Type=" . $shipping_method .
98
- "&Height=" . $sheight .
99
- "&Width=" . $swidth .
100
- "&Length=" . $slength .
101
- "&Quantity=" . $shipping_num_boxes;
102
-
103
- $drc_result = file($url);
104
- foreach($drc_result as $vals)
105
- {
106
- $tokens = split("=", $vals);
107
- $$tokens[0] = $tokens[1];
108
- }
 
 
 
109
 
110
- // Check that the DRC returned without error.
111
- if(trim($err_msg) == "OK")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  {
113
- $shippingPrice = $request->getBaseCurrency()->convert($charge, $request->getPackageCurrency());
114
-
115
- $shippingPrice += $this->getConfigData('handling_fee');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- $method = Mage::getModel('shipping/rate_result_method');
 
 
 
 
 
 
 
 
118
 
119
- $method->setCarrier('australiapost');
120
- $method->setCarrierTitle($this->getConfigData('title'));
121
 
122
- $method->setMethod($shipping_method);
123
- $title_days = ($days == 1) ? " (1 day)" : " ($days days)";
124
- $title = $this->getConfigData('name') . " " .
125
- ucfirst(strtolower($shipping_method)) .
126
- $title_days;
127
- $method->setMethodTitle($title);
128
 
129
- $method->setPrice($shippingPrice);
130
- $method->setCost($shippingPrice);
131
 
132
- $result->append($method);
133
- }
134
- }
135
 
136
- return $result;
137
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  /**
140
  * Get allowed shipping methods
78
  // on destination country.
79
  if($destCountry == "AU")
80
  {
81
+ //============= Domestic Shipping ==================
82
+ $shipping_methods = array('STANDARD', 'EXPRESS');
83
+
84
+ foreach($shipping_methods as $shipping_method)
85
+ {
86
+ $drc = $this->_drcRequest($shipping_method, $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
87
+
88
+ if($drc['err_msg'] == 'OK')
89
+ {
90
+ // Check for registered post activation. If so, add extra options
91
+ if($this->getConfigData('registered_post'))
92
+ {
93
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
94
+ $title = $this->getConfigData('name') . " " .
95
+ ucfirst(strtolower($shipping_method)) .
96
+ $title_days;
97
+
98
+ $charge = $drc['charge'];
99
+ $charge += $this->getConfigData('registered_post_charge');
100
+
101
+ if($this->getConfigData('person_to_person'))
102
+ {
103
+ $charge += 5.50;
104
+ }
105
+ elseif($this->getConfigData('delivery_confirmation'))
106
+ {
107
+ $charge += 1.85;
108
+ }
109
+
110
+ $method = $this->_createMethod($request, $shipping_method, $title, $charge, $charge);
111
+ $result->append($method);
112
+
113
+ // Insurance only covers up to $5000 worth of goods.
114
+ $packageValue = ($request->getPackageValue() > 5000) ? 5000 : $request->getPackageValue();
115
+
116
+ // Insurance cost is $1.25 per $100 or part thereof. First $100 is
117
+ // included in normal registered post costs.
118
+ $insurance = (ceil($packageValue / 100) - 1) * 1.25;
119
+ $charge += $insurance;
120
+
121
+ $title = $this->getConfigData('name') . " " . ucfirst(strtolower($shipping_method)) . ' with Extra Cover';
122
+ $method = $this->_createMethod($request, $shipping_method, $title, $charge, $charge);
123
+ $result->append($method);
124
+ }
125
+ else
126
+ {
127
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
128
+ $title = $this->getConfigData('name') . " " .
129
+ ucfirst(strtolower($shipping_method)) .
130
+ $title_days;
131
+
132
+ $method = $this->_createMethod($request, $shipping_method, $title, $drc['charge'], $drc['charge']);
133
+ $result->append($method);
134
+ }
135
+ }
136
+ }
137
  }
138
  else
139
  {
140
+ //============= International Shipping ==================
141
+ // International shipping options are highly dependent upon whether
142
+ // or not you are using registered post.
143
+ if($this->getConfigData('registered_post'))
144
+ {
145
+ //============= Registered Post ================
146
+ // Registered Post International
147
+ // Same price as Air Mail, plus $5. Extra cover is not available.
148
+ // A weight limit of 2kg applies.
149
+ if($sweight <= 2000)
150
+ {
151
+ $drc = $this->_drcRequest('AIR', $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
152
+
153
+ if($drc['err_msg'] == 'OK')
154
+ {
155
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
156
+ $title = $this->getConfigData('name') . ' Registered Post International' . $title_days;
157
+
158
+ // RPI is another 5 dollars.
159
+ $charge = $drc['charge'] + 5;
160
+
161
+ if($this->getConfigData('delivery_confirmation'))
162
+ {
163
+ $charge += 3.30;
164
+ }
165
+
166
+ $charge += $this->getConfigData('registered_post_charge');
167
 
168
+ $method = $this->_createMethod($request, 'AIR', $title, $charge, $charge);
169
+ $result->append($method);
170
+ }
171
+ }
172
+
173
+ // Express Post International
174
+ $drc = $this->_drcRequest('EPI', $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
175
+
176
+ if($drc['err_msg'] == 'OK')
177
+ {
178
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
179
+ $title = $this->getConfigData('name') . ' Express Post International' . $title_days;
180
+
181
+ $charge = $drc['charge'];
182
+
183
+ if($this->getConfigData('delivery_confirmation'))
184
+ {
185
+ $charge += 3.30;
186
+ }
187
+
188
+ $charge += $this->getConfigData('registered_post_charge');
189
+
190
+ $method = $this->_createMethod($request, 'EPI', $title, $charge, $charge);
191
+ $result->append($method);
192
+
193
+ // Insurance only covers up to $5000 worth of goods.
194
+ $packageValue = ($request->getPackageValue() > 5000) ? 5000 : $request->getPackageValue();
195
+
196
+ // Insurance cost is $2.25 per $100 or part thereof. First $100 is $8.45.
197
+ $insurance = 8.45 + (ceil($packageValue / 100) - 1) * 1.25;
198
+ $charge += $insurance;
199
+
200
+ $title = $this->getConfigData('name') . ' Express Post International with Extra Cover';
201
+ $method = $this->_createMethod($request, 'EPI-EC', $title, $charge, $charge);
202
+ $result->append($method);
203
+ }
204
+
205
+ // Express Courier International
206
+ // TODO: Create a table for this method.
207
+ }
208
+ else
209
  {
210
+ //============= Standard Post ================
211
+ // Sea Shipping
212
+ $drc = $this->_drcRequest('SEA', $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
213
+
214
+ if($drc['err_msg'] == 'OK')
215
+ {
216
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
217
+ $title = $this->getConfigData('name') . ' Sea Mail' .
218
+ $title_days;
219
+
220
+ $method = $this->_createMethod($request, 'SEA', $title, $drc['charge'], $drc['charge']);
221
+ $result->append($method);
222
+ }
223
+
224
+ // Air Mail
225
+ $drc = $this->_drcRequest('AIR', $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
226
+
227
+ if($drc['err_msg'] == 'OK')
228
+ {
229
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
230
+ $title = $this->getConfigData('name') . ' Air Mail' .
231
+ $title_days;
232
+
233
+ $method = $this->_createMethod($request, 'AIR', $title, $drc['charge'], $drc['charge']);
234
+ $result->append($method);
235
+ }
236
+
237
+ // Express Post International
238
+ $drc = $this->_drcRequest('EPI', $frompcode, $topcode, $destCountry, $sweight, $slength, $swidth, $sheight, $shipping_num_boxes);
239
+
240
+ if($drc['err_msg'] == 'OK')
241
+ {
242
+ $title_days = ($drc['days'] == 1) ? ' (1 day)' : ' (' . $drc['days'] . ' days)';
243
+ $title = $this->getConfigData('name') . ' Express Post International' .
244
+ $title_days;
245
+
246
+ $method = $this->_createMethod($request, 'EPI', $title, $drc['charge'], $drc['charge']);
247
+ $result->append($method);
248
+ }
249
+
250
+ // Express Courier International
251
+ // TODO: Create a table for this method.
252
+ }
253
 
254
+ }
255
+
256
+ return $result;
257
+ }
258
+
259
+ protected function _createMethod($request, $method_code, $title, $price, $cost)
260
+ {
261
+ $shippingPrice = $request->getBaseCurrency()->convert($price, $request->getPackageCurrency());
262
+ $shippingCost = $request->getBaseCurrency()->convert($cost, $request->getPackageCurrency());
263
 
264
+ $method = Mage::getModel('shipping/rate_result_method');
 
265
 
266
+ $method->setCarrier('australiapost');
267
+ $method->setCarrierTitle($this->getConfigData('title'));
 
 
 
 
268
 
269
+ $method->setMethod($method_code);
270
+ $method->setMethodTitle($title);
271
 
272
+ $method->setPrice($this->getFinalPriceWithHandlingFee($shippingPrice));
273
+ $method->setCost($shippingCost);
 
274
 
275
+ return $method;
276
  }
277
+
278
+ protected function _drcRequest($service, $fromPostCode, $toPostCode, $destCountry, $weight, $length, $width, $height, $num_boxes)
279
+ {
280
+ // Construct the appropriate URL and send all the information
281
+ // to the Australia Post DRC.
282
+ $url = "http://drc.edeliver.com.au/ratecalc.asp?" .
283
+ "Pickup_Postcode=" . $fromPostCode .
284
+ "&Destination_Postcode=" . $toPostCode .
285
+ "&Country=" . $destCountry .
286
+ "&Weight=" . $weight .
287
+ "&Service_Type=" . $service .
288
+ "&Height=" . $height .
289
+ "&Width=" . $width .
290
+ "&Length=" . $length .
291
+ "&Quantity=" . $num_boxes;
292
+
293
+ $drc_result = file($url);
294
+ $result = array();
295
+ foreach($drc_result as $vals)
296
+ {
297
+ $tokens = split("=", $vals);
298
+ $result[$tokens[0]] = trim($tokens[1]);
299
+ }
300
+
301
+ return $result;
302
+ }
303
 
304
  /**
305
  * Get allowed shipping methods
app/code/community/Fontis/Australia/Model/Shipping/Carrier/Eparcel.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Originally based on Magento Tablerate Shipping code.
16
+ *
17
+ * @category Fontis
18
+ * @package Fontis_Australia
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+
24
+ /**
25
+ * Australia Post eParcel shipping model
26
+ *
27
+ * @category Fontis
28
+ * @package Fontis_Australia
29
+ */
30
+
31
+ class Fontis_Australia_Model_Shipping_Carrier_Eparcel
32
+ extends Mage_Shipping_Model_Carrier_Abstract
33
+ implements Mage_Shipping_Model_Carrier_Interface
34
+ {
35
+ protected $_code = 'eparcel';
36
+ protected $_default_condition_name = 'package_weight';
37
+
38
+ protected $_conditionNames = array();
39
+
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ foreach ($this->getCode('condition_name') as $k=>$v) {
44
+ $this->_conditionNames[] = $k;
45
+ }
46
+ }
47
+
48
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
49
+ {
50
+ if (!$this->getConfigFlag('active')) {
51
+ return false;
52
+ }
53
+
54
+ if (!$request->getConditionName()) {
55
+ $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
56
+ }
57
+
58
+ $result = Mage::getModel('shipping/rate_result');
59
+ $rates = $this->getRate($request);
60
+
61
+ if(is_array($rates))
62
+ {
63
+ foreach ($rates as $rate)
64
+ {
65
+ if (!empty($rate) && $rate['price'] >= 0) {
66
+ $method = Mage::getModel('shipping/rate_result_method');
67
+
68
+ $method->setCarrier('matrixrate');
69
+ $method->setCarrierTitle($this->getConfigData('title'));
70
+
71
+ $method->setMethod($rate['delivery_type']);
72
+ $method->setMethodTitle($rate['delivery_type']);
73
+
74
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
75
+
76
+ $method->setPrice($shippingPrice);
77
+ $method->setCost($rate['cost']);
78
+ $method->setDeliveryType($rate['delivery_type']);
79
+
80
+ $result->append($method);
81
+ }
82
+ }
83
+ }
84
+ else
85
+ {
86
+ if (!empty($rates) && $rates['price'] >= 0) {
87
+ $method = Mage::getModel('shipping/rate_result_method');
88
+
89
+ $method->setCarrier('eparcel');
90
+ $method->setCarrierTitle($this->getConfigData('title'));
91
+
92
+ $method->setMethod('bestway');
93
+ $method->setMethodTitle($this->getConfigData('name'));
94
+
95
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($rates['price']);
96
+
97
+ $method->setPrice($shippingPrice);
98
+ $method->setCost($rates['cost']);
99
+ $method->setDeliveryType($rates['delivery_type']);
100
+
101
+ $result->append($method);
102
+ }
103
+ }
104
+
105
+ return $result;
106
+ }
107
+
108
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
109
+ {
110
+ return Mage::getResourceModel('australia/shipping_carrier_eparcel')->getRate($request);
111
+ }
112
+
113
+ public function getCode($type, $code='')
114
+ {
115
+ $codes = array(
116
+
117
+ 'condition_name'=>array(
118
+ 'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'),
119
+ 'package_value' => Mage::helper('shipping')->__('Price vs. Destination'),
120
+ 'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'),
121
+ ),
122
+
123
+ 'condition_name_short'=>array(
124
+ 'package_weight' => Mage::helper('shipping')->__('Weight (and above)'),
125
+ 'package_value' => Mage::helper('shipping')->__('Order Subtotal (and above)'),
126
+ 'package_qty' => Mage::helper('shipping')->__('# of Items (and above)'),
127
+ ),
128
+
129
+ );
130
+
131
+ if (!isset($codes[$type])) {
132
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code type: %s', $type));
133
+ }
134
+
135
+ if (''===$code) {
136
+ return $codes[$type];
137
+ }
138
+
139
+ if (!isset($codes[$type][$code])) {
140
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code for type %s: %s', $type, $code));
141
+ }
142
+
143
+ return $codes[$type][$code];
144
+ }
145
+
146
+ /**
147
+ * Get allowed shipping methods
148
+ *
149
+ * @return array
150
+ */
151
+ public function getAllowedMethods()
152
+ {
153
+ return array('bestway'=>$this->getConfigData('name'));
154
+ }
155
+
156
+ /*
157
+ * Tracking code
158
+ */
159
+ public function isTrackingAvailable()
160
+ {
161
+ return true;
162
+ }
163
+
164
+ public function getTrackingInfo($tracking)
165
+ {
166
+ $info = array();
167
+
168
+ $result = $this->getTracking($tracking);
169
+
170
+ if($result instanceof Mage_Shipping_Model_Tracking_Result){
171
+ if ($trackings = $result->getAllTrackings()) {
172
+ return $trackings[0];
173
+ }
174
+ }
175
+ elseif (is_string($result) && !empty($result)) {
176
+ return $result;
177
+ }
178
+
179
+ return false;
180
+ }
181
+
182
+ public function getTracking($trackings)
183
+ {
184
+ if (!is_array($trackings)) {
185
+ $trackings = array($trackings);
186
+ }
187
+
188
+ return $this->_getTracking($trackings);
189
+ }
190
+
191
+ protected function _getTracking($trackings)
192
+ {
193
+ $result = Mage::getModel('shipping/tracking_result');
194
+
195
+ foreach($trackings as $t) {
196
+ $tracking = Mage::getModel('shipping/tracking_result_status');
197
+ $tracking->setCarrier($this->_code);
198
+ $tracking->setCarrierTitle($this->getConfigData('title'));
199
+ $tracking->setTracking($t);
200
+ $tracking->setUrl('http://www.eparcel.com.au/');
201
+ $result->append($tracking);
202
+ }
203
+
204
+ return $result;
205
+ }
206
+
207
+ /**
208
+ * Event Observer. Triggered when a shipment is created.
209
+ */
210
+ public function sendManifest($observer)
211
+ {
212
+ //Mage::log('=========================================================================');
213
+
214
+ $order = $observer->getEvent()->getShipment()->getOrder();
215
+
216
+ if(!($order->getShippingCarrier() instanceof $this)) {
217
+ return $this;
218
+ }
219
+
220
+ // The current timestamp is used several times
221
+ $timestamp = date('c');
222
+
223
+ // Save the consignment number as it will be used more than once
224
+ $consignmentNumber = $order->getIncrementId();
225
+
226
+ $doc = new SimpleXMLElement('<PCMS xmlns="http://www.auspost.com.au/xml/pcms"></PCMS>');
227
+
228
+ $pcms = $doc->addChild('SendPCMSManifest');
229
+
230
+ $head = $pcms->addChild('header');
231
+ $body = $pcms->addChild('body');
232
+
233
+ $head->addChild('TransactionDateTime', $timestamp);
234
+ $head->addChild('TransactionId', $consignmentNumber);
235
+ $head->addChild('TransactionSequence', '0'); // Used to identify a sequence of transactions, N/A
236
+ $head->addChild('ApplicationId', 'MERCHANT');
237
+
238
+ $manifest = $body->addChild('PCMSManifest');
239
+
240
+ $manifest->addChild('MerchantLocationId', $this->getConfigData('merchant_location_id')); // Testing = AWV
241
+ $manifest->addChild('ManifestNumber', $consignmentNumber);
242
+ $manifest->addChild('DateSubmitted', $timestamp);
243
+ $manifest->addChild('DateLodged', $timestamp);
244
+
245
+ // There may be multiple consignments per manifest.
246
+ $consignment = $manifest->addChild('PCMSConsignment');
247
+
248
+ // Get shipping address info
249
+ $shippingAddress = $order->getShippingAddress();
250
+ $name = $shippingAddress->getFirstname().' '.$shippingAddress->getLastname();
251
+ $street = $shippingAddress->getStreet();
252
+
253
+ // TODO: Revert back to using the Magento directory lookup, once they have
254
+ // fixed the code that does loadByName.
255
+ $stateCodes = array(
256
+ 'Victoria' => 'VIC',
257
+ 'New South Wales' => 'NSW',
258
+ 'Australian Capital Territory' => 'ACT',
259
+ 'Northern Territory' => 'NT',
260
+ 'Queensland' => 'QLD',
261
+ 'South Australia' => 'SA',
262
+ 'Tasmania' => 'TAS',
263
+ 'Western Australia' => 'WA'
264
+ );
265
+
266
+
267
+ $consignment->addChild('ConsignmentNumber', $consignmentNumber);
268
+ $consignment->addChild('ChargeCode', $this->getConfigData('charge_code')); // Testing = S2
269
+ $consignment->addChild('DeliveryName', $name);
270
+ if($shippingAddress->getCompany()) { $consignment->addChild('DeliveryCompanyName', $shippingAddress->getCompany()); } // Optional
271
+ if(is_array($street)) {
272
+ $consignment->addChild('DeliveryAddressLine1', $street[0]);
273
+ if(count($street) >= 2) { $consignment->addChild('DeliveryAddressLine2', $street[1]); } // Optional
274
+ if(count($street) >= 3) { $consignment->addChild('DeliveryAddressLine3', $street[2]); } // Optional
275
+ if(count($street) >= 4) { $consignment->addChild('DeliveryAddressLine4', $street[3]); } // Optional
276
+ }
277
+ else {
278
+ $consignment->addChild('DeliveryAddressLine1', $street);
279
+ }
280
+ $consignment->addChild('DeliveryPhoneNumber', $shippingAddress->getTelephone());
281
+ $consignment->addChild('DeliveryEmailAddress', $order->getCustomerEmail());
282
+ $consignment->addChild('DeliverySuburb', $shippingAddress->getCity());
283
+ //$consignment->addChild('DeliveryStateCode', Mage::getModel('directory/region')->loadByName($shippingAddress->getRegion(), 'AU')->getCode());
284
+ $consignment->addChild('DeliveryStateCode', $stateCodes[$shippingAddress->getRegion()]);
285
+ $consignment->addChild('DeliveryPostcode', $shippingAddress->getPostcode());
286
+ $consignment->addChild('DeliveryCountryCode', 'AU'); // International deliveries not currently accepted
287
+ $consignment->addChild('IsInternationalDelivery', 'false'); // International deliveries not currently accepted
288
+ $consignment->addChild('ReturnName', $this->getConfigData('return_name')); // Optional
289
+ $consignment->addChild('ReturnAddressLine1', $this->getConfigData('return_address_1'));
290
+ $consignment->addChild('ReturnAddressLine2', $this->getConfigData('return_address_2')); // Optional
291
+ $consignment->addChild('ReturnAddressLine3', $this->getConfigData('return_address_3')); // Optional
292
+ $consignment->addChild('ReturnAddressLine4', $this->getConfigData('return_address_4')); // Optional
293
+ $consignment->addChild('ReturnSuburb', $this->getConfigData('return_suburb'));
294
+ $consignment->addChild('ReturnStateCode', $this->getConfigData('return_state'));
295
+ $consignment->addChild('ReturnPostcode', $this->getConfigData('return_postcode'));
296
+ $consignment->addChild('ReturnCountryCode', 'AU');
297
+ $consignment->addChild('CreatedDateTime', $timestamp);
298
+ $consignment->addChild('PostChargeToAccount', $this->getConfigData('post_charge_account')); // For Testing = 8830728
299
+ $consignment->addChild('IsSignatureRequired', $this->getConfigData('signature_required') ? 'Y' : 'N'); // Y/N
300
+ $consignment->addChild('DeliverPartConsignment', 'N'); // Y/N
301
+ $consignment->addChild('ContainsDangerousGoods', 'false'); // true/false
302
+
303
+ foreach($order->getAllVisibleItems() as $item) {
304
+ Mage::log('Item: ' . print_r($item->getData(), true));
305
+ // Consignments have one article per product
306
+ $article = $consignment->addChild('PCMSDomesticArticle'); // International deliveries not currently accepted
307
+
308
+ $article->addChild('ArticleNumber', $item->getSku());
309
+ $article->addChild('BarcodeArticleNumber', '');
310
+ //$article->addChild('Length', ''); // Optional
311
+ //$article->addChild('Width', ''); // Optional
312
+ //$article->addChild('Height', ''); // Optional
313
+ $article->addChild('ActualWeight', $item->getRowWeight());
314
+ //$article->addChild('CubicWeight', ''); // Optional
315
+ $article->addChild('ArticleDescription', $item->getShortDescription());
316
+ $article->addChild('IsTransitCoverRequired', 'N');
317
+ //$article->addChild('TransitCoverAmount', '');
318
+
319
+ // All contents are optional
320
+ $contents = $article->addChild('ContentsItem');
321
+
322
+ //$contents->addChild('ProductType', '');
323
+ //$contents->addChild('GoodsDescription', '');
324
+ //$contents->addChild('CountryOriginCode', '');
325
+ //$contents->addChild('Weight', $item->getWeight());
326
+ $contents->addChild('Quantity', $item->getQtyShipped());
327
+ $contents->addChild('UnitValue', $item->getPrice());
328
+ $contents->addChild('Value', $item->getRowTotal());
329
+ //$contents->addChild('HSTariff', '');
330
+ //$contents->addChild('ProductClassification', '');
331
+ //*/
332
+ }
333
+
334
+ $data = $doc->asXML();
335
+
336
+ //Mage::log($data);
337
+
338
+ $soap = new SoapClient('https://test603a.auspost.com.au/despatchManifest/DespatchManifestWS?WSDL', array('login' => 'soaptest', 'password' => 'password'));
339
+ $soap->submitManifestForDespatch($data);
340
+
341
+ // Automatically add tracking information
342
+ $track = Mage::getModel('sales/order_shipment_track');
343
+ $track->setCarrierCode('eparcel');
344
+ $track->setNumber($consignmentNumber);
345
+ $track->setTitle($this->getConfigData('title'));
346
+ $observer->getEvent()->getShipment()->addTrack($track);
347
+
348
+ //Mage::log(print_r($track->getData(), true));
349
+
350
+ return $this;
351
+ }
352
+ }
app/code/community/Fontis/Australia/Model/Shipping/Config/Eparcel.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Backend model for Australia Post eParcel table rates CSV import
24
+ *
25
+ * @category Fontis
26
+ * @package Fontis_Australia
27
+ */
28
+
29
+ class Fontis_Australia_Model_Shipping_Config_Eparcel extends Mage_Core_Model_Config_Data
30
+ {
31
+ public function _afterSave()
32
+ {
33
+ Mage::getResourceModel('australia/shipping_carrier_eparcel')->uploadAndImport($this);
34
+ }
35
+ }
app/code/community/Fontis/Australia/Model/Shipping/Config/Eparcelcondition.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Australia Post shipping weight unit selector and conversion values.
24
+ * All conversion rates are to convert into grams, which is the required unit
25
+ * of weight used by the Australia Post DRC.
26
+ *
27
+ * @category Fontis
28
+ * @package Fontis_Australia
29
+ */
30
+ class Fontis_Australia_Model_Shipping_Config_Eparcelcondition
31
+ {
32
+ public function toOptionArray()
33
+ {
34
+ return array(
35
+ array('value' => 'package_weight', 'label' => Mage::helper('adminhtml')->__('Weight vs Destination')),
36
+ );
37
+ }
38
+ }
app/code/community/Fontis/Australia/etc/config.xml CHANGED
@@ -23,7 +23,7 @@
23
  <config>
24
  <modules>
25
  <Fontis_Australia>
26
- <version>1.0</version>
27
  <depends>
28
  <Mage_Shipping />
29
  <Mage_Payment />
@@ -33,57 +33,77 @@
33
  </Fontis_Australia>
34
  </modules>
35
  <global>
36
- <models>
37
- <australia>
38
- <class>Fontis_Australia_Model</class>
39
- </australia>
40
- </models>
41
- <helpers>
42
- <australia>
43
- <class>Fontis_Australia_Helper</class>
44
- </australia>
45
- </helpers>
46
- <blocks>
47
- <australia>
48
- <class>Fontis_Australia_Block</class>
49
- </australia>
50
- </blocks>
51
- <resources>
52
- <australia_setup>
53
- <setup>
54
- <module>Fontis_Australia</module>
55
- </setup>
56
- <connection>
57
- <use>directory_setup</use>
58
- </connection>
59
- </australia_setup>
60
- <australia_write>
61
- <connection>
62
- <use>local_write</use>
63
- </connection>
64
- </australia_write>
65
- <australia_read>
66
- <connection>
67
- <use>local_read</use>
68
- </connection>
69
- </australia_read>
70
- </resources>
71
- <sales>
72
- <shipping>
73
- <carriers>
74
- <australiapost>
75
- <class>Fontis_Australia_Model_Shipping_Carrier_Australiapost</class>
76
- </australiapost>
77
- </carriers>
78
- </shipping>
79
- <tax>
80
- <methods>
81
- <gst>
82
- <class>Fontis_Australia_Model_Tax_Gst</class>
83
- </gst>
84
- </methods>
85
- </tax>
86
- </sales>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </global>
88
  <frontend>
89
  <routers>
@@ -112,7 +132,30 @@
112
  <title>Australia Post</title>
113
  <name></name>
114
  <weight_units>1000</weight_units>
 
 
 
 
115
  </australiapost>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  </carriers>
117
 
118
  <payment>
23
  <config>
24
  <modules>
25
  <Fontis_Australia>
26
+ <version>1.1</version>
27
  <depends>
28
  <Mage_Shipping />
29
  <Mage_Payment />
33
  </Fontis_Australia>
34
  </modules>
35
  <global>
36
+ <models>
37
+ <australia>
38
+ <class>Fontis_Australia_Model</class>
39
+ <resourceModel>australia_mysql4</resourceModel>
40
+ </australia>
41
+ <australia_mysql4>
42
+ <class>Fontis_Australia_Model_Mysql4</class>
43
+ <entities>
44
+ <eparcel>
45
+ <table>australia_eparcel</table>
46
+ </eparcel>
47
+ </entities>
48
+ </australia_mysql4>
49
+ </models>
50
+ <helpers>
51
+ <australia>
52
+ <class>Fontis_Australia_Helper</class>
53
+ </australia>
54
+ </helpers>
55
+ <blocks>
56
+ <australia>
57
+ <class>Fontis_Australia_Block</class>
58
+ </australia>
59
+ </blocks>
60
+ <resources>
61
+ <australia_setup>
62
+ <setup>
63
+ <module>Fontis_Australia</module>
64
+ </setup>
65
+ <connection>
66
+ <use>directory_setup</use>
67
+ </connection>
68
+ </australia_setup>
69
+ <australia_write>
70
+ <connection>
71
+ <use>core_write</use>
72
+ </connection>
73
+ </australia_write>
74
+ <australia_read>
75
+ <connection>
76
+ <use>core_read</use>
77
+ </connection>
78
+ </australia_read>
79
+ </resources>
80
+ <sales>
81
+ <shipping>
82
+ <carriers>
83
+ <australiapost>
84
+ <class>Fontis_Australia_Model_Shipping_Carrier_Australiapost</class>
85
+ </australiapost>
86
+ </carriers>
87
+ </shipping>
88
+ <tax>
89
+ <methods>
90
+ <gst>
91
+ <class>Fontis_Australia_Model_Tax_Gst</class>
92
+ </gst>
93
+ </methods>
94
+ </tax>
95
+ </sales>
96
+ <events>
97
+ <sales_order_shipment_save_after>
98
+ <observers>
99
+ <fontis_australia_shipment_save>
100
+ <type>singleton</type>
101
+ <class>australia/shipping_carrier_eparcel</class>
102
+ <method>sendManifest</method>
103
+ </fontis_australia_shipment_save>
104
+ </observers>
105
+ </sales_order_shipment_save_after>
106
+ </events>
107
  </global>
108
  <frontend>
109
  <routers>
132
  <title>Australia Post</title>
133
  <name></name>
134
  <weight_units>1000</weight_units>
135
+ <registered_post>0</registered_post>
136
+ <registered_post_charge>2.75</registered_post_charge>
137
+ <delivery_confirmation>0</delivery_confirmation>
138
+ <person_to_person>0</person_to_person>
139
  </australiapost>
140
+ <eparcel>
141
+ <active>0</active>
142
+ <sallowspecific>0</sallowspecific>
143
+ <condition_name>package_weight</condition_name>
144
+ <model>australia/shipping_carrier_eparcel</model>
145
+ <name>eParcel</name>
146
+ <title>Australia Post eParcel</title>
147
+ <sallowspecific>1</sallowspecific>
148
+ <specificcountry>AU</specificcountry>
149
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
150
+ <handling_type>F</handling_type>
151
+ <merchant_location_id>AWV</merchant_location_id>
152
+ <charge_code>S2</charge_code>
153
+ <post_charge_account>1234567</post_charge_account>
154
+ <signature_required>0</signature_required>
155
+ <signature_cost>6.44</signature_cost>
156
+ <insurance_step>100.0</insurance_step>
157
+ <insurance_cost_per_step>1.05</insurance_cost_per_step>
158
+ </eparcel>
159
  </carriers>
160
 
161
  <payment>
app/code/community/Fontis/Australia/etc/system.xml CHANGED
@@ -50,10 +50,19 @@
50
  <show_in_store>1</show_in_store>
51
  <comment>Shown before each shipping method</comment>
52
  </name>
 
 
 
 
 
 
 
 
 
53
  <handling_fee translate="label">
54
  <label>Handling Fee</label>
55
  <frontend_type>text</frontend_type>
56
- <sort_order>7</sort_order>
57
  <show_in_default>1</show_in_default>
58
  <show_in_website>1</show_in_website>
59
  <show_in_store>1</show_in_store>
@@ -62,12 +71,51 @@
62
  <label>Products Use Units</label>
63
  <frontend_type>select</frontend_type>
64
  <source_model>australia/shipping_config_weightunits</source_model>
65
- <sort_order>8</sort_order>
66
  <show_in_default>1</show_in_default>
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>1</show_in_store>
69
  <comment>Specify the weight units that products use - they will be converted to grams</comment>
70
  </weight_units>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  <sort_order translate="label">
72
  <label>Sort order</label>
73
  <frontend_type>text</frontend_type>
@@ -122,6 +170,263 @@
122
  </specificerrmsg>
123
  </fields>
124
  </australiapost>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  </groups>
126
  </carriers>
127
  <payment translate="label" module="payment">
50
  <show_in_store>1</show_in_store>
51
  <comment>Shown before each shipping method</comment>
52
  </name>
53
+ <handling_type translate="label">
54
+ <label>Calculate Handling Fee</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>shipping/source_handlingType</source_model>
57
+ <sort_order>7</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </handling_type>
62
  <handling_fee translate="label">
63
  <label>Handling Fee</label>
64
  <frontend_type>text</frontend_type>
65
+ <sort_order>8</sort_order>
66
  <show_in_default>1</show_in_default>
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>1</show_in_store>
71
  <label>Products Use Units</label>
72
  <frontend_type>select</frontend_type>
73
  <source_model>australia/shipping_config_weightunits</source_model>
74
+ <sort_order>20</sort_order>
75
  <show_in_default>1</show_in_default>
76
  <show_in_website>1</show_in_website>
77
  <show_in_store>1</show_in_store>
78
  <comment>Specify the weight units that products use - they will be converted to grams</comment>
79
  </weight_units>
80
+ <registered_post translate="label">
81
+ <label>Use Registered Post</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>adminhtml/system_config_source_yesno</source_model>
84
+ <sort_order>22</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <comment>Will enable extra options for insurance, calculated at standard Australia Post rates, and will use Registered Post methods instead of regular post.</comment>
89
+ </registered_post>
90
+ <registered_post_charge translate="label">
91
+ <label>Registered Post Charge</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>23</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <comment>Surcharge that is added to shipping when using Registered Post.</comment>
98
+ </registered_post_charge>
99
+ <delivery_confirmation translate="label">
100
+ <label>Use Delivery Confirmation</label>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>adminhtml/system_config_source_yesno</source_model>
103
+ <sort_order>24</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ <comment>The sender of a Registered Post article receives a card signed by the recipient. A $1.85 surcharge will be applied for domestic shipments, $3.30 for international.</comment>
108
+ </delivery_confirmation>
109
+ <person_to_person translate="label">
110
+ <label>Use Person-to-Person</label>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <sort_order>26</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ <comment>The Registered Post article must be signed for by the person named in the address. A $5.50 surcharge will be applied.</comment>
118
+ </person_to_person>
119
  <sort_order translate="label">
120
  <label>Sort order</label>
121
  <frontend_type>text</frontend_type>
170
  </specificerrmsg>
171
  </fields>
172
  </australiapost>
173
+ <eparcel translate="label">
174
+ <label>Australia Post eParcel</label>
175
+ <frontend_type>text</frontend_type>
176
+ <sort_order>2</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ <fields>
181
+ <handling_type translate="label">
182
+ <label>Calculate Handling Fee</label>
183
+ <frontend_type>select</frontend_type>
184
+ <source_model>shipping/source_handlingType</source_model>
185
+ <sort_order>7</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ </handling_type>
190
+ <handling_fee translate="label">
191
+ <label>Handling Fee</label>
192
+ <frontend_type>text</frontend_type>
193
+ <sort_order>8</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>1</show_in_store>
197
+ </handling_fee>
198
+ <merchant_location_id translate="label">
199
+ <label>Merchant Location ID</label>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>9</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ <comment>Provided by Australia Post. The unique ID specifying a specific merchant location.</comment>
206
+ </merchant_location_id>
207
+ <charge_code translate="label">
208
+ <label>Charge Code</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>10</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ <comment>This is an alphanumeric code which identifies the service being used and is supplied by Australia Post.</comment>
215
+ </charge_code>
216
+ <post_charge_account translate="label">
217
+ <label>Post Charge To Account</label>
218
+ <frontend_type>text</frontend_type>
219
+ <sort_order>11</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ <comment>Merchant account to which Australia Post “post” the charges against for invoicing purposes.</comment>
224
+ </post_charge_account>
225
+
226
+ <signature_required translate="label">
227
+ <label>Signature Required</label>
228
+ <frontend_type>select</frontend_type>
229
+ <source_model>adminhtml/system_config_source_yesno</source_model>
230
+ <sort_order>12</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>1</show_in_store>
234
+ <comment>If Yes Australia Post will attempt to capture a signature and if no-one is in attendance the consignment will be “carded”.</comment>
235
+ </signature_required>
236
+ <signature_cost translate="label">
237
+ <label>Signature Cost</label>
238
+ <frontend_type>text</frontend_type>
239
+ <sort_order>13</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>1</show_in_store>
243
+ <comment>Additonal amount to charge for requiring a signature.</comment>
244
+ </signature_cost>
245
+
246
+ <insurance_step translate="label">
247
+ <label>Insurance Step</label>
248
+ <frontend_type>text</frontend_type>
249
+ <sort_order>20</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>1</show_in_store>
253
+ <comment>If insurance is $1.05 per $100, set this field to 100.0</comment>
254
+ </insurance_step>
255
+ <insurance_cost_per_step translate="label">
256
+ <label>Insurance Cost Per Step</label>
257
+ <frontend_type>text</frontend_type>
258
+ <sort_order>21</sort_order>
259
+ <show_in_default>1</show_in_default>
260
+ <show_in_website>1</show_in_website>
261
+ <show_in_store>1</show_in_store>
262
+ <comment>If insurance is $1.05 per $100, set this field to 1.05</comment>
263
+ </insurance_cost_per_step>
264
+
265
+
266
+ <active translate="label">
267
+ <label>Enabled</label>
268
+ <frontend_type>select</frontend_type>
269
+ <source_model>adminhtml/system_config_source_yesno</source_model>
270
+ <sort_order>1</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ </active>
275
+ <condition_name translate="label">
276
+ <label>Condition</label>
277
+ <frontend_type>select</frontend_type>
278
+ <source_model>australia/shipping_config_eparcelcondition</source_model>
279
+ <sort_order>4</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>0</show_in_store>
283
+ </condition_name>
284
+ <export translate="label">
285
+ <label>Export</label>
286
+ <frontend_type>export</frontend_type>
287
+ <sort_order>5</sort_order>
288
+ <show_in_default>0</show_in_default>
289
+ <show_in_website>1</show_in_website>
290
+ <show_in_store>0</show_in_store>
291
+ </export>
292
+ <import translate="label">
293
+ <label>Import</label>
294
+ <frontend_type>import</frontend_type>
295
+ <backend_model>australia/shipping_config_eparcel</backend_model>
296
+ <sort_order>6</sort_order>
297
+ <show_in_default>0</show_in_default>
298
+ <show_in_website>1</show_in_website>
299
+ <show_in_store>0</show_in_store>
300
+ </import>
301
+ <name translate="label">
302
+ <label>Method name</label>
303
+ <frontend_type>text</frontend_type>
304
+ <sort_order>3</sort_order>
305
+ <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ </name>
309
+ <sort_order translate="label">
310
+ <label>Sort order</label>
311
+ <frontend_type>text</frontend_type>
312
+ <sort_order>100</sort_order>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ </sort_order>
317
+ <title translate="label">
318
+ <label>Title</label>
319
+ <frontend_type>text</frontend_type>
320
+ <sort_order>2</sort_order>
321
+ <show_in_default>1</show_in_default>
322
+ <show_in_website>1</show_in_website>
323
+ <show_in_store>1</show_in_store>
324
+ </title>
325
+
326
+ <return_name>
327
+ <label>Return Address Name</label>
328
+ <frontend_type>text</frontend_type>
329
+ <sort_order>60</sort_order>
330
+ <show_in_default>1</show_in_default>
331
+ <show_in_website>1</show_in_website>
332
+ <show_in_store>1</show_in_store>
333
+ </return_name>
334
+ <return_addressline_1>
335
+ <label>Return Address Line 1</label>
336
+ <frontend_type>text</frontend_type>
337
+ <sort_order>61</sort_order>
338
+ <show_in_default>1</show_in_default>
339
+ <show_in_website>1</show_in_website>
340
+ <show_in_store>1</show_in_store>
341
+ </return_addressline_1>
342
+ <return_addressline_2>
343
+ <label>Return Address Line 2</label>
344
+ <frontend_type>text</frontend_type>
345
+ <sort_order>62</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>1</show_in_store>
349
+ </return_addressline_2>
350
+ <return_addressline_3>
351
+ <label>Return Address Line 3</label>
352
+ <frontend_type>text</frontend_type>
353
+ <sort_order>63</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ </return_addressline_3>
358
+ <return_addressline_4>
359
+ <label>Return Address Line 4</label>
360
+ <frontend_type>text</frontend_type>
361
+ <sort_order>64</sort_order>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>1</show_in_website>
364
+ <show_in_store>1</show_in_store>
365
+ </return_addressline_4>
366
+ <return_suburb>
367
+ <label>Return Suburb</label>
368
+ <frontend_type>text</frontend_type>
369
+ <sort_order>65</sort_order>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>1</show_in_website>
372
+ <show_in_store>1</show_in_store>
373
+ </return_suburb>
374
+ <return_state>
375
+ <label>Return State Code</label>
376
+ <frontend_type>text</frontend_type>
377
+ <sort_order>66</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>1</show_in_store>
381
+ <comment>Must be a two- or three-letter state code</comment>
382
+ </return_state>
383
+ <return_postcode>
384
+ <label>Return Postcode</label>
385
+ <frontend_type>text</frontend_type>
386
+ <sort_order>67</sort_order>
387
+ <show_in_default>1</show_in_default>
388
+ <show_in_website>1</show_in_website>
389
+ <show_in_store>1</show_in_store>
390
+ </return_postcode>
391
+
392
+ <sallowspecific translate="label">
393
+ <label>Ship to applicable countries</label>
394
+ <frontend_type>select</frontend_type>
395
+ <sort_order>90</sort_order>
396
+ <frontend_class>shipping-applicable-country</frontend_class>
397
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
398
+ <show_in_default>1</show_in_default>
399
+ <show_in_website>1</show_in_website>
400
+ <show_in_store>1</show_in_store>
401
+ </sallowspecific>
402
+ <specificcountry translate="label">
403
+ <label>Ship to Specific countries</label>
404
+ <frontend_type>multiselect</frontend_type>
405
+ <sort_order>91</sort_order>
406
+ <source_model>adminhtml/system_config_source_country</source_model>
407
+ <show_in_default>1</show_in_default>
408
+ <show_in_website>1</show_in_website>
409
+ <show_in_store>1</show_in_store>
410
+ </specificcountry>
411
+ <showmethod translate="label">
412
+ <label>Show method if not applicable</label>
413
+ <frontend_type>select</frontend_type>
414
+ <sort_order>92</sort_order>
415
+ <source_model>adminhtml/system_config_source_yesno</source_model>
416
+ <show_in_default>1</show_in_default>
417
+ <show_in_website>1</show_in_website>
418
+ <show_in_store>1</show_in_store>
419
+ </showmethod>
420
+ <specificerrmsg translate="label">
421
+ <label>Displayed Error Message</label>
422
+ <frontend_type>textarea</frontend_type>
423
+ <sort_order>80</sort_order>
424
+ <show_in_default>1</show_in_default>
425
+ <show_in_website>1</show_in_website>
426
+ <show_in_store>1</show_in_store>
427
+ </specificerrmsg>
428
+ </fields>
429
+ </eparcel>
430
  </groups>
431
  </carriers>
432
  <payment translate="label" module="payment">
app/code/community/Fontis/Australia/sql/australia_setup/mysql4-install-0.7.0.php CHANGED
@@ -22,6 +22,28 @@
22
  $installer = $this;
23
  $installer->startSetup();
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  // Insert a list of states into the regions database. Magento will then pick
26
  // these up when displaying addresses and allow the user to select from a drop-down
27
  // list, rather than having to type them in manually.
22
  $installer = $this;
23
  $installer->startSetup();
24
 
25
+ // Create a database table for eParcel table rates.
26
+ // This table uses the same structure as the normal table rate table.
27
+ $installer->run("
28
+ DROP TABLE IF EXISTS {$this->getTable('australia_eparcel')};
29
+ CREATE TABLE {$this->getTable('australia_eparcel')} (
30
+ `pk` int(10) unsigned NOT NULL auto_increment,
31
+ `website_id` int(11) NOT NULL default '0',
32
+ `dest_country_id` varchar(4) NOT NULL default '0',
33
+ `dest_region_id` int(10) NOT NULL default '0',
34
+ `dest_zip` varchar(10) NOT NULL default '',
35
+ `condition_name` varchar(20) NOT NULL default '',
36
+ `condition_from_value` decimal(12,4) NOT NULL default '0.0000',
37
+ `condition_to_value` decimal(12,4) NOT NULL default '0.0000',
38
+ `price` decimal(12,4) NOT NULL default '0.0000',
39
+ `price_per_kg` decimal(12,4) NOT NULL default '0.0000',
40
+ `cost` decimal(12,4) NOT NULL default '0.0000',
41
+ `delivery_type` varchar(50) NOT NULL default '',
42
+ PRIMARY KEY (`pk`),
43
+ UNIQUE KEY `dest_country` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_to_value`)
44
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
45
+ ");
46
+
47
  // Insert a list of states into the regions database. Magento will then pick
48
  // these up when displaying addresses and allow the user to select from a drop-down
49
  // list, rather than having to type them in manually.
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fontis_Australia</name>
4
- <version>1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>This extension is intended to provide most of the functionality needed to run a Magento store in Australia. This includes all essential payment and shipping methods as well as small localisations such as adding the store's ABN, adding Australian states and territories to the region directory and adding in a postcode database.</description>
11
  <notes>Currently active are modules for BPAY, direct deposit, Australia Post, the addition of regions and postcodes, and the addition of ABN and phone number to the general configuration values (although currently not in use).</notes>
12
  <authors><author><name>Chris Norton</name><user>auto-converted</user><email>chris.norton@fontis.com.au</email></author><author><name>Lloyd Hazlett</name><user>auto-converted</user><email>hazzard43@fastmail.fm</email></author></authors>
13
- <date>2008-10-27</date>
14
- <time>07:14:15</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="fontis"><dir name="australia"><dir name="payment"><dir name="bpay"><file name="form.phtml" hash="2bd318e4e8ac220a6b2f8339d5cf090d"/><file name="info.phtml" hash="70dae47552b94f5773afb59d00555a4b"/></dir><dir name="directdeposit"><file name="form.phtml" hash="1d01443b2e0f3147bf65dd9c799d4744"/><file name="info.phtml" hash="70d76862e026d4e8d76e6c32a36a5d74"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="fontis"><dir name="australia"><dir name="payment"><dir name="bpay"><file name="form.phtml" hash="2bd318e4e8ac220a6b2f8339d5cf090d"/><file name="info.phtml" hash="f578ec338f8b333f20af6253676fa167"/></dir><dir name="directdeposit"><file name="form.phtml" hash="1ad42dfd4409c49166e864469b24b898"/><file name="info.phtml" hash="70d76862e026d4e8d76e6c32a36a5d74"/></dir></dir><file name="postcode-checkout.phtml" hash="51867acd43c4f8c982ab1fea103a579f"/><file name="postcode.phtml" hash="b0d7bfa170c7ca3bd4a256f0404d7189"/><file name="postcode.phtml.~1~" hash="85dbbd2b416f85f230dcce12e52cb397"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Fontis"><dir name="Australia"><dir name="Block"><dir name="Bpay"><file name="Form.php" hash="958e11d14d7c87054a68d34b60c498d6"/><file name="Info.php" hash="a28f40be3c76637eb43ba80c61031512"/></dir><dir name="Directdeposit"><file name="Form.php" hash="13589d5d85499678bdc62fde04107095"/><file name="Info.php" hash="0f31ac7451127c87813c823423a9057b"/></dir><file name="Autocomplete.php" hash="4f33f809dae969781ead580b13e9bd3a"/></dir><dir name="controllers"><file name="AjaxController.php" hash="5fb086e3236446b6a6f10f4c78eb3fcb"/></dir><dir name="etc"><file name="config.xml" hash="dfe2fc7f2706d90f6f41f89d9cdfe3db"/><file name="system.xml" hash="da40a4584279c6b0618f64ec5c6651fd"/></dir><dir name="Helper"><file name="Data.php" hash="e493486d7a5ccd5589d99d08b136b819"/></dir><dir name="Model"><dir name="Config"><file name="CustomerGroupAccess.php" hash="e531a8049b9a877e01c2b806b065dbef"/><file name="CustomerGroups.php" hash="8014e56b1141cb9bbb63f807ec1c87a5"/></dir><dir name="Payment"><file name="Bpay.php" hash="56d5b9d3e17cbc9ff4316fef2574401a"/><file name="Directdeposit.php" hash="21c4febe6d321450fba4de5e655093c8"/></dir><dir name="Shipping"><dir name="Carrier"><file name="Australiapost.php" hash="791bdc2384774739a7563ab548400cbc"/></dir><dir name="Config"><file name="Weightunits.php" hash="e13ba9de393ae67420f863d4008c3c72"/></dir></dir><dir name="Tax"><file name="Gst.php" hash="d7e024971dab498e80de8c957d2911f2"/></dir></dir><dir name="sql"><dir name="australia_setup"><file name="mysql4-install-0.7.0.php" hash="c85da407f2817d022b065a3baa1b2688"/><file name="postcodes.txt" hash="21083a0f94e200259c9b4540666b251e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fontis_Australia.xml" hash="a60b83cf1b1b449a16fe09da16342a4d"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fontis_Australia</name>
4
+ <version>1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
10
  <description>This extension is intended to provide most of the functionality needed to run a Magento store in Australia. This includes all essential payment and shipping methods as well as small localisations such as adding the store's ABN, adding Australian states and territories to the region directory and adding in a postcode database.</description>
11
  <notes>Currently active are modules for BPAY, direct deposit, Australia Post, the addition of regions and postcodes, and the addition of ABN and phone number to the general configuration values (although currently not in use).</notes>
12
  <authors><author><name>Chris Norton</name><user>auto-converted</user><email>chris.norton@fontis.com.au</email></author><author><name>Lloyd Hazlett</name><user>auto-converted</user><email>hazzard43@fastmail.fm</email></author></authors>
13
+ <date>2009-02-06</date>
14
+ <time>00:52:33</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="fontis"><dir name="australia"><dir name="payment"><dir name="bpay"><file name="form.phtml" hash="2bd318e4e8ac220a6b2f8339d5cf090d"/><file name="info.phtml" hash="70dae47552b94f5773afb59d00555a4b"/></dir><dir name="directdeposit"><file name="form.phtml" hash="1d01443b2e0f3147bf65dd9c799d4744"/><file name="info.phtml" hash="70d76862e026d4e8d76e6c32a36a5d74"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="fontis"><dir name="australia"><dir name="payment"><dir name="bpay"><file name="form.phtml" hash="2bd318e4e8ac220a6b2f8339d5cf090d"/><file name="info.phtml" hash="f578ec338f8b333f20af6253676fa167"/></dir><dir name="directdeposit"><file name="form.phtml" hash="1ad42dfd4409c49166e864469b24b898"/><file name="info.phtml" hash="70d76862e026d4e8d76e6c32a36a5d74"/></dir></dir><file name="postcode-checkout.phtml" hash="51867acd43c4f8c982ab1fea103a579f"/><file name="postcode.phtml" hash="b0d7bfa170c7ca3bd4a256f0404d7189"/><file name="postcode.phtml.~1~" hash="85dbbd2b416f85f230dcce12e52cb397"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Fontis"><dir name="Australia"><dir name="Block"><dir name="Bpay"><file name="Form.php" hash="958e11d14d7c87054a68d34b60c498d6"/><file name="Info.php" hash="a28f40be3c76637eb43ba80c61031512"/></dir><dir name="Directdeposit"><file name="Form.php" hash="13589d5d85499678bdc62fde04107095"/><file name="Info.php" hash="0f31ac7451127c87813c823423a9057b"/></dir><file name="Autocomplete.php" hash="4f33f809dae969781ead580b13e9bd3a"/></dir><dir name="controllers"><file name="AjaxController.php" hash="5fb086e3236446b6a6f10f4c78eb3fcb"/></dir><dir name="etc"><file name="config.xml" hash="065996bf3178e22242bc2f4bd7967189"/><file name="system.xml" hash="55e1454a117345d75972ce83501f1cf1"/></dir><dir name="Helper"><file name="Data.php" hash="e493486d7a5ccd5589d99d08b136b819"/></dir><dir name="Model"><dir name="Config"><file name="CustomerGroupAccess.php" hash="e531a8049b9a877e01c2b806b065dbef"/><file name="CustomerGroups.php" hash="8014e56b1141cb9bbb63f807ec1c87a5"/></dir><dir name="Mysql4"><dir name="Shipping"><dir name="Carrier"><dir name="Eparcel"><file name="Collection.php" hash="87f450c6b318060b83e7d7d0662cdf50"/></dir><file name="Eparcel.php" hash="17a03d0e38cb193539938b5f092d0398"/></dir></dir></dir><dir name="Payment"><file name="Bpay.php" hash="56d5b9d3e17cbc9ff4316fef2574401a"/><file name="Directdeposit.php" hash="21c4febe6d321450fba4de5e655093c8"/></dir><dir name="Shipping"><dir name="Carrier"><file name="Australiapost.php" hash="1d5feafcee979417f0c654a5b159a6b6"/><file name="Eparcel.php" hash="952dda45bd21c68d14d110850c3a749e"/></dir><dir name="Config"><file name="Eparcel.php" hash="8c754cdc86316dbee53db68f0e2652bc"/><file name="Eparcelcondition.php" hash="b8cc830ab6e0e397d32bf574f60b0500"/><file name="Weightunits.php" hash="e13ba9de393ae67420f863d4008c3c72"/></dir></dir><dir name="Tax"><file name="Gst.php" hash="d7e024971dab498e80de8c957d2911f2"/></dir></dir><dir name="sql"><dir name="australia_setup"><file name="mysql4-install-0.7.0.php" hash="f475b13bb5319599c4a852cfb8788f9a"/><file name="postcodes.txt" hash="21083a0f94e200259c9b4540666b251e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fontis_Australia.xml" hash="a60b83cf1b1b449a16fe09da16342a4d"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>