Page 1 of 2

Notice: Undefined offset in auspost.php

Posted: Fri Oct 19, 2012 8:26 pm
by SRD
On this website, during checkout, step 4: delivery, I receive the following errors:
Notice: Undefined offset: 1 in /catalog/model/shipping/auspost.php on line 39
Notice: Undefined offset: 1 in /catalog/model/shipping/auspost.php on line 79
Lines 38,39;78,79 of auspost.php:

Code: Select all

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

				foreach ($parts as $part) {
					list($key, $value) = explode('=', $part);
Here is the full auspost.php

I am pretty sure this is the default AusPost postage provider which came with OpenCart.

Re: Notice: Undefined offset in auspost.php

Posted: Sun Oct 21, 2012 6:36 am
by Avvici
Arrays are often serialized so that they can be stored in a database text field. If you change the data within a serialized array, without changing the character count, you will get the error above.
For example take this code:

Code: Select all

<?php
$thing = array('one','two');
echo serialize($thing);
?>
This will echo out the following: a:2:{i:0;s:3:”one”;i:1;s:3:”two”;}
Now… if you stored that in a database, you could then retrieve it later and unserialize() it to get your array back. wohoo!

In that serialized data, s:3:”one” means that the first element in the array is a string, and that it’s 3 characters long. Now.. if you manually changed “one” to “otherone” like this a:2:{i:0;s:3:”otherone”;i:1;s:3:”two”;} then when you ran it through unserialize() to retrieve your array, you would get the error were talking about.

Fix: To correct this you would need to update the string length also like so: a:2:{i:0;s:8:”otherone”;i:1;s:3:”two”;} because “otherone” is actually 8 characters long.

Point is, the string in the field is malformed;) It needs to replaced.

Re: Notice: Undefined offset in auspost.php

Posted: Sun Oct 21, 2012 9:55 am
by SRD
Hi avvici

Thank you for your insight. I understand the theory, but I am not a programmer, and I don't understand what needs to happen to fix the file.

The file is the default which came with OpenCart. I might raise a bug report...

Re: Notice: Undefined offset in auspost.php

Posted: Sun Oct 21, 2012 11:35 am
by Avvici
No, it's not a bug. Yes you are using the default open cart but you have a custom shipping extension that is causing the error. Bug report won' t help. I don't mind looking at the code for you. Just PM me the control file.

Re: Notice: Undefined offset in auspost.php

Posted: Sun Oct 21, 2012 12:06 pm
by SRD
Thanks.

The control file is here.

Re: Notice: Undefined offset in auspost.php

Posted: Sun Oct 21, 2012 4:38 pm
by SRD
Australia Post is not a custom shipping method; it came with the default installation of OpenCart.

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 2:27 am
by Avvici
That is the model. I need the controller.

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 12:53 pm
by philbydevil
I would highly recommend ditching the default Australia Post extension and installing this one:
http://forum.opencart.com/viewtopic.php?f=119&t=5638

It has many more options than the default one...

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 6:30 pm
by SRD
I've PM'd you the controler avvici

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 6:32 pm
by SRD
Thanks philbydevil. I'm using OC 1.5.4, and the max version that extension is compatible with is 1.5.2...

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 6:54 pm
by philbydevil
I run 1.5.4.1 and it works fine. Read the last few pages of the thread as some people have reported issues with weights/dimensions/split shipping but I haven't had any problems.

Give it a try, it's got a lot more options...

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 7:03 pm
by philbydevil
PS - I think the default and other extension have the same filenames so you might have to rename one set

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 7:20 pm
by SRD
Thanks. I've deleted the old AusPost, and uploaded the new one. I've enabled the Shipping module, and enabled some of the postage options, but in checkout, when I get to the step of selecting the shipping, I receive "Warning: No Shipping options are available. Please contact us for assistance!"

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 7:25 pm
by SRD
Here's the shipping screen, and the top of the AusPost screen:

Image

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 7:53 pm
by philbydevil
I think there's an extra "global" enable/disable towards the bottom

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 8:03 pm
by SRD
Yep, Status is set to Enabled.

Re: Notice: Undefined offset in auspost.php

Posted: Mon Oct 22, 2012 8:13 pm
by philbydevil
Are the geo zones set up correctly?

Re: Notice: Undefined offset in auspost.php

Posted: Tue Oct 23, 2012 8:02 pm
by SRD
Geo Zones is set to All Zones in the AusPost module settings.

Is there another location they should be set?

Re: Notice: Undefined offset in auspost.php

Posted: Tue Oct 23, 2012 8:18 pm
by philbydevil
So Geo Zones should be set to All Zones if you want to use Australia Post to ship to all geo zones that you have set up.

But then double-check that the actual Geo Zones (System->Localization->Geo Zones) are set up correctly and include the country/countries you want to ship to.

So, I have two Geo Zones - Australia and International. Obviously, Australia just has Australia. International includes all of the other countries I sell to. Lets me choose different shipping/payment methods for the two zones.

And you did replace all of the Aus Post module files (both catalog and admin)?

Re: Notice: Undefined offset in auspost.php

Posted: Tue Oct 23, 2012 8:34 pm
by SRD
So the 2 existing Geo zones were UK Shipping & UK VAT Zone.

I added a zone called Australia, and added the country Australia to this zone.

I still receive "Warning: No Shipping options are available. Please contact us for assistance!".

Yes, I replaced both catalog and admin files...