Post by jack65 » Wed Aug 29, 2012 12:43 pm

Hi,
While setting a new install i can not get the Australia post mod to work,
The system gives the option to check the postage but then when you enter the details it just sits there.
it's like it is not calling any thing into action, below is the error log stuff.
2012-08-28 23:05:23 - PHP Notice: Undefined offset: 1 in shop/catalog/model/shipping/auspost.php on line 39
2012-08-28 23:05:23 - PHP Notice: Undefined offset: 1 in shop/catalog/model/shipping/auspost.php on line 79

Regards
Steve.
Last edited by jack65 on Wed Aug 29, 2012 8:18 pm, edited 1 time in total.

Newbie

Posts

Joined
Wed Aug 29, 2012 7:59 am

Post by jack65 » Wed Aug 29, 2012 8:15 pm

Hi - if any one else has the same problem i found this fix in the bugs area


<?php
class ModelShippingAusPost extends Model {
public function getQuote($address) {
$this->load->language('shipping/auspost');

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('auspost_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('auspost_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}

$error = '';

$quote_data = array();

if ($status) {
$weight = $this->weight->convert($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->config->get('auspost_weight_class_id'));

if ($this->config->get('auspost_standard') && $address['iso_code_2'] == 'AU') {
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'http://drc.edeliver.com.au/ratecalc.asp ... _postcode=' . urlencode($this->config->get('auspost_postcode')) . '&destination_postcode=' . urlencode($address['postcode']) . '&height=70&width=70&length=70&country=AU&service_type=standard&quantity=1&weight=' . urlencode($weight));
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($curl);

curl_close($curl);

if ($response) {
$response_info = array();

$parts = explode("\n", trim($response));

foreach ($parts as $part) {
list($key, $value) = explode('=', $part);

$response_info[$key] = $value;
}

if ($response_info['err_msg'] != 'OK') {
$error = $response_info['err_msg'];
} else {
$title = $this->language->get('text_standard');

if ($this->config->get('auspost_display_time')) {
$title .= ' (' . $response_info['days'] . ' ' . $this->language->get('text_eta') . ')';
}

$quote_data['standard'] = array(
'code' => 'auspost.standard',
'title' => $title,
'cost' => $this->currency->convert($response_info['charge'], 'AUD', $this->config->get('config_currency')),
'tax_class_id' => $this->config->get('auspost_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($this->currency->convert($response_info['charge'], 'AUD', $this->currency->getCode()), $this->config->get('auspost_tax_class_id'), $this->config->get('config_tax')), $this->currency->getCode(), 1.0000000)
);
}
}
}

if ($this->config->get('auspost_express') && $address['iso_code_2'] == 'AU') {
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'http://drc.edeliver.com.au/ratecalc.asp ... _postcode=' . urlencode($this->config->get('auspost_postcode')) . '&destination_postcode=' . urlencode($address['postcode']) . '&height=70&width=70&length=70&country=AU&service_type=express&quantity=1&weight=' . urlencode($weight));
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($curl);

curl_close($curl);

if ($response) {
$response_info = array();

$parts = explode("\n", trim($response));

foreach ($parts as $part) {
list($key, $value) = explode('=', $part);

$response_info[$key] = $value;
}

if ($response_info['err_msg'] != 'OK') {
$error = $response_info['err_msg'];
} else {
$title = $this->language->get('text_express');

if ($this->config->get('auspost_display_time')) {
$title .= ' (' . $response_info['days'] . ' ' . $this->language->get('text_eta') . ')';
}

$quote_data['express'] = array(
'code' => 'auspost.express',
'title' => $title,
'cost' => $this->currency->convert($response_info['charge'], 'AUD', $this->config->get('config_currency')),
'tax_class_id' => $this->config->get('auspost_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($this->currency->convert($response_info['charge'], 'AUD', $this->currency->getCode()), $this->config->get('auspost_tax_class_id'), $this->config->get('config_tax')), $this->currency->getCode(), 1.0000000)
);
}
}
}
}

$method_data = array();

if ($quote_data) {
$method_data = array(
'code' => 'auspost',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('auspost_sort_order'),
'error' => $error
);
}

return $method_data;
}
}
?>

Regards
Steve.

Newbie

Posts

Joined
Wed Aug 29, 2012 7:59 am

Post by bamzero » Mon Oct 01, 2012 12:18 pm

The lines

$parts = explode("\n", trim($response));

should also really be

$parts = explode("\r\n", trim($response));

otherwise you'll end up with return characters in the array.

Newbie

Posts

Joined
Mon Oct 01, 2012 12:16 pm

Post by mintjelly » Tue Jan 22, 2013 8:47 am

So what exactly is fixed here? All this code means nothing to me. Can someone be more specific? I see that many people have had no issues whatsoever with this module. I am wondering why I need to fix anything in the code?

Newbie

Posts

Joined
Mon Jul 09, 2012 8:20 am
Who is online

Users browsing this forum: No registered users and 8 guests