Page 1 of 1

shipping undefined offset: 1

Posted: Mon Oct 24, 2011 5:05 am
by average_joe
Hello,

I need some help.

I am working through the checkout stage.
Once I get past the shipping prices I click continue, and it does not go to payment method.
I get this error code..

Code: Select all

PHP Notice:  Undefined offset:  1 in .../store/catalog/controller/checkout/shipping.php on line 31
What reads along that 31 line is..

Code: Select all

if (!isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) [
$json['error']['warning'] = $this->language->get('error_shipping');
               }
Does anyone know what is wrong?

I'm using version 1.5.1

thank you

shipping undefined offset: 1

Posted: Mon Oct 24, 2011 5:32 am
by uksitebuilder
Its most definitely a bug in the shipping module you are using

Re: shipping undefined offset: 1

Posted: Tue Oct 25, 2011 12:44 am
by average_joe
i'm using Qphoria's USPS shipping module, but if I were to change it to any other shipping module the same thing happens..

Is there anything I can do to fix it?

Re: shipping undefined offset: 1

Posted: Wed Oct 26, 2011 2:16 am
by Qphoria
I don't have a USPS shipping module for 1.5.x
There is only the one in the core and I've never seen this.
Try updating to the latest version of opencart or at least the latest version of the USPS module from the 1.5.1.3.1 zip (catalog/model/shipping/usps.php)

Re: shipping undefined offset: 1

Posted: Thu Oct 27, 2011 4:41 am
by average_joe
i've tried the updated USPS module from the newest opencart version, and it still has the same results..

each time I change the module, it does the same thing.
I've even tried to update to an entirely new opencart version.

I'm not sure what happened

Re: shipping undefined offset: 1

Posted: Tue Dec 13, 2011 6:24 pm
by 24-7-open
Problem lies most likely in the interpunction or formatting of your shipping rates. Check all .,:

Re: shipping undefined offset: 1

Posted: Thu Dec 15, 2011 7:07 pm
by frenzy111
i'm not using opencart, but after spending several hours with the same bug incorporating the usps api on my site I figured i'd share my thoughts.

I have 3 different pages that im using to call the rates check, all with the same variables. 2 of them are bare bones, the 3rd (which is getting the undefined offset 1 error) is the actual page for my site. The only differences i can tell is that on the 3rd page, im calling a function to return the rates. I've also changed it to just echo it out, but in either case, I get the rates fine, it's just the damn error won't go away. Venture any guesses? i'll check back tomorrow

Re: shipping undefined offset: 1

Posted: Sat Dec 17, 2011 10:57 am
by frenzy111
I discovered a solution to my particular problem. Hope it helps someone. In my code here, there is a value of $extra which is never defined. I commented out this part, and then printed out the array being returned.

Code: Select all

	if (array_key_exists('attributes',$xml_elem)) {
			list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
		} else {
After seeing what values were being printed out,
i returned the the following

Code: Select all

return $params['RATEV4RESPONSE']['PACKAGE']['POSTAGE']['RATE'];
So it would seem to me it has something to do with the array values. I'm just going with what works. going to test out the rest of the shipping methods and hope all goes well.