Page 2 of 3

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 7:41 pm
by straightlight
My fixes instructions above are accurate. By adding the guest fix, simply make sure to include the } at the end.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 8:04 pm
by platypuspuzzles
Ah sorry, I didn't explain myself properly.

I trust your and value your corrections.

I mean, the errors coming up catalog/model/account... files include completely different coding at the lines listed, compared to the ones we have fixed.
ERROR MESSAGE :
<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>[]
line 4 is below and I don't know how to code this to fix it

Code: Select all

$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$this->customer->getId() . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', city = '" . $this->db->escape($data['city']) . "', zone_id = '" . (int)$data['zone_id'] . "', country_id = '" . (int)$data['country_id'] . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "'");

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 8:22 pm
by straightlight
There is nothing wrong with this code. The reason why you're receiving an error message is because the controller (where you already posted the fix on the previous page) was the one needing the fix. ;)

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 8:33 pm
by platypuspuzzles
Ah, I see!
Thanks so much

So, I've made the changes to the catalog/controller/checkout/guest_shipping.php and /guest.php

So to make the errors go away for this same error, when a customer goes through 'registration' or áccount', I just need to make the same changes in these corresponding catalog/controller/checkout/[insertfilename].php

Is that right?

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 8:36 pm
by straightlight
platypuspuzzles wrote:Ah, I see!
Thanks so much

So, I've made the changes to the catalog/controller/checkout/guest_shipping.php and /guest.php

So to make the errors go away for this same error, when a customer goes through 'registration' or áccount', I just need to make the same changes in these corresponding catalog/controller/checkout/[insertfilename].php

Is that right?
That type of questioning cannot be accurate but the best methodology is always to read the lines on what the error handler provides with the filename and the line number either from the browser or from the error logs.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 8:51 pm
by platypuspuzzles
Ok, I'm learning a lot here.

I've updated the guest.php and guest_shipping.php controller files, but don't know what controller files to edit to fix the following errors

Below are my only errors that remain, that are triggered when a customer checkouts out through registering an account or logging in with an account and creating a new address.
Undefined index: company in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>
Undefined index: address_2 in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>[]

Undefined index: fax in <b>/home/.../catalog/model/account/customer.php</b> on line <b>14</b>
Undefined index: company in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>
Undefined index: address_2 in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>[]

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 9:08 pm
by straightlight
It seems the controller files that handles those model files also contains undefined and mentioned indexes. Instead of going to the model files to fix them, simply go to the controller files and apply the same type of fix you did on the previous page.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 9:19 pm
by platypuspuzzles
That's what I assumed, however I can't find the controller files I need to edit as they are named differently to those listed in the model/account/customer and model/account/address file errors

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 9:32 pm
by straightlight
Looks like you found an unanticipated requested post but a confirmed bug. Good catch !

In catalog/controller/checkout/payment_address.php file,

find:

Code: Select all

$address_id = $this->model_account_address->addAddress($this->request->post);
add above:

Code: Select all

if (empty($this->request->post['company'])) {
						$this->request->post['company'] = '';
					}
					
					if (empty($this->request->post['address_2'])) {
						$this->request->post['address_2'] = '';
					}
					
					if (empty($this->request->post['fax'])) {
						$this->request->post['fax'] = '';
					}
Note: The same needs to be applied to the shipping_address.php on the same folder.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 10:19 pm
by platypuspuzzles
Thanks so much for all your help with this!

I've made the changes to the catalog/controller/checkout/payment_address.php and shipping_address.php files but continue to get the following errors

**checkout - register new account**
<b>Notice</b>: Undefined index: fax in <b>/home/.../catalog/model/account/customer.php</b> on line <b>14</b>
<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>[]

**checkout - log in to account - change of address**
<b>Notice</b>: Undefined variable: address_id in <b>/home/.../catalog/controller/checkout/payment_address.php</b> on line <b>170</b>[]
This is the code at 170

Code: Select all

$this->session->data['payment_address'] = $this->model_account_address->getAddress($address_id);

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 10:47 pm
by straightlight
In your catalog/controller/checkout/register.php file,

find:

Code: Select all

$customer_id = $this->model_account_customer->addCustomer($this->request->post);
apply the same integration as my previous post right above; add the codes above this line this time.

As for this one:
**checkout - log in to account - change of address**

<b>Notice</b>: Undefined variable: address_id in <b>/home/.../catalog/controller/checkout/payment_address.php</b> on line <b>170</b>[]
This is the code at 170
What does your error log states regarding new added address that tries to get added on the database? A database error message would be needed on this one.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:10 pm
by platypuspuzzles
I dont know where to find the error log - nothing is listed in the admin/settings error log screen

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:21 pm
by straightlight
Let's troubleshoot this issue. In your catalog/controller/checkout/payment_address.php , shipping_address.php and register.php file,

add above each instances of:

Code: Select all

$address_id = $this->model_account_address->addAddress($this->request->post);
this code:

Code: Select all

$this->log->write(__FILE__ . ': ' . print_r($this->request->post));
Then, try the entire checkout action again. Then, go to your admin - > systems - > tools - > error log page and see if the last actions reveals one or all of those three PHP files in the logs from a few minutes from now.

If so, without full server path, please paste the results on your next reply.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:34 pm
by platypuspuzzles
O0 O0 O0 O0 HAPPY DANCE O0 O0 O0 O0

Thank you so much!!! The continued errors were because I didn't read your last guidance post properly and instead of adding the code ABOVE the line, I replaced it.

I've just tested all the different checkout options and they all work 100%

Thank you so much!

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:42 pm
by straightlight
Here we go, problem solved. :)

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:45 pm
by platypuspuzzles
For future reference or for anyone else who comes across these issues, I've attached the edited catalog/controller/checkout files that contain the appropriate changes

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:47 pm
by platypuspuzzles
files are for 2.2.0.0 upgrade changes for catalog/controller/checkout to fix JSON errors at checkout

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:48 pm
by platypuspuzzles
straightlight wrote:Here we go, problem solved. :)
Couldn't have done it without you. Thanks again.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 11:58 pm
by straightlight
Take note that if extensions are involved to edit those files not to download and use those files but rather the follow the instructions for v2.2.0.0 to avoid altering installed contributions that may rely on those specific lines especially when multiple file changes are involved.

Re: checkout page json erorrs

Posted: Thu Jul 21, 2016 12:12 pm
by gopani@gmail.com
Hi

I am getting same error "admin_controller_sale_order.php on line 2313"

Can somebody please help