Post by emadrazanmay » Sun Apr 26, 2020 5:03 am

Hi guys
opencart version : 2.3.0.2
php version :7.4.5
i got this error on checkout page:

Code: Select all

trying to access array offset on value of type bool in system/storage/modification/catalog/controller/startup/startup.php on line 171
the code responsible for this error is :

----------------------------------------------

Code: Select all

        if (isset($this->session->data['shipping_address'])) {
		$this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']);
	} elseif ($this->config->get('config_tax_default') == 'shipping') {
		$this->tax->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
	}
----------------------------------------------
code in line "171" is :
----------------------------------------------

Code: Select all

$this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']);
----------------------------------------------
thanks for the help
Last edited by straightlight on Sun Apr 26, 2020 6:02 am, edited 1 time in total.

Newbie

Posts

Joined
Mon Jun 03, 2019 2:51 am

Post by straightlight » Sun Apr 26, 2020 6:05 am

See if the following could solved the issue for this version of PHP since it is still quite recent:

replace:

Code: Select all

if (isset($this->session->data['shipping_address'])) {
with:

Code: Select all

if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by emadrazanmay » Sun Apr 26, 2020 6:29 am

yes it solved the problem
thank you straightlight for the great help

Newbie

Posts

Joined
Mon Jun 03, 2019 2:51 am

Post by aaron1988 » Sat May 16, 2020 8:00 am

This also helped me fix the issue for PHP 7.4 :) fantastic job.

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by dashingwebtech » Thu Jun 04, 2020 10:17 pm

This solution is really solve my issue. Its very irritating when any error occurred in live server.
So big thank you @straightlight

Dashingwebtech


Posts

Joined
Sun May 17, 2020 10:07 pm

Post by straightlight » Thu Jun 04, 2020 10:38 pm

dashingwebtech wrote:
Thu Jun 04, 2020 10:17 pm
This solution is really solve my issue. Its very irritating when any error occurred in live server.
So big thank you @straightlight

Dashingwebtech
No problem. This fix as already been added in the pre-release version.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by 5miffy » Mon Jun 08, 2020 8:26 pm

Thanks @straightlight for that fix.
I enabled PHP7.4 on an Opencart 3 site and the error was bugging the hell out of me until I used your suggestion!

Newbie

Posts

Joined
Wed Nov 18, 2015 2:09 am

Post by IT beheerder KIK » Tue Jul 28, 2020 7:31 pm

This also helped me. Thanks a lot!

New member

Posts

Joined
Thu Jun 11, 2020 7:42 pm

Post by gerstavros » Fri Aug 21, 2020 9:59 pm

Solution worked, thanks

Code: Select all

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Trying to access array offset on value of type bool in <b>/var/www/site/html/catalog/controller/startup/startup.php</b> on line <b>166</b><b>Notice</b>: Trying to access array offset on value of type bool in <b>/var/www/site/html/catalog/controller/startup/startup.php</b> on line <b>166</b>{"country_id":"2","name":"Albania","iso_code_2":"AL","iso_code_3":"ALB","address_format":"","postcode_required":"0","zone":[{"zone_id":"33","country_id":"2","name":"Berat","code":"BR","status":"1"},{"zone_id":"34","country_id":"2","name":"Bulqize","code":"BU","status":"1"},{"zone_id":"35","country_id":"2","name":"Delvine","code":"DL","status":"1"},{"zone_id":"36","country_id":"2","name":"Devoll","code":"DV","status":"1"},{"zone_id":"37","country_id":"2","name":"Diber","code":"DI","status":"1"},{"zone_id":"38","country_id":"2","name":"Durres","code":"DR","status":"1"},{"zone_id":"39","country_id":"2","name":"Elbasan","code":"EL","status":"1"},{"zone_id":"41","country_id":"2","name":"Fier","code":"FR","status":"1"},{"zone_id":"42","country_id":"2","name":"Gjirokaster","code":"GJ","status":"1"},{"zone_id":"43","country_id":"2","name":"Gramsh","code":"GR","status":"1"},{"zone_id":"44","country_id":"2","name":"Has","code":"HA","status":"1"},{"zone_id":"45","country_id":"2","name":"Kavaje","code":"KA","status":"1"},{"zone_id":"40","country_id":"2","name":"Kolonje","code":"ER","status":"1"},{"zone_id":"48","country_id":"2","name":"Korce","code":"KO","status":"1"},{"zone_id":"49","country_id":"2","name":"Kruje","code":"KR","status":"1"},{"zone_id":"47","country_id":"2","name":"Kucove","code":"KC","status":"1"},{"zone_id":"50","country_id":"2","name":"Kukes","code":"KU","status":"1"},{"zone_id":"46","country_id":"2","name":"Kurbin","code":"KB","status":"1"},{"zone_id":"52","country_id":"2","name":"Lezhe","code":"LE","status":"1"},{"zone_id":"51","country_id":"2","name":"Librazhd","code":"LB","status":"1"},{"zone_id":"53","country_id":"2","name":"Lushnje","code":"LU","status":"1"},{"zone_id":"54","country_id":"2","name":"Malesi e Madhe","code":"MM","status":"1"},{"zone_id":"55","country_id":"2","name":"Mallakaster","code":"MK","status":"1"},{"zone_id":"56","country_id":"2","name":"Mat","code":"MT","status":"1"},{"zone_id":"57","country_id":"2","name":"Mirdite","code":"MR","status":"1"},{"zone_id":"58","country_id":"2","name":"Peqin","code":"PQ","status":"1"},{"zone_id":"59","country_id":"2","name":"Permet","code":"PR","status":"1"},{"zone_id":"60","country_id":"2","name":"Pogradec","code":"PG","status":"1"},{"zone_id":"61","country_id":"2","name":"Puke","code":"PU","status":"1"},{"zone_id":"64","country_id":"2","name":"Sarande","code":"SR","status":"1"},{"zone_id":"62","country_id":"2","name":"Shkoder","code":"SH","status":"1"},{"zone_id":"63","country_id":"2","name":"Skrapar","code":"SK","status":"1"},{"zone_id":"65","country_id":"2","name":"Tepelene","code":"TE","status":"1"},{"zone_id":"67","country_id":"2","name":"Tirane","code":"TR","status":"1"},{"zone_id":"66","country_id":"2","name":"Tropoje","code":"TP","status":"1"},{"zone_id":"68","country_id":"2","name":"Vlore","code":"VL","status":"1"}],"status":"1"}
Last edited by gerstavros on Sun Aug 23, 2020 3:55 am, edited 1 time in total.

New member

Posts

Joined
Mon Apr 04, 2016 12:44 am

Post by straightlight » Sat Aug 22, 2020 2:58 am

What is on line 66 of that file?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by gerstavros » Sun Aug 23, 2020 3:51 am

straightlight wrote:
Sat Aug 22, 2020 2:58 am
What is on line 66 of that file?
the code reading the address

Code: Select all

		if (isset($this->session->data['shipping_address'])) {
			$this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']);
		} elseif ($this->config->get('config_tax_default') == 'shipping') {
			$this->tax->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
		}
EDIT: it worked, file was somehow restored in default, or i never saved the changes...

New member

Posts

Joined
Mon Apr 04, 2016 12:44 am

Post by debruyckerejohan » Sat Dec 12, 2020 6:59 pm

thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan


Posts

Joined
Fri May 01, 2020 4:21 pm

Post by johans » Thu Apr 15, 2021 10:07 pm

debruyckerejohan wrote:
Sat Dec 12, 2020 6:59 pm
thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan
THIS ONE WORKS!

Thanks,
Mr. J


New member

Posts

Joined
Mon Oct 17, 2011 5:08 pm

Post by straightlight » Thu Apr 15, 2021 10:10 pm

johans wrote:
Thu Apr 15, 2021 10:07 pm
debruyckerejohan wrote:
Sat Dec 12, 2020 6:59 pm
thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan
THIS ONE WORKS!
Thanks for the feedback. However, this fix has already been integrated into the OC v3.0.3.7 release.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by aerogel » Thu Apr 22, 2021 4:26 pm

straightlight wrote:
Sun Apr 26, 2020 6:05 am
See if the following could solved the issue for this version of PHP since it is still quite recent:

replace:

Code: Select all

if (isset($this->session->data['shipping_address'])) {
with:

Code: Select all

if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
life is such an easy journey when someone knows what to do!
thanks alot

New member

Posts

Joined
Thu Jan 04, 2018 8:14 pm

Post by niczous » Fri Jun 18, 2021 1:05 am

debruyckerejohan wrote:
Sat Dec 12, 2020 6:59 pm
thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan
Hi!

I am using Version 3.0.3.6 and PHP 7.4

I tried to use the solution mentioned above but it doesn't work. This error affected the new registered customer. Previous customers are doing okay.

Thank you in advance.

Newbie

Posts

Joined
Sat Jun 03, 2017 6:28 pm

Post by straightlight » Fri Jun 18, 2021 1:43 am

niczous wrote:
Fri Jun 18, 2021 1:05 am
debruyckerejohan wrote:
Sat Dec 12, 2020 6:59 pm
thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan
Hi!

I am using Version 3.0.3.6 and PHP 7.4

I tried to use the solution mentioned above but it doesn't work. This error affected the new registered customer. Previous customers are doing okay.

Thank you in advance.
Then, something else is affecting your store that may originate from an installed extension.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by niczous » Fri Jun 18, 2021 11:03 am

straightlight wrote:
Fri Jun 18, 2021 1:43 am
niczous wrote:
Fri Jun 18, 2021 1:05 am
debruyckerejohan wrote:
Sat Dec 12, 2020 6:59 pm
thanks,
working with "Version 3.0.3.2"
it helped me to.
i changed in ../catalog/controller/startup/startup.php

if (isset($this->session->data['shipping_address'])) {
changes to
if (isset($this->session->data['shipping_address']['country_id']) && isset($this->session->data['shipping_address']['zone_id'])) {
AND
if (isset($this->session->data['payment_address'])) {
changes to
if (isset($this->session->data['payment_address']['country_id']) && isset($this->session->data['payment_address']['zone_id'])) {

Grz,
Johan
Hi!

I am using Version 3.0.3.6 and PHP 7.4

I tried to use the solution mentioned above but it doesn't work. This error affected the new registered customer. Previous customers are doing okay.

Thank you in advance.
Then, something else is affecting your store that may originate from an installed extension.
The last extension I installed was PHPmailer to solve my SMTP error on checkout and I have just uninstalled it but still getting the error on 166.

Newbie

Posts

Joined
Sat Jun 03, 2017 6:28 pm

Post by straightlight » Fri Jun 18, 2021 6:20 pm

niczous wrote:
Fri Jun 18, 2021 11:03 am
straightlight wrote:
Fri Jun 18, 2021 1:43 am
niczous wrote:
Fri Jun 18, 2021 1:05 am


Hi!

I am using Version 3.0.3.6 and PHP 7.4

I tried to use the solution mentioned above but it doesn't work. This error affected the new registered customer. Previous customers are doing okay.

Thank you in advance.
Then, something else is affecting your store that may originate from an installed extension.
The last extension I installed was PHPmailer to solve my SMTP error on checkout and I have just uninstalled it but still getting the error on 166.
Which full PHP version are you using? Also, are you sure your changes are reflecting? Which type of server package are you using? Are your PHP files being saved as UTF-8 without BOM? If you reduce your PHP version back to 7.3x releases, is the line 166 error still showing?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by niczous » Sat Jun 19, 2021 5:10 am

straightlight wrote:
Fri Jun 18, 2021 6:20 pm
niczous wrote:
Fri Jun 18, 2021 11:03 am
straightlight wrote:
Fri Jun 18, 2021 1:43 am


Then, something else is affecting your store that may originate from an installed extension.
The last extension I installed was PHPmailer to solve my SMTP error on checkout and I have just uninstalled it but still getting the error on 166.
Which full PHP version are you using? Also, are you sure your changes are reflecting? Which type of server package are you using? Are your PHP files being saved as UTF-8 without BOM? If you reduce your PHP version back to 7.3x releases, is the line 166 error still showing?
Hi! Thank you so much for your response. I have deleted and re-uploaded all the files in the startup folder. Logout the site and create a new customer. Login using another computer to test. Finally, the error is solved. Thank you again.

Newbie

Posts

Joined
Sat Jun 03, 2017 6:28 pm
Who is online

Users browsing this forum: No registered users and 69 guests