Hello!
I needed to create 5 additional fields for user, so I decided to add them after "company" field.
I edited files in catalog/controller, catalog/model and catalog/view for front-end of the site and
admin/controller, admin/model and admin/view for back-end of the site
I also added new columns in "address" table of database.
Since these new fields were pretty much the same as "company" field, 1 line of text and not mandatory, I used "company" fields code as a guide to create my other fields.
At the moment everything is almost fine, I'm experiencing 1 problem, which I don't know how to fix or why is it present.
When I register account from front-end, I see all the new fields I can fill them with no problem, after registering an account information from these fields gets written to database. I can also edit/change these fields and this information will get updated in database. Everything is great when working from font-end.
Problems start with back-end. When I try to view user account "address" tab (where company field and my new fields are located) from administration panel. For some reason address information is displayed from another account, although in front-end right address information (including my custom fields) is displayed.
I also tried creating account from administration panel, in this case I can also fill my custom fields with no problem, and information from these fields also gets written to database. I can even view "address" information in front-end.
I'm using oc 1.5.1.3
I needed to create 5 additional fields for user, so I decided to add them after "company" field.
I edited files in catalog/controller, catalog/model and catalog/view for front-end of the site and
admin/controller, admin/model and admin/view for back-end of the site
I also added new columns in "address" table of database.
Since these new fields were pretty much the same as "company" field, 1 line of text and not mandatory, I used "company" fields code as a guide to create my other fields.
At the moment everything is almost fine, I'm experiencing 1 problem, which I don't know how to fix or why is it present.
When I register account from front-end, I see all the new fields I can fill them with no problem, after registering an account information from these fields gets written to database. I can also edit/change these fields and this information will get updated in database. Everything is great when working from font-end.
Problems start with back-end. When I try to view user account "address" tab (where company field and my new fields are located) from administration panel. For some reason address information is displayed from another account, although in front-end right address information (including my custom fields) is displayed.
I also tried creating account from administration panel, in this case I can also fill my custom fields with no problem, and information from these fields also gets written to database. I can even view "address" information in front-end.
I'm using oc 1.5.1.3
It is hard to pin-point the problem with no code.
Could you first of all check the database and make sure all of the data match. Could you also post these two files:
admin/controller and admin/model (the 2 files you edited to show the additional customer data)
Peter
Could you first of all check the database and make sure all of the data match. Could you also post these two files:
admin/controller and admin/model (the 2 files you edited to show the additional customer data)
Peter
For OpenCart & PHP/MySQL support feel free to PM me
Click here for my extentions
Did I help you? Donate here to show support
Thank you for a fast response!
It seems that everything matches, I just tried creating account new account and data from custom fields did get written to database exactly as I wrote it.
I added the 2 files in a zip file.
new fields are:
reg_no
bank
account
swift
http
It seems that everything matches, I just tried creating account new account and data from custom fields did get written to database exactly as I wrote it.
I added the 2 files in a zip file.
new fields are:
reg_no
bank
account
swift
http
Attachments
Well that eliminates the database end. One other question before I have a look at the code, do the fields show the data for a specific customer? For example is it always showing the details for the first customer in the database?
Peter
Peter
For OpenCart & PHP/MySQL support feel free to PM me
Click here for my extentions
Did I help you? Donate here to show support
Could you try the following and let me know what happens.
In the model file search for
Right above that can you add this code
Also, in the model file can you change the following code from:
to:
Let me know what happens when you change that
Peter
In the model file search for
Code: Select all
return $address_data;
Code: Select all
print_r($address_data);
Code: Select all
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE customer_id = " . (int)$address_id . "");
Code: Select all
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = " . (int)$address_id . "");
Peter
For OpenCart & PHP/MySQL support feel free to PM me
Click here for my extentions
Did I help you? Donate here to show support
To answer the first question - Each time I created new user, information displayed was from another user, it wasn't a specific user.
Thank you for providing these suggestions!
When I addedit caused some additional problems, but I removed it
But when I usedit solved my problem.
I'm sorry If I'm being a bit rude but I have another question, it seems that I already found a fix, just wanted to ask if it's ok.
It is also regarding file customer.php file located in admin/model/sale
When viewing order details from back end I get this error "Notice: Undefined index: address_id in /admin/model/sale/customer.php on line 218"
code for line 215 - 218Code in question (line 218) is one line below the fix you just provided, it seemed to me that this might be some leftover from some earlier mod (I didn't know about vqmod at first ), so I removed this line, which immediately fixed this error.
Is it safe to remove this line ?
Thank you again!
Thank you for providing these suggestions!
When I added
Code: Select all
print_r($address_data);
But when I used
Code: Select all
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = " . (int)$address_id . "");
I'm sorry If I'm being a bit rude but I have another question, it seems that I already found a fix, just wanted to ask if it's ok.
It is also regarding file customer.php file located in admin/model/sale
When viewing order details from back end I get this error "Notice: Undefined index: address_id in /admin/model/sale/customer.php on line 218"
code for line 215 - 218
Code: Select all
public function getAddress($address_id) {
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = " . (int)$address_id . "");
$default_query = $this->db->query("SELECT address_id FROM " . DB_PREFIX . "customer WHERE address_id = '" . (int)$address_query->row['address_id'] . "'");
Is it safe to remove this line ?
Thank you again!
I would leave it there, it is there for a reason and it may affect other parts of the admin panel because models can be used in various different locations in the admin panel.
The error is correct. $query->row['address_id'] is not being defined anywhere in the function. Try change it to this:
Let me know how you get on
Thanks
Peter
The error is correct. $query->row['address_id'] is not being defined anywhere in the function. Try change it to this:
Code: Select all
$default_query = $this->db->query("SELECT address_id FROM " . DB_PREFIX . "customer WHERE address_id = '" . (int)$address_id. "'");
Thanks
Peter
For OpenCart & PHP/MySQL support feel free to PM me
Click here for my extentions
Did I help you? Donate here to show support
Who is online
Users browsing this forum: No registered users and 115 guests