Page 1 of 1

Adding 2 fields to Address (including checkout)

Posted: Sat Jul 26, 2014 1:20 am
by dfumagalli
Hello,

I need to add two varchar fields to che checkout, those fields are an extension to the customer address record. I expect to have to modify the oc_order and oc_address tables at a minimum.

Now, despite I think adding such fields is a common need in OpenCart, I haven't found a single howto or tutorial that is either complete or relatively recent (OpenCart 1.5.6+). I am not talking about adding a "Mr/Mrs" field in the customer or contact info (some tutorials about that are out there) but to adding to address and thus checkout.

I know there is at least 1 commercial mod to do that, but I have to perform so many convoluted operations it'd be hard to explain anyone the hundred or so company-imposed rules I had to code in the current OpenCart website. Furthermore the website has to interface with a proprietary CRM.

So I have to do it by myself.
I have found a 2012 discussion that mentions this task and then another that seems more recent.

All what I ask is: are the lists of files to edit, mentioned in those posts, complete and correct? Since they are different, which one is closest to being right?

Thanks in advance.

Re: Adding 2 fields to Address (including checkout)

Posted: Sat Jul 26, 2014 11:29 pm
by IP_CAM
here is a good instruction on how to do it.
http://forum.opencart.com/viewtopic.php?f=29&t=2648

It's not as easy as it may look at first view, if one is a Code-Newbie. I played around with the content of the 'Date of birth' DOB-VqMod (-Content, hardcoded) to get a little more familiar with the matter some time ago, but I experienced frequently DOB-Errors, due to not having all code implemented, as/where it should have been. So, for the moment, I forgot about 'such' Mod's..., using existing, but not used, form fields and renaming their 'Purpose'.

http://www.opencart.com/index.php?route ... n_id=16473

get some Insider-Info by checking content of such Options as well, it helps to understand the logics...

http://www.opencart.com/index.php?route ... n_id=17829

http://www.opencart.com/index.php?route ... on_id=6187

http://www.opencart.com/index.php?route ... n_id=16978

http://www.opencart.com/index.php?route ... n_id=17898

http://www.opencart.com/index.php?route ... on_id=2651

http://www.opencart.com/index.php?route ... n_id=15358

http://www.opencart.com/index.php?route ... on_id=3517

http://www.opencart.com/index.php?route ... on_id=2651

http://www.opencart.com/index.php?route ... n_id=11702


Good Luck

Ernie

ipc.li/shop

Re: Adding 2 fields to Address (including checkout)

Posted: Mon Jul 28, 2014 4:03 pm
by dfumagalli
Thank you so much!

The last link you posted is a good start to what I need to do.

I'll start with that, then I'll have to figure out where there is missing code. In fact, I have counted how many times the "address_1" string appears througout OpenCart. Out of all the address class fields, I picked it because it is quite unique so I won't get false positives.
The result: "address_1" is present in 216 (!!!) OpenCart 1.5.6 files.

Thinking about it, the totally basic and expected operation (in any database operated software) to add 1 new field looks quite daunting indeed!